1package com.bumptech.glide.load.resource.gif; 2 3import android.graphics.Bitmap; 4import com.bumptech.glide.load.engine.Resource; 5import com.bumptech.glide.gifdecoder.GifDecoder; 6import com.bumptech.glide.load.ResourceDecoder; 7import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; 8import com.bumptech.glide.load.resource.bitmap.BitmapResource; 9 10import java.io.IOException; 11 12class GifFrameResourceDecoder implements ResourceDecoder<GifDecoder, Bitmap> { 13 private BitmapPool bitmapPool; 14 15 public GifFrameResourceDecoder(BitmapPool bitmapPool) { 16 this.bitmapPool = bitmapPool; 17 } 18 19 @Override 20 public Resource<Bitmap> decode(GifDecoder source, int width, int height) throws IOException { 21 Bitmap bitmap = source.getNextFrame(); 22 return new BitmapResource(bitmap ,bitmapPool); 23 } 24 25 @Override 26 public String getId() { 27 return "GifFrameResourceDecoder.com.bumptech.glide.load.resource.gif"; 28 } 29} 30