qrcode icon indicating copy to clipboard operation
qrcode copied to clipboard

小程序中调用最新版的 decode 结果为 undefined

Open mikoshu opened this issue 6 months ago • 3 comments

在小程序中通过 canvas 获取 imgData 按照 npm 示例执行解码 最终的 current 结果为: {value: undefined, done: true} 但是在 h5 中同样的图片就能获取到结果 是否 detected 类有用到 canvas 方法?

mikoshu avatar Aug 11 '25 09:08 mikoshu

小程序的 canvas 和 h5 不一定是兼容的,你看下获取的 imgData 是不是 rgba 数组,解码库并无和 canvas 绑定,只要接收的是标准合法的 rgba 数组即可!

nuintun avatar Aug 22 '25 14:08 nuintun

是rgba数组数据应该没问题 应为用相同的getImageData方法 jsQr 说可以正常解码的

mikoshu avatar Aug 22 '25 15:08 mikoshu

检查下 devicePixelRatio,可能是 devicePixelRatio 带来的图片缩放造成的

nuintun avatar Aug 29 '25 07:08 nuintun