Catch OOM on decode image

This commit is contained in:
M66B
2019-10-23 18:28:11 +02:00
parent 8e9d6da937
commit 8be6738a7a

View File

@@ -504,6 +504,15 @@ class ImageHelper {
}
static Bitmap decodeImage(File file, int scaleToPixels) {
try {
return decodeImage(file, scaleToPixels);
} catch (OutOfMemoryError ex) {
Log.e(ex);
return null;
}
}
private static Bitmap _decodeImage(File file, int scaleToPixels) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(file.getAbsolutePath(), options);