在阅读了一些关于该问题的问题和帖子后,我正在尝试旋转 Zxing 显示器。按照说明操作后,显示器确实旋转了,但扫描仪的矩形未按应有的位置定位(如所附图像所示)。
这就是我所做的:
在 CameraConfigurationManager 中:
camera.setDisplayOrientation(90);
在解码处理程序.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 中:
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;