bardecode.com
barcode reading software
  • Home
  • Download
  • Purchase
  • SDK Licensing
  • Pricing
    • Windows SDK Price List
    • Windows SDK with PDF Extension Price List
    • PDF Extension For Windows Price List
    • Linux SDK Price List
    • Multi-Platform Toolkit for .Net/Docker Price List
    • BardecodeFiler Desktop Only Price List
    • BardecodeFiler Windows Service Price List
    • DOS Command Prompt Barcode Tool Price List
  • Products
    • Barcode Reader Toolkit for Windows
    • Barcode Reader Toolkit for Linux
    • BardecodeFiler Application Desktop Only
    • BardecodeFiler Application & Windows Service
    • Windows DOS Command Prompt Barcode Tool
    • Multi-Platform Barcode Reader Toolkit for .Net Standard on Docker
    • Aquaforest’s Autobahn DX
  • Knowledge Base
    • Documentation
    • Specifications
  • News
  • Contact
    • About Us
    • Resellers
    • Links
Select Page ...

News

Using the Softek Barcode Reader Toolkit on Android with ScanBarCodeFromRGBABitmap

admin August 31, 2021 Knowledge Base, Software Development Kits

The Android version of the SDK cannot read directly from image files but it can read from a bitmap using code similar to the following:

Barcode barcode = new Barcode();

// Load your image file into a bitmap

int width = bitmap.getWidth();
int height = bitmap.getHeight();

byte[] rawBytes = new byte[width * height * 4];
int index = 0;

for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
        int colour = bitmap.getPixel(x, y);
        int red = (colour >> 16) & 0xff;
        int green = (colour >> 8) & 0xff;
        int blue = colour & 0xff;
        int alpha = 0;
        int rawIndex = index * 4
        rawBytes[rawIndex++] = (byte) red ;
        rawBytes[rawIndex++] = (byte) green;
        rawBytes[rawIndex++] = (byte) blue;
        rawBytes[rawIndex++] = (byte) alpha;

        index++;
    }
}

int n = barcode.ScanBarCodeFromRGBABitmap(bitmap.getWidth(), bitmap.getHeight(), rawBytes);

if (n > 0)
    strBarcode = barcode.GetBarString(1);

 

← New review of our SDK at “Free Apps for Me”
Softek BarcodeReader SDK now available on NuGet →
admin

  • Copyright © 2021 Softek Software Ltd. All Rights Reserved