Skip to content
New issue

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.java拍照预览图像拉伸问题 #49

Open
yanyw9 opened this issue Oct 26, 2021 · 1 comment

Comments

@yanyw9
Copy link

yanyw9 commented Oct 26, 2021

环境信息

  • 机型与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;
}

@TommyLemon
Copy link
Owner

赞,感谢反馈。
可以提交一个 Pull Request 来贡献下代码哦,非常感谢~
https://github.com/Tencent/APIJSON/blob/master/CONTRIBUTING.md#pull-request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants