Closed zubinxiong closed 1 year ago
Try changing from WebPConfig.COMPRESSION_LOSSY
to WebPConfig.COMPRESSION_LOSSLESS
Dispose is an internally determined parameter by the encoder. See WEBP container specification for more information https://developers.google.com/speed/webp/docs/riff_container#animation
Save the returned bitmaps and verifying them for any distortions or use different gif decoder like Glide. https://github.com/bumptech/glide
val target = Glide.with(context)
.asGif()
.load(srcUri)
.submit()
val drawable = target.get()
val gifState = drawable.constantState ?: throw NullPointerException("GifState is null")
val frameLoaderField = gifState.javaClass.getDeclaredField("frameLoader")
frameLoaderField.isAccessible = true
val frameLoader = frameLoaderField[gifState]
val decoderField = frameLoader.javaClass.getDeclaredField("gifDecoder")
decoderField.isAccessible = true
val gifDecoder = decoderField[frameLoader] as StandardGifDecoder
for (i in 0 until gifDecoder.frameCount) {
gifDecoder.advance()
val bitmap = gifDecoder.nextFrame
}
originGif
library convert webp in whatsapp https://github.com/UdaraWanasinghe/webp-android/assets/7650970/71743d96-b912-4fa0-a318-f9b2344397ab