Fix crash OutOfMemoryError. (#103)

This commit is contained in:
Alexander Sergeev 2017-09-17 16:51:45 +03:00 committed by Florian Rival
parent 7b9445743c
commit cefb679432
1 changed files with 10 additions and 2 deletions

View File

@ -45,7 +45,11 @@ class ImageResizer {
int finalWidth = (int) (width * ratio);
int finalHeight = (int) (height * ratio);
newImage = Bitmap.createScaledBitmap(image, finalWidth, finalHeight, true);
try {
newImage = Bitmap.createScaledBitmap(image, finalWidth, finalHeight, true);
} catch (OutOfMemoryError e) {
return null;
}
}
return newImage;
@ -60,7 +64,11 @@ class ImageResizer {
Matrix matrix = new Matrix();
matrix.postRotate(angle);
retVal = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
try {
retVal = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
} catch (OutOfMemoryError e) {
return null;
}
return retVal;
}