二維碼掃描 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);
資源下載地址
免費下載地址在 http://linux.linuxidc.com/
用戶名與密碼都是www.linuxidc.com
具體下載目錄在 /2014年資料/5月/2日/Zxing圖片拉伸解決 Android 二維碼掃描
下載方法見 http://www.linuxidc.com/Linux/2013-07/87684.htm
更多Android相關信息見Android 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=11