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).
This is what I have done:
in CameraConfigurationManager:
camera.setDisplayOrientation(90);
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;
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.
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.