penfeizhou / APNG4Android

Android animation support for APNG & Animated WebP & Gif & Animated AVIF, High performance
Apache License 2.0
570 stars 75 forks source link

调用WebPEncoder.fromGif实现gif转webp,webp出现闪的问题 #191

Closed zhi936689039 closed 1 year ago

zhi936689039 commented 1 year ago

New Issue Checklist

Issue Info

Info Value
Device Info e.g. Huawei Mate 30 pro
System Version e.g. 6.0
APNG4Android Library Version e.g. 1.0.0
Repro rate e.g. all the time (100%) / sometimes x% / only once
Repro with our demo project e.g. does it happen with our demo project?
Demo project link e.g. link to a demo project that highlights the issue

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.

zhi936689039 commented 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()
                }
zhi936689039 commented 1 year ago

这是https://res.naadi.microparty.com/user/1688545363899.gif gif的地址

jingpeng commented 1 year ago

可以参考EncoderTestActivity这里的源码,链接如下https://github.com/penfeizhou/APNG4Android/blob/master/app/src/main/java/com/github/penfeizhou/animation/demo/EncoderTestActivity.java

zhi936689039 commented 1 year ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

jingpeng commented 1 year ago

我在此基础上稍作修改使用了你的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()
jingpeng commented 1 year ago

https://github.com/penfeizhou/APNG4Android/assets/5223226/fcafe28d-2359-431e-95dd-0fbf927e965f

jingpeng commented 1 year ago

看起来好像不闪?

jingpeng commented 1 year ago

建议你先进行本地下载缓存,后以本地路径进行转换操作

zhi936689039 commented 1 year ago

好,我试试

zhi936689039 commented 1 year ago

那这个也可以通过png转webp嘛

zhi936689039 commented 1 year ago

--!不行,兄弟, 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) } } }

zhi936689039 commented 1 year ago

emm..好像我的用法有问题

zhi936689039 commented 1 year ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。