aboutsummaryrefslogtreecommitdiff
path: root/third_party
diff options
context:
space:
mode:
authorSam Judd <judds@google.com>2014-10-17 09:03:01 -0700
committerSam Judd <judds@google.com>2014-10-17 09:03:01 -0700
commit162c0ca87fa61299bfd13b18fe8bea76772e05f0 (patch)
treecf181c925196f3200d7f4a33a9785338950d487b /third_party
parentd88c2f7df8007f44fb2b6ec3c00eac280fb298ec (diff)
downloadglide-162c0ca87fa61299bfd13b18fe8bea76772e05f0.tar.gz
Add api to set default decode format.
Fixes #177.
Diffstat (limited to 'third_party')
-rw-r--r--third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java15
1 files changed, 14 insertions, 1 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 4e82f84b..efef2392 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
@@ -113,6 +113,7 @@ public class GifDecoder {
private GifHeaderParser parser = new GifHeaderParser();
private Bitmap previousImage;
private boolean savePrevious;
+ private Bitmap.Config config;
/**
* An interface that can be used to provide reused {@link android.graphics.Bitmap}s to avoid GCs from constantly
@@ -151,6 +152,10 @@ public class GifDecoder {
return data;
}
+ public void setPreferredConfig(Bitmap.Config config) {
+ this.config = config;
+ }
+
/**
* Move the animation frame counter forward.
*/
@@ -625,8 +630,16 @@ public class GifDecoder {
return n;
}
+ private Bitmap.Config getPreferredConfig() {
+ if (config == Bitmap.Config.RGB_565 && !header.isTransparent) {
+ return Bitmap.Config.RGB_565;
+ } else {
+ return Bitmap.Config.ARGB_8888;
+ }
+ }
+
private Bitmap getNextBitmap() {
- Bitmap.Config targetConfig = header.isTransparent ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
+ Bitmap.Config targetConfig = getPreferredConfig();
Bitmap result = bitmapProvider.obtain(header.width, header.height, targetConfig);
if (result == null) {
result = Bitmap.createBitmap(header.width, header.height, targetConfig);