Zxing interface Optimization (portrait, stretch, scan box size and Scan line movement)

Source: Internet
Author: User
There is a need to scan the QR code on the project, and the more mature framework is zbar,zxing. But each has the superiority, the individual thinks still is zbar to the scanning package efficiency is relatively higher, at that time I do is scans some zbar, recognizes this map library

There are some zxing, Later found that zbar in the android5.0 above causes the project to crash directly, because of the lack of the cpu64 bit of so file, due to lack of technology to solve the problem, also did not find support 64-bit so file, the last cruel, scan QR code This module all re-do, the reference of the zxing. But later found that the interface of zxing is really ugly, or decided to optimize it.


One
The Zxing jar package is first directed into the project Libs directory, and some associated files under Res are required (Strings.xml,raw under Values Color.xml, Ids.xml, Beep.ogg).

Two


Lead the project into studio,



Three

Modify to vertical screen (refer to other people's methods)

The following code is commented out in the Initfromcameraparameters () method of the 1.CameraConfigurationManager class:

Code snippet, double-click Copy
01 02 03 04 05 06 if (width < height) {log.i (TAG, "Display reports portrait orientation;     Assuming this is incorrect ");     int temp = width;       width = height;     Height = temp; }


2. In the Setdesiredcameraparameters () method of the Cameraconfigurationmanager class, add the following code before camera.setparameters (parameters):
Code snippet, double-click Copy
01 Camera.setdisplayorientation (90);


3. Replace the following code in the Getframingrectinpreview () method of the Cameramanager class:
Code snippet, double-click Copy
01 02 03 04 Rect.left = Rect.left * cameraresolution.x/screenresolution.x; Rect.right = Rect.right * cameraresolution.x/screenresolution.x; Rect.top = Rect.top * CAMERARESOLUTION.Y/SCREENRESOLUTION.Y; Rect.bottom = Rect.bottom * CAMERARESOLUTION.Y/SCREENRESOLUTION.Y;

Replaced by
Code snippet, double-click Copy
01 02 03 04 Rect.left = Rect.left * cameraresolution.y/screenresolution.x; Rect.right = Rect.right * cameraresolution.y/screenresolution.x; Rect.top = Rect.top * CAMERARESOLUTION.X/SCREENRESOLUTION.Y;

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.