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



>伙计们,我正在开发一个用于读取二维码的安卓应用程序。我实现了库ZXing,但我不能使用相机。我需要将二维码保存为图像并使用与 ZXing 解码存储为图像的二维码相关的功能......有什么想法吗?

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

是的,您可以在不使用相机的情况下解码 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;
} 

最新更新