From bc2b52007cf41d09a4565f74fe98227db2d027f5 Mon Sep 17 00:00:00 2001 From: vvveiii Date: Thu, 16 May 2019 16:41:23 +0800 Subject: [PATCH] fix issues: SDWebImageDecodeFirstFrameOnly flag is ignored when image loaded from cache. --- SDWebImage/SDImageCache.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/SDWebImage/SDImageCache.m b/SDWebImage/SDImageCache.m index 10506e82..75be7b41 100644 --- a/SDWebImage/SDImageCache.m +++ b/SDWebImage/SDImageCache.m @@ -15,6 +15,7 @@ #import "SDImageCoderHelper.h" #import "SDAnimatedImage.h" #import "UIImage+MemoryCacheCost.h" +#import "UIImage+Metadata.h" @interface SDImageCache () @@ -378,6 +379,15 @@ // First check the in-memory cache... UIImage *image = [self imageFromMemoryCacheForKey:key]; + + if ((options & SDImageCacheDecodeFirstFrameOnly) && image.sd_isAnimated) { +#if SD_MAC + image = [[NSImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:kCGImagePropertyOrientationUp]; +#else + image = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:image.imageOrientation]; +#endif + } + BOOL shouldQueryMemoryOnly = (image && !(options & SDImageCacheQueryMemoryData)); if (shouldQueryMemoryOnly) { if (doneBlock) {