From 0c8659e41be8679c5f06b41ea7c2b6ad6d85c5a4 Mon Sep 17 00:00:00 2001 From: Carlos Sobrinho Date: Tue, 3 Sep 2013 20:44:29 +0200 Subject: [PATCH] - In some rare situations the BitmapFactory can throw a IllegalArgumentException when ever the opts.inBitmap is not null and the native part of the decoder returns a null. My impression is that either there is a rare problem with the bitmap pool (wrong dimensions) or the image might have a different config (png vs gif for instance). Signed-off-by: Carlos Sobrinho --- .../src/com/bumptech/glide/resize/load/Downsampler.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/library/src/com/bumptech/glide/resize/load/Downsampler.java b/library/src/com/bumptech/glide/resize/load/Downsampler.java index cb921153b2..98d159d48b 100644 --- a/library/src/com/bumptech/glide/resize/load/Downsampler.java +++ b/library/src/com/bumptech/glide/resize/load/Downsampler.java @@ -162,9 +162,11 @@ private Bitmap decodeStream(RecyclableBufferedInputStream bis, BitmapFactory.Opt //won't go past our pre-allocated 16kb } - final Bitmap result = BitmapFactory.decodeStream(bis, null, options); - + Bitmap result = null; + try { + result = BitmapFactory.decodeStream(bis, null, options); + if (options.inJustDecodeBounds) { bis.reset(); bis.clearMark(); @@ -173,6 +175,8 @@ private Bitmap decodeStream(RecyclableBufferedInputStream bis, BitmapFactory.Opt } } catch (IOException e) { e.printStackTrace(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); } return result;