Bug fix issue out of memory when unable to decode byte array

pull/239/head
nathaniel09 7 years ago
parent 819638862f
commit df35cbcd06
  1. 6
      cameraview/src/main/utils/com/otaliastudios/cameraview/CameraUtils.java

@ -175,6 +175,7 @@ public class CameraUtils {
}
Bitmap bitmap;
try {
if (maxWidth < Integer.MAX_VALUE || maxHeight < Integer.MAX_VALUE) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
@ -202,6 +203,11 @@ public class CameraUtils {
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
temp.recycle();
}
} catch (OutOfMemoryError e) {
// Create blank bitmap if out of memory to avoid crash
int dummySize = 100;
bitmap = Bitmap.createBitmap(dummySize, dummySize, Bitmap.Config.ARGB_8888); // this creates a MUTABLE bitmap
}
return bitmap;
}

Loading…
Cancel
Save