Kannan Suresh
Kannan Suresh

Reputation: 4580

Decode QR code image using zxing library in Android

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

Answers (3)

She Smile GM
She Smile GM

Reputation: 1322

BinaryBitmap binaryBitmap=new BinaryBitmap(new HybridBinarizer(new RGBLuminanceSource(bitmap));

Upvotes: 0

nut
nut

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

Sean Owen
Sean Owen

Reputation: 66866

Look in the project code, but under androidtest/. There's a class called RGBLuminanceSource that does this.

Upvotes: 3

Related Questions