jenly1314 / ZXingLite

🔥 ZXing的精简极速版,优化扫码和生成二维码/条形码,内置闪光灯等功能。扫描风格支持:微信的线条样式,支付宝的网格样式。几句代码轻松拥有扫码功能 ,ZXingLite让集成更简单。(扫码识别速度快如微信)
https://jenly1314.github.io/ZXingLite/
Apache License 2.0
3.04k stars 472 forks source link

2.1.1版本在oppo A32机型上识别不了扫码 #181

Closed itsgm closed 1 year ago

itsgm commented 2 years ago

2.1.1之前的版本可以识别,整个demo的扫码都无法识别

itsgm commented 2 years ago

2.1.1不行,我回退到1.1.9版本用了,难道是camerax的问题么

yangzyqq commented 2 years ago

这个问题解决了么

wangxiongxu commented 2 years ago

2.0.3也不行

mengxn commented 2 years ago

Realme Q5手机上,2.x都识别不了,回退到1.1.9可以了。

pp520henni commented 1 year ago

VIVO Y31s 也无法扫描

qiuxfeng1985 commented 1 year ago

原因:ImageAnalyzer 解析Y数据时出现了异常,在某些手机上,remaining() 方法返回的是字节数组的容量,而不是实际大小

ByteBuffer buffer = image.getPlanes()[0].getBuffer(); byte[] data = new byte[buffer.remaining()]; buffer.get(data);

改为如下方式

int width = image.getWidth(); int height = image.getHeight(); ByteBuffer yBuffer = image.getPlanes()[0].getBuffer(); int numPixels = (int) (width height ImageFormat.getBitsPerPixel(ImageFormat.YUV_420_888) / 8); byte[] data = new byte[numPixels]; int index = 0; int yRowStride = image.getPlanes()[0].getRowStride(); int yPixelStride = image.getPlanes()[0].getPixelStride(); for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { data[index++] = yBuffer.get(y yRowStride + x yPixelStride); } }

jenly1314 commented 1 year ago

没有相关机型来进行测试验证;麻烦更新至当前最新版本 2.4.0 试试,看是否还存在此问题?

qiuxfeng1985 commented 1 year ago

在oppo A32上验证没有问题了

Allen8Lee commented 1 year ago

您发送的邮件我已收到。

jenly1314 commented 1 year ago

在oppo A32上验证没有问题了

感谢验证