penfeizhou / APNG4Android

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

Previous frames do not remove in WebpEncoder #159

Closed KishorJena closed 2 years ago

KishorJena commented 2 years ago

New Issue Checklist

Issue Info

Info Value
Device Info Redmi Note 7 Pro
System Version 10
APNG4Android Library Version 2.23.0
Repro rate all the time (100%)
Repro with our demo project -
Demo project link -

Issue Description and Steps

All previous frames stays there new frames are drawn over those frames.

    WebPEncoder encoder = new WebPEncoder();

    for(Bitmap bitmap:bitmaps)  {
       ...
      encoder.addFrame(final_Bitmap, 0,0,delay);
    }

    final byte[] bytes = encoder.build();
KishorJena commented 2 years ago

Ok found solution.
I'm not well in java so it took time to understand the codes and after experimenting I found the way. I set disposal and blending as true. As suggested in two issues in this repo.

Ref: https://github.com/penfeizhou/APNG4Android/blob/7b9c5e6b5ee0b9d2ac8b488711916e94c51a06d7/awebpencoder/src/main/java/com/github/penfeizhou/animation/awebpencoder/WebPEncoder.java#L307

https://github.com/penfeizhou/APNG4Android/blob/7b9c5e6b5ee0b9d2ac8b488711916e94c51a06d7/awebpencoder/src/main/java/com/github/penfeizhou/animation/awebpencoder/WebPEncoder.java#L163

https://github.com/penfeizhou/APNG4Android/blob/7b9c5e6b5ee0b9d2ac8b488711916e94c51a06d7/awebpencoder/src/main/java/com/github/penfeizhou/animation/awebpencoder/WebPEncoder.java#L143

KishorJena commented 2 years ago

This is great library. Now one thing remain is decoding and getting frames but unfortunately I am stuck there. Luckily there are two libraries which are doing decoding but I want to use this library to for decoding gif and awebp.