Browse our Products

Aspose.BarCode for Android via Java 25.11

All Changes

KeySummaryCategory
BARCODENET-39404Improve recognition performance of inverted barcodesEnhancement

Features and Improvements

Inverted Barcodes Recognition Performance

The recognition performance for inverted barcodes, where foreground and background colors are swapped, has been significantly improved. These enhancements provide more reliable decoding:

  • in scanned documents that contain negative or inverted images,
  • in high-contrast PDF files and document-processing workflows.

The feature can be enabled via the setInverseImage(InverseImageMode) quality setting:

public void example() {
    // Initialize the barcode generator with Data Matrix type and input text
    BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.DATA_MATRIX, "0126789ABCDEFabcdef");
    // Set barcode foreground (bar) and background colors
    generator.getParameters().getBarcode().setBarColor(Color.WHITE);
    generator.getParameters().setBackColor(Color.BLACK);
    // Generate the barcode image as a Bitmap
    Bitmap barcodeBitmap = generator.generateBarCodeImage();
    // Initialize the barcode reader with the generated image and specify the decode type
    BarCodeReader reader = new BarCodeReader(barcodeBitmap, DecodeType.DATA_MATRIX);
    // Enable inverse image mode to handle white-on-black codes
    reader.getQualitySettings().setInverseImage(InverseImageMode.ENABLED);
    // Read and log all detected barcode texts
    for (BarCodeResult result : reader.readBarCodes()) {
        Log.d("Barcode", result.getCodeText());
    }
}