Fix crash OutOfMemoryError. (#103)
This commit is contained in:
parent
7b9445743c
commit
cefb679432
|
@ -45,7 +45,11 @@ class ImageResizer {
|
|||
|
||||
int finalWidth = (int) (width * ratio);
|
||||
int finalHeight = (int) (height * ratio);
|
||||
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);
|
||||
try {
|
||||
retVal = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
|
||||
} catch (OutOfMemoryError e) {
|
||||
return null;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue