androidimage-processingbitmapwebpfresco

How to get all bitmaps from animated webp using android fresco?


How to get a list of all bitmaps from webp animation using android fresco?

The code below is always returns null instead of a bitmap

        val imageRequest = ImageRequestBuilder
            .newBuilderWithSource(Uri.parse("https://upload.wikimedia.org/wikipedia/commons/4/41/Sunflower_from_Silesia2.jpg"))
            .build()
        val imagePipeline = Fresco.getImagePipeline()
        val dataSource = imagePipeline.fetchDecodedImage(imageRequest, this)
        dataSource.subscribe(object : BaseBitmapDataSubscriber() {
            override fun onFailureImpl(dataSource: DataSource<CloseableReference<CloseableImage>>?) {
                val m = dataSource
            }

            override fun onNewResultImpl(bitmap: Bitmap?) {
                val m = bitmap
            }
        }, CallerThreadExecutor.getInstance())

Solution

  • For all interested, fresco docs has this line "This subscriber doesn’t work for animated images as those can not be represented as a single bitmap."