ZoharAndroid / zoharandroid.github.io

Other
4 stars 2 forks source link

Zxing实现竖屏扫二维码 #28

Open ZoharAndroid opened 5 years ago

ZoharAndroid commented 5 years ago

https://zoharandroid.github.io/2019-08-13-zxing%E5%AE%9E%E7%8E%B0%E7%AB%96%E5%B1%8F%E6%89%AB%E4%BA%8C%E7%BB%B4%E7%A0%81/

基于Zxing库实现竖屏二维码扫码

beanu commented 4 years ago

是不是少了一段代码? 我运行之后报错。 我在DecodeHandler中的decode中PlanarYUVLuminanceSource source定义之前添加如下代码后运行正常。


byte[] rotatedData = new byte[data.length];
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                rotatedData[x * height + height - y - 1] = data[x + y * width];
            }
        }
        int tmp = width; // Here we are swapping, that's the difference to #11
        width = height;
        height = tmp;
        data = rotatedData;
'''