【问题标题】:zxing library not scanning QR code black background and white code(Negative scan) in androidzxing库不扫描二维码黑色背景和白色代码(负扫描)在android中
【发布时间】:2017-01-07 06:02:44
【问题描述】:

在我的应用程序中使用 zxing 库扫描二维码,但库不支持扫描黑码中的白色(负扫描),所以请建议我如何解决这个问题。

【问题讨论】:

  • 你找到解决办法了吗?

标签: android zxing


【解决方案1】:

添加以下代码,source.invert() 将完成您的工作

 LuminanceSource source = new RGBLuminanceSource(bitmaps[0].getWidth(), 
 bitmaps[0].getHeight(), intArray);
 BinaryBitmap bMap = new BinaryBitmap(new HybridBinarizer(source));

        try {
            result = reader.decode(bMap);
        } catch (Exception e) {
            BinaryBitmap bMap1 = new BinaryBitmap(new HybridBinarizer(source.invert()));
            try {
                result = reader.decode(bMap1);
            } catch (NotFoundException notFoundException) {
              //  notFoundException.printStackTrace();
            } catch (ChecksumException checksumException) {
                //checksumException.printStackTrace();
            } catch (FormatException formatException) {
                //formatException.printStackTrace();
            }
        }
        return result;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多