下面列出了com.bumptech.glide.gifdecoder.GifDecoder# BitmapProvider ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public GifState(GifHeader header, byte[] data, Context context,
Transformation<Bitmap> frameTransformation, int targetWidth, int targetHeight,
GifDecoder.BitmapProvider provider, BitmapPool bitmapPool, Bitmap firstFrame) {
if (firstFrame == null) {
throw new NullPointerException("The first frame of the GIF must not be null");
}
gifHeader = header;
this.data = data;
this.bitmapPool = bitmapPool;
this.firstFrame = firstFrame;
this.context = context.getApplicationContext();
this.frameTransformation = frameTransformation;
this.targetWidth = targetWidth;
this.targetHeight = targetHeight;
bitmapProvider = provider;
}
private void ensureGifDecoder() {
if (mGifDecoder != null) return;
ensureGifHeader();
GifDecoder.BitmapProvider provider = new GifBitmapProvider(
Glide.get(mContext).getBitmapPool(),
Glide.get(mContext).getArrayPool()
);
mGifDecoder = new StandardGifDecoder(provider);
mGifDecoder.setData(mGifHeader, getInputStreamData());
mGifFrames = mGifDecoder.getFrameCount() + 1;
}
public GifDecoder buildDecoder(GifDecoder.BitmapProvider bitmapProvider) {
return new GifDecoder(bitmapProvider);
}
/**
* Constructor for GifDrawable.
*
* @see #setFrameTransformation(Transformation, Bitmap)
*
* @param context A context.
* @param bitmapProvider An {@link GifDecoder.BitmapProvider} that can be used to
* retrieve re-usable {@link Bitmap}s.
* @param bitmapPool A {@link BitmapPool} that can be used to return
* the first frame when this drawable is recycled.
* @param frameTransformation An {@link Transformation} that can be applied to each frame.
* @param targetFrameWidth The desired width of the frames displayed by this drawable (the width of the view or
* {@link com.bumptech.glide.request.target.Target} this drawable is being loaded into).
* @param targetFrameHeight The desired height of the frames displayed by this drawable (the height of the view or
* {@link com.bumptech.glide.request.target.Target} this drawable is being loaded into).
* @param gifHeader The header data for this gif.
* @param data The full bytes of the gif.
* @param firstFrame The decoded and transformed first frame of this gif.
*/
public GifDrawable(Context context, GifDecoder.BitmapProvider bitmapProvider, BitmapPool bitmapPool,
Transformation<Bitmap> frameTransformation, int targetFrameWidth, int targetFrameHeight,
GifHeader gifHeader, byte[] data, Bitmap firstFrame) {
this(new GifState(gifHeader, data, context, frameTransformation, targetFrameWidth, targetFrameHeight,
bitmapProvider, bitmapPool, firstFrame));
}