Android zxing frame scan fix scan box size, picture compression problem

Source: Internet
Author: User

When we are in the zxing framework to scan the QR code, we will find that now the mobile phone with the resolution of the addition. The scanning box will be smaller, the 1920*1280 and 1280*720 are relatively normal. But Samsung's several mobile phone note4,5. S6, such as several mobile phone resolution up to 2560*1440, even some phones up to 3660 of the bar can't remember.

When these phones scan, pop-up scan activity Intermediate surfaceview Scan form Small is also drunk,

Do not say the solution to the method:

1: Find the intent that initiates the scan:

Intent opencameraintent = new Intent (context,captureactivity.class);
Startactivityforresult (opencameraintent,0);

2: Follow up the captureactivity class. Search in class:Cameramanager. follow it in. Cameramanager class: The top four rows are set to a wide height,

private static final int min_frame_width = (int) dp_sp_px_utils.dp2px (MyApplication.instance.getResources (), ();  private static final int min_frame_height = (int) dp_sp_px_utils.dp2px (MyApplication.instance.getResources (), ();  private static final int max_frame_width = (int) dp_sp_px_utils.dp2px (MyApplication.instance.getResources (), +);  private static final int max_frame_height = (int) dp_sp_px_utils.dp2px (MyApplication.instance.getResources (), 240);


I have a DP conversion in the back, so that the screen scan form size is fixed for each resolution. Perfect solution to this problem.

Second question: the picture will be compressed after each scan

Workaround: Locate the Cameraconfigurationmanager.java class under the camera package under the Zxing package and change:

Search   initfromcameraparameters This method, find Log.d under this method (TAG, "screen resolution:" + screenresolution); This sentence, in this sentence, add the following code:

Point Screenresolutionforcamera = new Point ();          screenresolutionforcamera.x = screenresolution.x;          SCREENRESOLUTIONFORCAMERA.Y = SCREENRESOLUTION.Y;          Preview size is all something like 480*320, and other 320*480          if (screenresolution.x < SCREENRESOLUTION.Y) {          screenresolutionforcamera.x = SCREENRESOLUTION.Y;          SCREENRESOLUTIONFORCAMERA.Y = screenresolution.x;          }  

Then here's a line of this code:

[Java]View Plaincopy
    1. Cameraresolution = getcameraresolution (parameters, screenresolution);

Changed to Screenresolutionforcamera in Screenresolution
For example, the following:

[Java]View Plaincopy
    1. Cameraresolution = getcameraresolution (Parameters, Screenresoluti

Save. Implementation of the perfect solution, here are two-dimensional code scanning and QR code generation demo do not need points, we learn from each other. Together with progress, problems can be raised in the comment area.



Android zxing frame scan fix scan box size, picture compression 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.