Android的Zxing改变方向为纵向 [英] Android Zxing change orientation to portrait

查看:573
本文介绍了Android的Zxing改变方向为纵向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读的几个问题,并张贴关于发行后旋转Zxing显示。 下面的说明之后,显示并旋转,但扫描仪的矩形 没有定位,它应(如可以看到附接在图像上)。

I'm trying to rotate Zxing display after reading a few questions and posts about the issue. After following the instructions, the display did rotate, but the rectangle of the scanner is not positioned as it should (as can be seen on the image attached).

这是我做了什么:

  1. 在CameraConfigurationManager:

  1. in CameraConfigurationManager:

camera.setDisplayOrientation(90);

  • 在德codeHandler.java

  • in DecodeHandler.java

    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;         
    width = height;
    height = tmp;
    

  • 在CameraManager.java:

  • in CameraManager.java:

    rect.left = rect.left * cameraResolution.y / screenResolution.x;
    rect.right = rect.right * cameraResolution.y / screenResolution.x;
    rect.top = rect.top * cameraResolution.x / screenResolution.y;
    rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y;
    

  • 推荐答案

    很多挣扎后,我发现这个问题,我希望这将帮助别人的未来。

    After a lot of struggling, I found the problem, and I hope it will help someone in the future.

    initFromCameraParameters 的方法 CameraConfigurationManager 有一个假设,即扫描总是风景模式,并为此修复时,宽度LT;身高。 如果您按照问题的步骤,并删除此检查,它工作正常。

    On initFromCameraParameters method in CameraConfigurationManager there is an assumption that the scan is ALWAYS in landscape mode, and therefor a fix when width < height. If You follow the steps in the question and remove this check, it works fine.

    这篇关于Android的Zxing改变方向为纵向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆