I'm creating a android project, main feature is scan barcode.
I'm tried integrate with Zxing library into my project, and it's work fine.
However, it's seems not support scan barcode from an available image in gallery of android devices.
How i can do it? or with other barcode library?
The simple answer is yes - if the barcode scanner that you have has what is known as a 2D (two dimensional) imager as its scan engine. Barcode scanners come with two different types of scan engines.
You could use this class MultiFormatReader from ZXing library.
You have to get Gallery image in BitMap and convert it as this:
Bitmap bMap = [...];
String contents = null;
int[] intArray = new int[bMap.getWidth()*bMap.getHeight()];
//copy pixel data from the Bitmap into the 'intArray' array
bMap.getPixels(intArray, 0, bMap.getWidth(), 0, 0, bMap.getWidth(), bMap.getHeight());
LuminanceSource source = new RGBLuminanceSource(bMap.getWidth(), bMap.getHeight(), intArray);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Reader reader = new MultiFormatReader();
Result result = reader.decode(bitmap);
contents = result.getText();
UPDATE1
To manipulate big image, please have a look at :
https://developer.android.com/training/articles/memory.html
https://developer.android.com/training/displaying-bitmaps/manage-memory.html
You could use this property android:largeHeap to increase heap size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With