Reputation: 4580
In my application I'm using the zxing library for QR decoding QR code images stored in the Android device. I would like to know how to convert Bitmap to BinaryImage to be decoded. I have found similar questions but none could solve my problem. Please help.
Upvotes: 3
Views: 5068
Reputation: 1322
BinaryBitmap binaryBitmap=new BinaryBitmap(new HybridBinarizer(new RGBLuminanceSource(bitmap));
Upvotes: 0
Reputation: 385
This is the way:
int width = bitmap.getWidth(), height = bitmap.getHeight();
int[] pixels = new int[width * height];
bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
bitmap.recycle();
bitmap = null;
RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels);
BinaryBitmap bBitmap = new BinaryBitmap(new HybridBinarizer(source));
Upvotes: 2
Reputation: 66866
Look in the project code, but under androidtest/
. There's a class called RGBLuminanceSource
that does this.
Upvotes: 3