From ae4aa3f848185be1ae6af9025aa1adbb79b46b20 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Sun, 5 Jan 2020 20:39:44 +0800 Subject: [PATCH] Fix the animated image for sd_imageFormat --- SDWebImage/Core/SDImageIOAnimatedCoder.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/SDWebImage/Core/SDImageIOAnimatedCoder.m b/SDWebImage/Core/SDImageIOAnimatedCoder.m index 7451a712..eaa42688 100644 --- a/SDWebImage/Core/SDImageIOAnimatedCoder.m +++ b/SDWebImage/Core/SDImageIOAnimatedCoder.m @@ -499,12 +499,16 @@ - (UIImage *)animatedImageFrameAtIndex:(NSUInteger)index { UIImage *image = [self.class createFrameAtIndex:index source:_imageSource scale:_scale preserveAspectRatio:_preserveAspectRatio thumbnailSize:_thumbnailSize]; + if (!image) { + return nil; + } // Image/IO create CGImage does not decode, so we do this because this is called background queue, this can avoid main queue block when rendering(especially when one more imageViews use the same image instance) UIImage *decodedImage = [SDImageCoderHelper decodedImageWithImage:image]; - if (!decodedImage) { - return image; + if (decodedImage) { + image = decodedImage; } - return decodedImage; + image.sd_imageFormat = self.class.imageFormat; + return image; } @end