mirror of
https://github.com/status-im/react-native-image-resizer.git
synced 2025-02-17 09:07:42 +00:00
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);
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user