Open yanyw9 opened 2 years ago
环境信息
问题描述
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; }
赞,感谢反馈。 可以提交一个 Pull Request 来贡献下代码哦,非常感谢~ https://github.com/Tencent/APIJSON/blob/master/CONTRIBUTING.md#pull-request
环境信息
问题描述
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; }