diff options
author | George Mount <mount@google.com> | 2013-05-28 16:27:44 -0700 |
---|---|---|
committer | George Mount <mount@google.com> | 2013-05-28 16:43:03 -0700 |
commit | 98df4dc894b8d8b8a6cac932ce193fddb7858e99 (patch) | |
tree | 87242bdf7adbacd226c48f5ebb7128a6321a0dd2 /src/com/android/photos | |
parent | 94472c3dc397cfa9a8fad5ba7628253ec6642ed6 (diff) | |
download | android_packages_apps_Snap-98df4dc894b8d8b8a6cac932ce193fddb7858e99.tar.gz android_packages_apps_Snap-98df4dc894b8d8b8a6cac932ce193fddb7858e99.tar.bz2 android_packages_apps_Snap-98df4dc894b8d8b8a6cac932ce193fddb7858e99.zip |
Recover from bitmap decode failure.
Skia errors out when decoding a bitmap into another bitmap
sometimes. When this situation is detected, the decode is
is retried without reusing a bitmap.
Change-Id: I935dec988ed7e115ceda9233a65d3b6083a17468
Diffstat (limited to 'src/com/android/photos')
-rw-r--r-- | src/com/android/photos/data/BitmapDecoder.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/com/android/photos/data/BitmapDecoder.java b/src/com/android/photos/data/BitmapDecoder.java index 3e5a0f778..c5101cdfb 100644 --- a/src/com/android/photos/data/BitmapDecoder.java +++ b/src/com/android/photos/data/BitmapDecoder.java @@ -97,13 +97,13 @@ public class BitmapDecoder { private static <T> Bitmap delegateDecode(Decoder<T> decoder, T input) { BitmapFactory.Options options = getOptions(); + GalleryBitmapPool pool = GalleryBitmapPool.getInstance(); try { options.inJustDecodeBounds = true; if (!decoder.decodeBounds(input, options)) { return null; } options.inJustDecodeBounds = false; - GalleryBitmapPool pool = GalleryBitmapPool.getInstance(); Bitmap reuseBitmap = pool.get(options.outWidth, options.outHeight); options.inBitmap = reuseBitmap; Bitmap decodedBitmap = decoder.decode(input, options); @@ -111,6 +111,13 @@ public class BitmapDecoder { pool.put(reuseBitmap); } return decodedBitmap; + } catch (IllegalArgumentException e) { + if (options.inBitmap == null) { + throw e; + } + pool.put(options.inBitmap); + options.inBitmap = null; + return decoder.decode(input, options); } finally { options.inBitmap = null; options.inJustDecodeBounds = false; |