blob: fb056d43a55eca9420dccf0a7549eea07381e344 [file] [log] [blame]
package com.bumptech.glide.load.resource.bitmap;
import android.graphics.Bitmap;
import android.os.ParcelFileDescriptor;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.io.IOException;
public class FileDescriptorBitmapDecoder implements ResourceDecoder<ParcelFileDescriptor, Bitmap> {
private final VideoBitmapDecoder bitmapDecoder;
private final BitmapPool bitmapPool;
private DecodeFormat decodeFormat;
public FileDescriptorBitmapDecoder(BitmapPool bitmapPool) {
this(new VideoBitmapDecoder(), bitmapPool, DecodeFormat.ALWAYS_ARGB_8888);
}
public FileDescriptorBitmapDecoder(VideoBitmapDecoder bitmapDecoder, BitmapPool bitmapPool,
DecodeFormat decodeFormat) {
this.bitmapDecoder = bitmapDecoder;
this.bitmapPool = bitmapPool;
this.decodeFormat = decodeFormat;
}
@Override
public Resource<Bitmap> decode(ParcelFileDescriptor source, int width, int height) throws IOException {
Bitmap bitmap = bitmapDecoder.decode(source, bitmapPool, width, height, decodeFormat);
if (bitmap == null) {
return null;
} else {
return new BitmapResource(bitmap, bitmapPool);
}
}
@Override
public String getId() {
return "FileDescriptorBitmapDecoder.com.bumptech.glide.load.data.bitmap";
}
}