Skip to content

Commit

Permalink
Added code for preventing java.lang.IllegalArgumentException: bug x +…
Browse files Browse the repository at this point in the history
… width must be <= bitmap.width()
  • Loading branch information
igreenwood committed Jan 7, 2016
1 parent 2ce8f5f commit 4a58be4
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ public Bitmap getCroppedBitmap() {
Bitmap source = getBitmap();
if (source == null) return null;

int x, y, w, h;
int x, y, w, h, sw, sh;
float l = (mFrameRect.left / mScale);
float t = (mFrameRect.top / mScale);
float r = (mFrameRect.right / mScale);
Expand All @@ -1021,6 +1021,15 @@ public Bitmap getCroppedBitmap() {
w = Math.round(r - l);
h = Math.round(b - t);

if(w > source.getWidth()){
w = source.getWidth();
x = 0;
}
if(h > source.getHeight()){
h = source.getHeight();
y = 0;
}

Bitmap cropped = Bitmap.createBitmap(source, x, y, w, h, null, false);
if (mCropMode != CropMode.CIRCLE) return cropped;
return getCircularBitmap(cropped);
Expand Down Expand Up @@ -1048,6 +1057,15 @@ public Bitmap getRectBitmap() {
w = Math.round(r - l);
h = Math.round(b - t);

if(w > source.getWidth()){
w = source.getWidth();
x = 0;
}
if(h > source.getHeight()){
h = source.getHeight();
y = 0;
}

return Bitmap.createBitmap(source, x, y, w, h, null, false);
}

Expand Down

0 comments on commit 4a58be4

Please sign in to comment.