Don’t attempt to scale an image that could not be decoded
This commit is contained in:
parent
1921af545c
commit
d8a549bb56
|
|
@ -344,7 +344,7 @@ public class CropImageActivity extends MonitoredActivity {
|
|||
|
||||
try {
|
||||
croppedImage = decoder.decodeRegion(rect, new BitmapFactory.Options());
|
||||
if (rect.width() > outWidth || rect.height() > outHeight) {
|
||||
if (croppedImage != null && (rect.width() > outWidth || rect.height() > outHeight)) {
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.postScale((float) outWidth / rect.width(), (float) outHeight / rect.height());
|
||||
croppedImage = Bitmap.createBitmap(croppedImage, 0, 0, croppedImage.getWidth(), croppedImage.getHeight(), matrix, true);
|
||||
|
|
|
|||
Loading…
Reference in New Issue