From d2221403e10fb9c6d8f10141db98aaaaf1f88679 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Tue, 27 Dec 2022 19:55:12 +0800 Subject: [PATCH] Removed the unused options for CGImageSourceCopyPropertiesAtIndex --- SDWebImage/Core/SDImageIOAnimatedCoder.m | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/SDWebImage/Core/SDImageIOAnimatedCoder.m b/SDWebImage/Core/SDImageIOAnimatedCoder.m index d8813ab8..49bdc422 100644 --- a/SDWebImage/Core/SDImageIOAnimatedCoder.m +++ b/SDWebImage/Core/SDImageIOAnimatedCoder.m @@ -183,12 +183,8 @@ static CGImageRef __nullable SDCGImageCreateCopy(CGImageRef cg_nullable image) { } + (NSTimeInterval)frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source { - NSDictionary *options = @{ - (__bridge NSString *)kCGImageSourceShouldCacheImmediately : @(YES), - (__bridge NSString *)kCGImageSourceShouldCache : @(YES) // Always cache to reduce CPU usage - }; NSTimeInterval frameDuration = 0.1; - CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, (__bridge CFDictionaryRef)options); + CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, NULL); if (!cfFrameProperties) { return frameDuration; } @@ -234,9 +230,8 @@ static CGImageRef __nullable SDCGImageCreateCopy(CGImageRef cg_nullable image) { }; } } - // Some options need to pass to `CGImageSourceCopyPropertiesAtIndex` before `CGImageSourceCreateImageAtIndex`, or ImageIO will ignore them because they parse once :) // Parse the image properties - NSDictionary *properties = (__bridge_transfer NSDictionary *)CGImageSourceCopyPropertiesAtIndex(source, index, (__bridge CFDictionaryRef)options); + NSDictionary *properties = (__bridge_transfer NSDictionary *)CGImageSourceCopyPropertiesAtIndex(source, index, NULL); CGFloat pixelWidth = [properties[(__bridge NSString *)kCGImagePropertyPixelWidth] doubleValue]; CGFloat pixelHeight = [properties[(__bridge NSString *)kCGImagePropertyPixelHeight] doubleValue]; CGImagePropertyOrientation exifOrientation = (CGImagePropertyOrientation)[properties[(__bridge NSString *)kCGImagePropertyOrientation] unsignedIntegerValue]; @@ -515,11 +510,7 @@ static CGImageRef __nullable SDCGImageCreateCopy(CGImageRef cg_nullable image) { CGImageSourceUpdateData(_imageSource, (__bridge CFDataRef)data, finished); if (_width + _height == 0) { - NSDictionary *options = @{ - (__bridge NSString *)kCGImageSourceShouldCacheImmediately : @(YES), - (__bridge NSString *)kCGImageSourceShouldCache : @(YES) // Always cache to reduce CPU usage - }; - CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(_imageSource, 0, (__bridge CFDictionaryRef)options); + CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(_imageSource, 0, NULL); if (properties) { CFTypeRef val = CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight); if (val) CFNumberGetValue(val, kCFNumberLongType, &_height);