在不使用相机的情况下解码QRcode图像

Cri*_*lli 0 android qr-code zxing

我正在开发一个用于阅读QR码的Android应用程序.我实现了ZXing库,但我不能使用相机.我需要将QR码保存为图像并使用与ZXing相关的功能解码存储为图像的QR码...任何想法?

我检查了论坛,但我需要更完整的东西...... :(

Sag*_*til 5

是的,您可以在不使用相机的情况下解码QR.您必须从库中导入图像,获取位图并将其传递给LuminanceSource source = new RGBLuminanceSource(bMap); 以下是代码.

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;
} 
Run Code Online (Sandbox Code Playgroud)