Step 1:add following lines to rotate data before Buildluminancesource (..) in decode (byte[] data, int width, int height)
Decodehandler.java:
bytenewbyte[data.length];for (int0; y < height; y++) { for (int0; x < width; x++) 1] = data[x + y * width];}int tmp = width;width = height;height = tmp;PlanarYUVLuminanceSource source = activity.getCameraManager().buildLuminanceSource(rotatedData, width, height);
Step 2:modify Getframingrectinpreview ().
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;
Step 3:disable the check for Landscape Mode in Initfromcameraparameters (...)
Cameraconfigurationmanager.java
Camera. ParametersParameters = Camera. GetParameters();WindowManager manager = (WindowManager) context. Getsystemservice(Context. WINDOW_service);Display display = Manager. Getdefaultdisplay();int width = display. GetWidth();int height = display. GetHeight();if (width < height) {int temp = width;width = height;Height = Temp;} screenresolution = new Point (height, width);Cameraresolution = findbestpreviewsizevalue (Parameters, new point (width, height));
Step 4:add following line to rotate Camera insetdesiredcameraparameters (...)
Cameraconfigurationmanager.java
camera.setDisplayOrientation(90);
Step 5:do not forget to set orientation of activity to portrait. I.e:manifest
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"QRCode" zxing the vertical screen and solve the deformation problem