"QRCode" zxing the vertical screen and solve the deformation problem

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.