【发布时间】:2017-01-07 06:02:44
【问题描述】:
在我的应用程序中使用 zxing 库扫描二维码,但库不支持扫描黑码中的白色(负扫描),所以请建议我如何解决这个问题。
【问题讨论】:
-
你找到解决办法了吗?
在我的应用程序中使用 zxing 库扫描二维码,但库不支持扫描黑码中的白色(负扫描),所以请建议我如何解决这个问题。
【问题讨论】:
添加以下代码,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;
【讨论】: