Merge pull request #2725 from cntrump/master

fix issues: SDWebImageDecodeFirstFrameOnly flag is ignored when image loaded from cache
This commit is contained in:
DreamPiggy 2019-05-16 17:33:54 +08:00 committed by GitHub
commit daad5338e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -15,6 +15,7 @@
#import "SDImageCoderHelper.h" #import "SDImageCoderHelper.h"
#import "SDAnimatedImage.h" #import "SDAnimatedImage.h"
#import "UIImage+MemoryCacheCost.h" #import "UIImage+MemoryCacheCost.h"
#import "UIImage+Metadata.h"
@interface SDImageCache () @interface SDImageCache ()
@ -378,6 +379,15 @@
// First check the in-memory cache... // First check the in-memory cache...
UIImage *image = [self imageFromMemoryCacheForKey:key]; 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)); BOOL shouldQueryMemoryOnly = (image && !(options & SDImageCacheQueryMemoryData));
if (shouldQueryMemoryOnly) { if (shouldQueryMemoryOnly) {
if (doneBlock) { if (doneBlock) {