Bitmap OOM and rotation fixes

// FREEBIE
This commit is contained in:
Jake McGinty
2014-12-29 16:40:37 -08:00
parent bec5e45605
commit 348352cc71
3 changed files with 22 additions and 4 deletions

View File

@@ -68,7 +68,15 @@ public class BitmapUtil {
public static Bitmap createScaledBitmap(Context context, MasterSecret masterSecret, Uri uri, int maxWidth, int maxHeight)
throws BitmapDecodingException, FileNotFoundException
{
return createScaledBitmap(context, masterSecret, uri, maxWidth, maxHeight, false);
Bitmap bitmap;
try {
bitmap = createScaledBitmap(context, masterSecret, uri, maxWidth, maxHeight, false);
} catch(OutOfMemoryError oome) {
Log.w(TAG, "OutOfMemoryError when scaling precisely, doing rough scale to save memory instead");
bitmap = createScaledBitmap(context, masterSecret, uri, maxWidth, maxHeight, true);
}
return bitmap;
}
private static Bitmap createScaledBitmap(Context context, MasterSecret masterSecret, Uri uri, int maxWidth, int maxHeight, boolean constrainedMemory)