I can't get the bitmap on ImagePipeline with animated gif image.
and also on Postprocessor.
It returns null.
Can you share a code snippet?
ImageRequest request = ImageRequestBuilder
.newBuilderWithSource(uri)
.build();
ImagePipeline imagePipeline = Fresco.getImagePipeline();
DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(request, null);
dataSource.subscribe(new BaseBitmapDataSubscriber() {
@Override
protected void onNewResultImpl(@Nullable Bitmap bitmap) {
if (bitmap == null) {
log.e(TAG, "bitmap null");
}
}
@Override
protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
}
}, CallerThreadExecutor.getInstance());
Postprocessor processor = new BasePostprocessor() {
@Override
public CloseableReference<Bitmap> process(Bitmap src, PlatformBitmapFactory bitmapFactory) {
int w = src.getWidth();
int h = src.getHeight();
CloseableReference<Bitmap> ref = bitmapFactory.createBitmap(w, h);
try {
Bitmap dest = ref.get();
// crop process
return CloseableReference.cloneOrNull(ref);
} finally {
CloseableReference.closeSafely(ref);
}
}
@Override
public String getName() {
return "crop_processor";
}
};
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
.setPostprocessor(processor)
.build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.build();
In that case, preprocessor does not processed at all.
All other images works fine but only animated GIFs have this problem.
We don't support postprocessing for animated images: http://frescolib.org/docs/modifying-image.html#things-to-know
You also can't use BaseBitmapDataSubscriber for an animation. Use BaseDataSubscriber instead.
@tyronen I'm using the BaseDataSubscriber to get the bitmap(which means the first frame of a gif),But what i get is just CloseableAnimatedImage, I don't know how to get the bitmap of it.
Most helpful comment
@tyronen I'm using the BaseDataSubscriber to get the bitmap(which means the first frame of a gif),But what i get is just CloseableAnimatedImage, I don't know how to get the bitmap of it.