bardecode.com
barcode reading software
  • Home
  • Download
  • Purchase
  • SDK Licensing
  • Pricing
    • Windows SDK Price List
    • Windows SDK with PDF Extension Price List
    • Linux SDK Price List
    • Linux SDK with PDF Extension Price List
    • PDF Extension For Windows Price List
    • Multi-Platform Toolkit for .NET Price List
    • BardecodeFiler Desktop Only Price List
    • BardecodeFiler Windows Service Price List
    • DOS Command Prompt Barcode Tool Price List
    • Terms and Conditions
    • Refund Policy
  • Products
    • Softek Barcode Reader Toolkit for Windows
    • Softek Barcode Reader Toolkit for Linux
    • BardecodeFiler Desktop App
    • BardecodeFiler Windows Service
    • Windows DOS Command Prompt Tool
    • Multi-platform barcode reader toolkit for .NET
    • Aquaforest’s Autobahn DX
  • Knowledge Base
    • Documentation
    • Specifications
  • News
  • Contact
    • About Us
    • Terms and Conditions
    • 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 © 2023 Softek Software Ltd. All Rights Reserved