简体   繁体   English

Android:如何使用 android 的 ImageDecoder 遍历 webp 帧

[英]Android : How to iterate through webp frames using android's ImageDecoder

I want to convert the animated webp into gif and I have gif encoder+decoder and webp ecnoder and it is working fine with gifs only.我想将动画 webp 转换为 gif,并且我有 gif 编码器+解码器和 webp ecnoder,它仅适用于 gif。 I want to process the animated webp as well so I need to decode the animated webp first and get bitamps for each frames.我也想处理动画 webp,所以我需要先解码动画 webp 并为每个帧获取 bitamps。 I could not get any animated webp decoder and later found that android.graphic has Image decoder which support animated webp image but it shown example for drawable and it has start() method for animated webp.我无法获得任何动画 webp 解码器,后来发现 android.graphic 具有支持动画 webp 图像的图像解码器,但它显示了可绘制的示例,并且它具有动画 webp 的 start() 方法。

How can I iterate through each frames to convert them into bitmap or some data type like byte[], base64, streams, etc so that i can convet that into bitmap.我如何遍历每个帧以将它们转换为 bitmap 或一些数据类型,如 byte[]、base64、流等,以便我可以将其转换为 bitmap。

 File file = new File(...);
  ImageDecoder.Source source = ImageDecoder.createSource(file);
  Drawable drawable = ImageDecoder.decodeDrawable(source);

As alternative for achieving same goal I have solved this by using Glide and APNG4 library along with some encoder decoder available on git.作为实现相同目标的替代方案,我通过使用 Glide 和 APNG4 库以及 git 上提供的一些编码器解码器解决了这个问题。

You can do both encode decode and and other stuff alone with APNG4.您可以使用 APNG4 单独进行编码解码和其他操作。

https://github.com/penfeizhou/APNG4Android https://github.com/penfeizhou/APNG4Android

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM