Using the Softek Barcode Reader Toolkit on Android with ScanBarCodeFromRGBABitmap
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);