We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用中发现扫描的二维码被拉伸了,本来是正方形的,拉伸成长方形的,虽然不影响使用,但是显示效果不好,排查代码,发现是CameraConfigurationManager下findBestPreviewSizeValue方法出现问题,该方法目的是找到最合适的预览尺寸,修改后的代码如下
private static Point findBestPreviewSizeValue(CharSequence previewSizeValueString, Point screenResolution) { int bestX = 0; int bestY = 0; float diff = Integer.MAX_VALUE; for (String previewSize : COMMA_PATTERN.split(previewSizeValueString)) {
previewSize = previewSize.trim(); int dimPosition = previewSize.indexOf('x'); if (dimPosition < 0) { Log.w(TAG, "Bad preview-size: " + previewSize); continue; } int newX; int newY; try { newX = Integer.parseInt(previewSize.substring(0, dimPosition)); newY = Integer.parseInt(previewSize.substring(dimPosition + 1)); } catch (NumberFormatException nfe) { Log.w(TAG, "Bad preview-size: " + previewSize); continue; } //int newDiff = Math.abs(newX - screenResolution.x) + Math.abs(newY - screenResolution.y); float newDiff = Math.abs((float) newX/newY-(float)screenResolution.x/screenResolution.y); if (newDiff == 0) { bestX = newX; bestY = newY; break; } else if (newDiff < diff) { bestX = newX; bestY = newY; diff = newDiff; } } if (bestX > 0 && bestY > 0) { return new Point(bestX, bestY); } return null; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
使用中发现扫描的二维码被拉伸了,本来是正方形的,拉伸成长方形的,虽然不影响使用,但是显示效果不好,排查代码,发现是CameraConfigurationManager下findBestPreviewSizeValue方法出现问题,该方法目的是找到最合适的预览尺寸,修改后的代码如下
private static Point findBestPreviewSizeValue(CharSequence previewSizeValueString, Point screenResolution) {
int bestX = 0;
int bestY = 0;
float diff = Integer.MAX_VALUE;
for (String previewSize : COMMA_PATTERN.split(previewSizeValueString)) {
The text was updated successfully, but these errors were encountered: