Closed zhi936689039 closed 1 year ago
我这块的代码是: var gifStreamLoader = FileLoader(file?.absolutePath) var webPEncoder = WebPEncoder.fromGif(gifStreamLoader)
//
ThreadUtils.getSinglePool().execute{
var fos = BufferedOutputStream(FileOutputStream(GifDownloadSaveUtil.getFileName(this@MainActivity,"test.webp")))
var bytes = webPEncoder.build()
fos.write(bytes)
fos.close()
}
这是https://res.naadi.microparty.com/user/1688545363899.gif gif的地址
可以参考EncoderTestActivity这里的源码,链接如下https://github.com/penfeizhou/APNG4Android/blob/master/app/src/main/java/com/github/penfeizhou/animation/demo/EncoderTestActivity.java
这是来自QQ邮箱的假期自动回复邮件。 您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
我在此基础上稍作修改使用了你的gif:
new Thread(new Runnable() {
@Override
public void run() {
final byte[] ret = WebPEncoder.fromDecoder(
GifDrawable.fromAsset(EncoderTestActivity.this,
"1688545363899.gif").getFrameSeqDecoder()).build();
imageView.post(new Runnable() {
@Override
public void run() {
Glide.with(imageView)
.load(ret)
.into(imageView);
}
});
}
}).start()
看起来好像不闪?
建议你先进行本地下载缓存,后以本地路径进行转换操作
好,我试试
那这个也可以通过png转webp嘛
--!不行,兄弟, ThreadUtils.getSinglePool().execute{ val ret = WebPEncoder.fromDecoder( APNGDrawable.fromFile(file?.absolutePath).frameSeqDecoder ).build() ThreadUtils.runOnUiThread{ // var fos = BufferedOutputStream(FileOutputStream(GifDownloadSaveUtil.getFileName(this@MainActivity,"test.webp"))) // fos.write(ret) // fos.close() iv_pic?.let { Glide.with(this@MainActivity).load(ret).into(it) } } }
emm..好像我的用法有问题
这是来自QQ邮箱的假期自动回复邮件。 您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
New Issue Checklist
Issue Info
Issue Description and Steps
Please fill in the detailed description of the issue (full output of any stack trace, compiler error, ...) and the steps to reproduce the issue.