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

Hotfix of Samsung devices #1

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ private Bitmap decodeRegionCrop(Rect rect, int outWidth, int outHeight) {
RectF adjusted = new RectF();
matrix.mapRect(adjusted, new RectF(rect));

//if the cutting box are rectangle( outWidth != outHeight ),and the exifRotation is 90 or 270,
//the outWidth and outHeight should be interchanged
if (exifRotation==90||exifRotation==270){
int temp=outWidth;
outWidth=outHeight;
outHeight=temp;
}

// Adjust to account for origin at 0,0
adjusted.offset(adjusted.left < 0 ? width : 0, adjusted.top < 0 ? height : 0);
rect = new Rect((int) adjusted.left, (int) adjusted.top, (int) adjusted.right, (int) adjusted.bottom);
Expand All @@ -335,6 +343,14 @@ private Bitmap decodeRegionCrop(Rect rect, int outWidth, int outHeight) {
if (rect.width() > outWidth || rect.height() > outHeight) {
Matrix matrix = new Matrix();
matrix.postScale((float) outWidth / rect.width(), (float) outHeight / rect.height());

//If the picture's exifRotation !=0 ,they should be rotated to 0 degrees
matrix.postRotate(exifRotation);
croppedImage = Bitmap.createBitmap(croppedImage, 0, 0, croppedImage.getWidth(), croppedImage.getHeight(), matrix, true);
} else {
//if the picture need not to be scale, they also need to be rotate to 0 degrees
Matrix matrix = new Matrix();
matrix.postRotate(exifRotation);
croppedImage = Bitmap.createBitmap(croppedImage, 0, 0, croppedImage.getWidth(), croppedImage.getHeight(), matrix, true);
}
} catch (IllegalArgumentException e) {
Expand Down