Zxing图片拉伸解决 Android 二维码扫描

版权声明:本文为博主原创文章。未经博主同意不得转载。 https://blog.csdn.net/aaawqqq/article/details/24852915

?二维码扫描? Android Zxing图片拉伸解决

Zxing是google提供的二维码扫描project

默认是横屏的? 转换成竖屏后图片出现拉伸

这里提供解决的方法:

Zxing? 改动?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);

中的screenResolution改为? screenResolutionForCamera
例如以下:

cameraResolution = getCameraResolution(parameters, screenResolutionForCamera);

?

Zxing图片拉伸解决 Android 二维码扫描

?

不足之处请在下方留言? 谢谢

希望对您实用

资源下载地址:http://download.csdn.net/detail/aaawqqq/7281577

?

上一篇:iOS性能优化-内存优化


下一篇:axios的post传参时,将参数转为form表单格式