Android Project Combat (44): zxing Two-dimensional code switching horizontal screen scanning

Source: Internet
Author: User

Original: Android Project Combat (44): zxing Two-dimensional code switching horizontal screen scanning

Demo Link

The default is portrait scanning, but when we configure the horizontal screen display in the manifest file:

  <activity            android:name=". Captureactivity"            android:screenorientation="landscape"             android:theme="@android: Style/theme.notitlebar.fullscreen" / >

This time scan, you will find that the scanning effect deformation, the direction is wrong.

You can modify it by following these steps:

1, modify the setdesiredcameraparameters function in Cameraconfigurationmanager.java ,

Camera.setdisplayorientation (90); ---> camera.setdisplayorientation (0);

2. Modify Cameramanager.java 's getframingrectinpreview () function to change to the following, change x to Y, y to X

Rect.left = Rect.left * cameraresolution.x/ screenresolution.x;   = Rect.right * cameraresolution.x/  screenresolution.x;   = Rect.top * CAMERARESOLUTION.Y/ screenresolution.y;   = Rect.bottom * CAMERARESOLUTION.Y/  screenresolution.y;  

3, modify the decode function in Decodehandler.java

4. Other modifiable parts refer to GitHub Demo

Can be set: the width of the middle line in the scan box in the middle line of the scan box and the gap between the left and right of the scan box, the distance between each of the four green corner corresponding to the length, width, color, transparency, the top position of the middle sliding line, the lowest-end position scan line  is a picture occlusion layer color, The color of the area outside the square flash point color Other features: Flash on the local get picture read QR code current XXX Time no scan, close the current scan QR code interface

Android Project Combat (44): zxing QR code switching horizontal screen scanning

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.