Android project combat (forty-four): Zxing QR code switching horizontal screen scanning

Original: Android project combat (forty-four): Zxing QR code switching horizontal screen scanning

Demo link

The default is to scan in portrait, but when we configure landscape in the manifest file:

  <activity
            android:name=".CaptureActivity"
            android:screenOrientation="landscape"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />

At this time, when scanning, you will find that the scanning effect is deformed and the direction is wrong.

 

It can be modified as follows:

1. Modify the setDesiredCameraParameters function in CameraConfigurationManager.java ,

      camera.setDisplayOrientation(90);   --->    camera.setDisplayOrientation(0);

     

 

2. Modify the getFramingRectInPreview() function of CameraManager.java as follows, that is, change x to y and y to x

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;  

 

3. Modify the decode function in DecodeHandler.java

 

4. Other modifiable parts refer to Github Demo 

Configurable:
The width of the middle line in the scan box
The gap between the middle line of the scan frame and the left and right of the scan frame
The distance the middle line moves per refresh
The length, width, color, and transparency corresponding to the four green corners
The topmost position and the bottommost position of the middle sliding line
A scanline is a picture
The color of the occlusion layer, the color of the area outside the square
flash color

Other functions:
flash on
Get pictures from local to read QR code
If there is no scanning within the current xxx time, close the current scanning QR code interface

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325112455&siteId=291194637