New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Animated WebP Image not showing correctly using UIImageView or FLAnimatedImageView #1951
Comments
By reading the decoder from YYImage and SDWebImage , I found that for single frame animated WebP, the libwebp's Looks at this animated webp image (actual size is 100x100), but the rendered animated images array (via none blend mode) used for |
The YYImageCoder code reference :YYImage |
There is an simple fix(which first create UIImage through CGImageCreate from WebPData. Then draw this UIImage to an new CGBitmapContext with actual size(not just the canvas size). The simple fix fork is here: SDWebImage Consider a higher performance(because create CGBitmapContext waste extra time), maybe we can modify the RGBA vector transform to do these. I found that YYImage use the |
Also, I found that the animated WebP dipose method(see here) is not support, currently is assume that all frames use the background disposal. By sharing a blend canvas while decoding multiple frame animated webp image, we could do disposal and blend correctly(not relay on that last image). |
PR is here: #1952 |
Because NSArray<UIImage *> *)images;
NSUInteger count = images.count;
int durations[count];
int const gcd = gcdArray(count, durations);
NSMutableArray<UIImage *> *animatedImages = [NSMutableArray arrayWithCapacity:count];
[images enumerateObjectsUsingBlock:^(UIImage * _Nonnull image, NSUInteger idx, BOOL * _Nonnull stop) {
int duration = durations[idx];
int repeatCount = duration / gcd;
for (int i = 0; i < repeatCount; ++i) {
[animatedImages addObject:image];
}
}]; |
#1951: Fix animated WebP decoding issue, including canvas size, the support for dispose method and the duration per frame
Fixed by #1952 |
New Issue Checklist
Issue Info
Issue Description and Steps
Description:
SDWebImage 4.0 add support to animated WebP. But when downloading and showing some of animated WebP using SDWebImage API(eg.
sd_setImageWithURL:
) toUIImageView
orFLAnimatedImageView
instance, the imageview can't render correctly.Comparing to another animated WebP library (YYImage), it seems that the decoder for WebP to get per frame images works wrong.
Also, current implementation does not support WebP disposal method, which cause many animated WebP images look strange. And due to UIImage's API, the
duration
parameter just use the average duration for each frame, which is different from the animated WebP standard which allows set different duration per frame and also cause some images look strange.For more detail and intuitive effect, you can go to the demo project to build and run.
Step:
FLAnimatedImageView
orUIImageView
instance and usesd_setImageWithURL:
API to set image.The text was updated successfully, but these errors were encountered: