Android Zxing QR code scanning image stretching,
In this project, the QR code scanning is integrated with zxing, and the image on the scanning interface is obviously stretched and deformed.
Based on past experience, this problem is generally caused by misplacement of x and Y axes. The problem of x and Y axes can be solved.
Because of this problem, many people have encountered it before and shared it online, so I don't need to repeat the wheel here.
Here I read a blog: http://blog.csdn.net/aaawqqq/article/details/24852915. I used the following method,
The image stretching problem is solved successfully.
The solution is as follows:
Modify the initFromCameraParameters method in CameraConfigurationManager. Java:
void initFromCameraParameters(Camera camera) { Camera.Parameters parameters = camera.getParameters(); previewFormat = parameters.getPreviewFormat(); previewFormatString = parameters.get("preview-format"); Log.d(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString); WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); screenResolution = new Point(display.getWidth(), display.getHeight()); Log.d(TAG, "Screen resolution: " + screenResolution); //added Point screenResolutionForCamera = new Point(); screenResolutionForCamera.x = screenResolution.x; screenResolutionForCamera.y = screenResolution.y; // preview size is always something like 480*320, other 320*480 if (screenResolution.x < screenResolution.y) { screenResolutionForCamera.x = screenResolution.y; screenResolutionForCamera.y = screenResolution.x; } cameraResolution = getCameraResolution(parameters, screenResolutionForCamera);// cameraResolution = getCameraResolution(parameters, screenResolution); Log.d(TAG, "Camera resolution: " + screenResolution); }
View Code