Web Demos

BARCODE READER SDK DEMO

Explore the flexibe barcode reading settings to optimize for your specific usage scenario.

WEB TWAIN SDK DEMO

Try the most popular web scanner features: scan images, import local images and PDF files, edit, save to local, upload to database, and etc.

BARCODE READER JAVASCRIPT DEMO

Transform any camera-equipped devices into real-time, browser-based barcode and QR code scanners.

MRZ SCANNER WEB DEMO

Detects the machine-readable zone of a passport, scans the text, and parses into human-readable data.

APP STORE DEMOS

BARCODE READER SDK FOR IOS

BARCODE READER SDK FOR ANDROID

VIEW MORE DEMOS >
Dev Center
Table of contents

Thanks for downloading Dynamsoft Barcode Reader Package!

Your download will start shortly. If your download does not begin, click here to retry.

Read Inverted Barcodes

Typically, barcodes are dark on a light background. But in some cases, the barcodes are “inverted” – light barcodes on a dark background, as shown in the image below.

Inverted Barcodes

Inverted Barcodes

The feature to decode such inverted barcodes is not enabled by default. To control this feature, we must use the GrayscaleTransformationModes. Now for a quick breakdown of each of the modes:

  • With only GTM_ORIGINAL enabled in GrayscaleTransformationModes, DBR scans only general black-on-white barcodes.
  • With only GTM_INVERTED enabled in GrayscaleTransformationModes, DBR scans only inverted barcodes.
  • When GTM_ORIGINAL is enabled as the first mode and GTM_INVERTED is enabled as the second mode in GrayscaleTransformationModes, DBR will try to decode general barcodes first. If the count of decoded barcodes does not reach the expected number, DBR will then try decoding the inverted barcodes.

To allow for inverted barcodes, add the value GTM_INVERTED to GrayscaleTransformationModes as shown in the code snippet below:

  • JavaScript
  • Android
  • Objective-C
  • Swift
  • C
  • C++
  • C#
  • Java
  • Python
// Obtains the current runtime settings of DBR.
let settings = await scanner.getRuntimeSettings();
// Adds GTM_INVERTED to grayscaleTransformationModes.
settings.furtherModes.grayscaleTransformationModes = [Dynamsoft.DBR.EnumGrayscaleTransformationMode.GTM_ORIGINAL, Dynamsoft.DBR.EnumGrayscaleTransformationMode.GTM_INVERTED];
// Updates the settings.
await scanner.updateRuntimeSettings(settings);
// Obtain current runtime settings of `reader` instance.
PublicRuntimeSettings settings = reader.getRuntimeSettings();
// Add GTM_INVERTED to GrayscaleTransformationModes to decode inverted barcodes.
settings.furtherModes.grayscaleTransformationModes = new int[]{EnumGrayscaleTransformationMode.GTM_ORIGINAL, EnumGrayscaleTransformationMode.GTM_INVERTED};
// Update the settings.
reader.updateRuntimeSettings(settings);
NSError* err = nil;
// Obtain current runtime settings of `reader` instance.
iPublicRuntimeSettings* settings = [reader getRuntimeSettings:&err];
// Add GTM_INVERTED to GrayscaleTransformationModes to decode inverted barcodes.
settings.furtherModes.grayscaleTransformationModes = @[@(EnumGrayscaleTransformationModeOriginal),@(EnumGrayscaleTransformationModeInverted)];
// Update the settings.
[reader updateRuntimeSettings:settings error:&err];
// Obtain current runtime settings of `barcodeReader` instance.
let settings = try? barcodeReader.getRuntimeSettings()
// Add GTM_INVERTED to GrayscaleTransformationModes to decode inverted barcodes.
settings?.furtherModes.grayscaleTransformationModes = [EnumGrayscaleTransformationMode.original, EnumGrayscaleTransformationMode.inverted]
// Update the settings.
try? barcodeReader.updateRuntimeSettings(settings!)
PublicRuntimeSettings settings;
char szErrorMsg[256] = {0};
// Obtain current runtime settings of `reader` instance.
DBR_GetRuntimeSettings(reader, &settings);
// Add GTM_INVERTED to GrayscaleTransformationModes to decode inverted barcodes.
settings.furtherModes.grayscaleTransformationModes[0] = GTM_ORIGINAL;
settings.furtherModes.grayscaleTransformationModes[1] = GTM_INVERTED;
// Update the settings.
DBR_UpdateRuntimeSettings(reader, &settings, szErrorMsg, 256);
PublicRuntimeSettings settings;
char szErrorMsg[256] = {0};
// Obtain current runtime settings of `reader` instance.
reader.GetRuntimeSettings(&settings);
// Add GTM_INVERTED to GrayscaleTransformationModes to decode inverted barcodes.
settings.furtherModes.grayscaleTransformationModes[0] = GTM_ORIGINAL;
settings.furtherModes.grayscaleTransformationModes[1] = GTM_INVERTED;
// Update the settings.
reader.UpdateRuntimeSettings(&settings, szErrorMsg, 256);
// Obtain current runtime settings of `reader` instance.
PublicRuntimeSettings settings = reader.GetRuntimeSettings();
// Add GTM_INVERTED to GrayscaleTransformationModes to decode inverted barcodes.
settings.FurtherModes.GrayscaleTransformationModes[0] = GTM_ORIGINAL;
settings.FurtherModes.GrayscaleTransformationModes[1] = GTM_INVERTED;
// Update the settings.
reader.UpdateRuntimeSettings(settings);
// Obtain current runtime settings of `reader` instance.
PublicRuntimeSettings settings = reader.getRuntimeSettings();
// Add GTM_INVERTED to GrayscaleTransformationModes to decode inverted barcodes.
settings.furtherModes.grayscaleTransformationModes = new int[]{EnumGrayscaleTransformationMode.GTM_ORIGINAL, EnumGrayscaleTransformationMode.GTM_INVERTED};
// Update the settings.
reader.updateRuntimeSettings(settings);
# Obtain current runtime settings of `reader` instance.
settings = reader.get_runtime_settings()
# Add GTM_INVERTED to GrayscaleTransformationModes to decode inverted barcodes.
settings.grayscale_transformation_modes[0] = EnumGrayscaleTransformationMode.GTM_ORIGINAL
settings.grayscale_transformation_modes[1] = EnumGrayscaleTransformationMode.GTM_INVERTED
# Update the settings.
reader.update_runtime_settings(settings)

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

In this article:

latest version

    • Latest version
    • Version 9.x
      • Version 9.2.0
      • Version 9.0.0
    • Version 8.x
      • Version 8.8.0
      • Version 8.6.0
      • Version 8.4.0
      • Version 8.2.0
      • Version 8.1.2
      • Version 8.1.0
      • Version 8.0.0
    • Version 7.x
      • Version 7.6.0
      • Version 7.5.0
    Change +
    © 2003–2023 Dynamsoft. All rights reserved.
    Privacy Statement / Site Map / Home / Purchase / Support