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

相机竖屏拍摄的照片会被旋转9度,导致条形码解析不出来 #265

Open
wangliu1994 opened this issue Oct 10, 2020 · 0 comments

Comments

@wangliu1994
Copy link

在使用analyzeBitmap方法解析图片时,可以加入图片旋转角度的判断,从而使解析的bitmap不被旋转导致条形码解析报错
public static int readPictureDegree(String imageFilePath) {
int degree = 0;
try {
ExifInterface exifInterface = new ExifInterface(imageFilePath);
int orientation =
exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
degree = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
degree = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
degree = 270;
break;
}
} catch (IOException e) {
e.printStackTrace();
}
return degree;
}

Matrix matrix = new Matrix();
matrix.reset();
matrix.setRotate(readPictureDegree(imageFilePath));
bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);

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

1 participant