原博客地址:http://blog.csdn.net/android_cmos/article/details/52186453
如果是直接引用的zxing包里面的camera文件时,可能会出现扫描的二维码在扫描框内出现拉伸问题,因为Zxing包里的二维码扫描默认是横屏扫描的,改为竖屏后出现比例问题,所以要修正过来。
可以在camera包里面的CameraConfigurationManager.java文件里的
void initFromCameraParameters(Camera camera)方法
在 Log.d(TAG, "Screen resolution: " + screenResolution);这句之后增加
- 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, screenResolution);
- cameraResolution = getCameraResolution(parameters, screenResolutionForCamera);