After Android uses Zxing to scan the QR code and change it to a portrait screen, the preview screen is stretched and distorted.
Perfect solution: After Android uses Zxing to scan the QR code and changes it to a portrait screen, the preview screen is stretched and distorted.
Step 1: Find
com.zxing.camera
Package
CameraConfigurationManager.java
File
void initFromCameraParameters(Camera camera)
Method
Step 2:
Log.d(TAG, Screen resolution: + screenResolution);
Add the following code
Point screenResolutionForCamera = new Point();screenResolutionForCamera.x = screenResolution.x;screenResolutionForCamera.y = screenResolution.y;// preview size is always something like 480*320, other 320*480if (screenResolution.x < screenResolution.y) { screenResolutionForCamera.x = screenResolution.y; screenResolutionForCamera.y = screenResolution.x;}
Step 3: replace
screenResolution
Is
screenResolutionForCamera
cameraResolution = getCameraResolution(parameters, screenResolution);
Replace the above Code with the following code (for example)
cameraResolution = getCameraResolution(parameters, screenResolutionForCamera);
VcHLQ1NORCC1xL2yyqbR + fill = "brush: java;">/*** -------------- * Welcome to reprint | reprinted please note * -------------- * if it is helpful to you, please click | top | * -------------- * Please keep humble | you will go further * -------------- * @ author zsl * @ github https://github.com/yy1300326388 * @ blog http://blog.csdn.net/yy1300326388 */