Skip to content
Open
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 @@ -1250,6 +1250,12 @@ private Bitmap getCroppedBitmapFromUri() throws IOException {
}

private Rect calcCropRect(int originalImageWidth, int originalImageHeight) {
int imageW = Math.round(getRotatedWidth(mAngle, originalImageWidth, originalImageHeight));
int imageH = Math.round(getRotatedHeight(mAngle, originalImageWidth, originalImageHeight));

if (!mIsCropEnabled) {
return new Rect(0, 0, imageW, imageH);
}
float scaleToOriginal =
getRotatedWidth(mAngle, originalImageWidth, originalImageHeight) / mImageRect.width();
float offsetX = mImageRect.left * scaleToOriginal;
Expand All @@ -1258,8 +1264,6 @@ private Rect calcCropRect(int originalImageWidth, int originalImageHeight) {
int top = Math.round(mFrameRect.top * scaleToOriginal - offsetY);
int right = Math.round(mFrameRect.right * scaleToOriginal - offsetX);
int bottom = Math.round(mFrameRect.bottom * scaleToOriginal - offsetY);
int imageW = Math.round(getRotatedWidth(mAngle, originalImageWidth, originalImageHeight));
int imageH = Math.round(getRotatedHeight(mAngle, originalImageWidth, originalImageHeight));
return new Rect(Math.max(left, 0), Math.max(top, 0), Math.min(right, imageW),
Math.min(bottom, imageH));
}
Expand Down