com.bumptech.glide.load.resource.gif.GifFrameResourceDecoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of glide Show documentation
Show all versions of glide Show documentation
A fast and efficient image loading library for Android focused on smooth scrolling.
package com.bumptech.glide.load.resource.gif;
import android.graphics.Bitmap;
import com.bumptech.glide.gifdecoder.GifDecoder;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
/**
* Decodes {@link Bitmap}s from {@link GifDecoder}s representing a particular frame of a particular
* GIF image.
*/
public final class GifFrameResourceDecoder implements ResourceDecoder {
private final BitmapPool bitmapPool;
public GifFrameResourceDecoder(BitmapPool bitmapPool) {
this.bitmapPool = bitmapPool;
}
@Override
public boolean handles(GifDecoder source, Options options) {
return true;
}
@Override
public Resource decode(GifDecoder source, int width, int height, Options options) {
Bitmap bitmap = source.getNextFrame();
return BitmapResource.obtain(bitmap, bitmapPool);
}
}