Android Zxing二维码扫描图片拉伸 Android Zxing二维码扫描图片拉伸的解决办法
NDK-baozi 人气:0想了解Android Zxing二维码扫描图片拉伸的解决办法的相关内容吗,NDK-baozi在本文为您仔细讲解Android Zxing二维码扫描图片拉伸的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Android二维码扫描图片拉伸,Android,Zxing图片拉伸,Android图片拉伸,下面大家一起来学习吧。
二维码扫描,Android Zxing图片拉伸解决。
Zxing是google提供的二维码扫描工程
默认是横屏的 转换成竖屏后图片出现拉伸
这里提供解决办法:
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);
资源下载地址:Android Zxing
加载全部内容