-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
环境信息
- 机型与Android版本:
- 使用ZBLibrary版本:
问题描述
package com.zxing.camera;
... ...
final class CameraConfigurationManager {
... ...
private static Point findBestPreviewSizeValue(CharSequence previewSizeValueString, Point screenResolution) {
... ...
int newDiff = Math.abs(newX - screenResolution.x) + Math.abs(newY - screenResolution.y);
if (newDiff == 0) {
bestX = newX;
bestY = newY;
break;
} else if (newDiff < diff) {
if((3 * newX) == (4 * newY)) {
bestX = newX;
bestY = newY;
diff = newDiff;
}
}
... ...
加粗代码并没有解决拍照预览图像拉伸问题。
我将这段代码替换成如下代码,发现图像不会拉伸变形,但是未在其他型号手机上测试。
float current_rate = (float) Math.max(newX, newY)/ (float)Math.min(newX, newY);
tmp_diff = Math.abs(current_rate-rate);
if( min_diff < 0){
min_diff = tmp_diff ;
bestX = newX;
bestY = newY;
}
if( tmp_diff < min_diff ){
min_diff = tmp_diff ;
bestX = newX;
bestY = newY;
}