Don’t attempt to scale an image that could not be decoded

This commit is contained in:
Jamie McDonald 2015-11-20 15:22:41 +01:00
parent 1921af545c
commit d8a549bb56
1 changed files with 1 additions and 1 deletions

View File

@ -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);