Fresco: Animated GIF Bitmap null on ImagePipeline

Created on 8 May 2015  路  5Comments  路  Source: facebook/fresco

I can't get the bitmap on ImagePipeline with animated gif image.
and also on Postprocessor.
It returns null.

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.

All 5 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cococool picture cococool  路  4Comments

eldk picture eldk  路  3Comments

stevenmtang picture stevenmtang  路  3Comments

hanhmh1203 picture hanhmh1203  路  4Comments

zewenwang picture zewenwang  路  4Comments