I tried reading from an image containing a QR code using zxing. ZXing Android Embedded
void readQrcode(Bitmap bitmap) {
    //Get the size of the Bitmap and get the pixel data
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    int[] pixels = new int[width * height];
    bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
    try {
        //Convert to Binary Bitmap format that can be handled by zxing
        LuminanceSource source = new RGBLuminanceSource(width, height, pixels);
        BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source));
        //Read and analyze image data with zxing
        Reader reader = new MultiFormatReader();
        Result decodeResult = reader.decode(binaryBitmap);
        //Get the analysis result
        String result = decodeResult.getText();
        Log.d("readQR", result);
    } catch (Exception e) {
        Log.d("readQR", e.getLocalizedMessage());
    }
}
Omit the part that reads from the file and gets the Bitmap!
Recommended Posts