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
- Cameraresolution = getcameraresolution (parameters, screenresolution);
Changed to Screenresolutionforcamera in Screenresolution
For example, the following:
[Java]View Plaincopy
- 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