diff options
author | Sam Judd <judds@google.com> | 2014-10-26 12:45:53 -0700 |
---|---|---|
committer | Sam Judd <judds@google.com> | 2014-10-26 13:40:23 -0700 |
commit | b67bebb4bb4b194ce2cbea5c6f68c87a762e9b70 (patch) | |
tree | b51157101efd3a9675fb95eef065e948e42c88fa /third_party/gif_decoder/src/main/java/com/bumptech/glide | |
parent | 9f6146784f4a8cd8c980d79e3915959718613ff2 (diff) | |
download | glide-b67bebb4bb4b194ce2cbea5c6f68c87a762e9b70.tar.gz |
Always use ARGB_8888 to decode gif frames.
Fixes #216.
Diffstat (limited to 'third_party/gif_decoder/src/main/java/com/bumptech/glide')
-rw-r--r-- | third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java b/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java index f5c05a15..c4b4281d 100644 --- a/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java +++ b/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java @@ -98,6 +98,11 @@ public class GifDecoder { private static final int INITIAL_FRAME_POINTER = -1; + // We can't tell if a gif has transparency to decode a partial frame on top of a previous frame, or if the final + // frame will actually have transparent pixels, so we must always use a format that supports transparency. We can't + // use ARGB_4444 because of framework issues drawing onto ARGB_4444 Bitmaps using Canvas. + private static final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888; + // Global File Header values and parsing flags. // Active color table. private int[] act; @@ -123,7 +128,6 @@ public class GifDecoder { private BitmapProvider bitmapProvider; private Bitmap previousImage; private boolean savePrevious; - private Bitmap.Config config; private int status; /** @@ -164,10 +168,6 @@ public class GifDecoder { return data; } - public void setPreferredConfig(Bitmap.Config config) { - this.config = config; - } - /** * Returns the current status of the decoder. * @@ -684,21 +684,10 @@ public class GifDecoder { return n; } - private Bitmap.Config getPreferredConfig() { - // We can't tell if a gif has transparency to decode a partial frame on top of a previous frame, or if the final - // frame will actually have transparent pixels, so we must always use a format that supports transparency. - if (config == Bitmap.Config.RGB_565 || config == Bitmap.Config.ARGB_4444) { - return Bitmap.Config.ARGB_4444; - } else { - return Bitmap.Config.ARGB_8888; - } - } - private Bitmap getNextBitmap() { - Bitmap.Config targetConfig = getPreferredConfig(); - Bitmap result = bitmapProvider.obtain(header.width, header.height, targetConfig); + Bitmap result = bitmapProvider.obtain(header.width, header.height, BITMAP_CONFIG); if (result == null) { - result = Bitmap.createBitmap(header.width, header.height, targetConfig); + result = Bitmap.createBitmap(header.width, header.height, BITMAP_CONFIG); } setAlpha(result); return result; |