Cristiana Camilli
Cristiana Camilli

Reputation: 31

decode a QRcode image without using the camera

guys I am developing an Android app for reading QR codes. I implemented the library ZXing, but I must not use the camera. I need to get a QR code saved as an image and use the functions relating to ZXing decoding QR code stored as images ... any ideas?

I checked the forum but I need something more complete ..: (

Upvotes: 0

Views: 5581

Answers (1)

Sagar Patil
Sagar Patil

Reputation: 1400

Yes you can decode a QR without using a camera. You have to import the image from the gallery, get the bitmap and pass it to LuminanceSource source = new RGBLuminanceSource(bMap); Here is the code.

LuminanceSource source = new RGBLuminanceSource(bMap); 
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Reader reader = new MultiFormatReader();
try {
    Result result = reader.decode(bitmap);
    String contents = result.getText(); 
    byte[] rawBytes = result.getRawBytes(); 
    BarcodeFormat format = result.getBarcodeFormat(); 
    ResultPoint[] points = result.getResultPoints();
} catch (NotFoundException e) {
    e.printStackTrace();
    return;
} catch (ChecksumException e) {
    e.printStackTrace();
    return;
} catch (FormatException e) {
    e.printStackTrace();
    return;
} 

Upvotes: 6

Related Questions