Skip to content

Commit

Permalink
support required size of cropped image for URI loaded image
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Teplitzki committed Feb 12, 2015
1 parent f7ad6ac commit 3541ea5
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,22 @@ public void rotateImage(int degrees) {
* @return a new Bitmap representing the cropped image
*/
public Bitmap getCroppedImage() {
return getCroppedImage(0, 0);
}

/**
* Gets the cropped image based on the current crop window.<br/>
* If image loaded from URI will use sample size to fir the requested width and height.
*
* @return a new Bitmap representing the cropped image
*/
public Bitmap getCroppedImage(int reqWidth, int reqHeight) {
if (mLoadedImageUri != null && mLoadedSampleSize > 1) {
Rect rect = getActualCropRectNoRotation();
reqWidth = reqWidth > 0 ? reqWidth : rect.width();
reqHeight = reqHeight > 0 ? reqHeight : rect.height();
ImageViewUtil.DecodeBitmapResult result =
ImageViewUtil.decodeSampledBitmapRegion(getContext(), mLoadedImageUri, rect, rect.width(), rect.height());
ImageViewUtil.decodeSampledBitmapRegion(getContext(), mLoadedImageUri, rect, reqWidth, reqHeight);

Bitmap bitmap = result.bitmap;
if (mDegreesRotated > 0) {
Expand Down

0 comments on commit 3541ea5

Please sign in to comment.