GifResourceDecoder.java revision ea01ddd754126290fc18c3dc8f6095ce0216768a
1package com.bumptech.glide.load.resource.gif; 2 3import android.content.Context; 4import com.bumptech.glide.Glide; 5import com.bumptech.glide.load.ResourceDecoder; 6import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; 7 8import java.io.IOException; 9import java.io.InputStream; 10 11public class GifResourceDecoder implements ResourceDecoder<InputStream, GifDrawable> { 12 private Context context; 13 private BitmapPool bitmapPool; 14 15 public GifResourceDecoder(Context context) { 16 this(context, Glide.get(context).getBitmapPool()); 17 } 18 19 public GifResourceDecoder(Context context, BitmapPool bitmapPool) { 20 this.context = context; 21 this.bitmapPool = bitmapPool; 22 } 23 24 @Override 25 public GifResource decode(InputStream source, int width, int height) throws IOException { 26 GifDecoder gifDecoder = new GifDecoder(bitmapPool); 27 gifDecoder.read(source, 0); 28 GifFrameManager frameManager = new GifFrameManager(context, bitmapPool); 29 return new GifResource(gifDecoder, frameManager); 30 } 31 32 @Override 33 public String getId() { 34 return "GifResourceDecoder.com.bumptech.glide.load.gif"; 35 } 36} 37