From 894f061acc5d2cd2bccf29a55050ed67641d6d78 Mon Sep 17 00:00:00 2001 From: lizhuoli Date: Thu, 30 Sep 2021 17:37:17 +0800 Subject: [PATCH 1/2] Fix compile issue --- SDWebImage/Core/UIView+WebCache.m | 1 + 1 file changed, 1 insertion(+) diff --git a/SDWebImage/Core/UIView+WebCache.m b/SDWebImage/Core/UIView+WebCache.m index 11588502..35f10362 100644 --- a/SDWebImage/Core/UIView+WebCache.m +++ b/SDWebImage/Core/UIView+WebCache.m @@ -12,6 +12,7 @@ #import "SDWebImageError.h" #import "SDInternalMacros.h" #import "SDWebImageTransitionInternal.h" +#import "SDImageCache.h" const int64_t SDWebImageProgressUnitCountUnknown = 1LL; From 8a13cbb68c592dc345933f1ceee907a88afe797b Mon Sep 17 00:00:00 2001 From: lizhuoli Date: Thu, 30 Sep 2021 17:39:13 +0800 Subject: [PATCH 2/2] Fix the pixel ratio calculation for thumbnail decoding --- SDWebImage/Core/NSImage+Compatibility.m | 4 ++-- SDWebImage/Core/SDImageIOAnimatedCoder.m | 8 ++++---- SDWebImage/Core/SDImageIOCoder.m | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/SDWebImage/Core/NSImage+Compatibility.m b/SDWebImage/Core/NSImage+Compatibility.m index 7de0c703..ce67151e 100644 --- a/SDWebImage/Core/NSImage+Compatibility.m +++ b/SDWebImage/Core/NSImage+Compatibility.m @@ -35,8 +35,8 @@ NSImageRep *imageRep = [self bestRepresentationForRect:imageRect context:nil hints:nil]; CGFloat width = imageRep.size.width; CGFloat height = imageRep.size.height; - NSUInteger pixelWidth = imageRep.pixelsWide; - NSUInteger pixelHeight = imageRep.pixelsHigh; + CGFloat pixelWidth = (CGFloat)imageRep.pixelsWide; + CGFloat pixelHeight = (CGFloat)imageRep.pixelsHigh; if (width > 0 && height > 0) { CGFloat widthScale = pixelWidth / width; CGFloat heightScale = pixelHeight / height; diff --git a/SDWebImage/Core/SDImageIOAnimatedCoder.m b/SDWebImage/Core/SDImageIOAnimatedCoder.m index 837e59cd..d4d739ec 100644 --- a/SDWebImage/Core/SDImageIOAnimatedCoder.m +++ b/SDWebImage/Core/SDImageIOAnimatedCoder.m @@ -191,8 +191,8 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination // 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); - NSUInteger pixelWidth = [properties[(__bridge NSString *)kCGImagePropertyPixelWidth] unsignedIntegerValue]; - NSUInteger pixelHeight = [properties[(__bridge NSString *)kCGImagePropertyPixelHeight] unsignedIntegerValue]; + CGFloat pixelWidth = [properties[(__bridge NSString *)kCGImagePropertyPixelWidth] doubleValue]; + CGFloat pixelHeight = [properties[(__bridge NSString *)kCGImagePropertyPixelHeight] doubleValue]; CGImagePropertyOrientation exifOrientation = (CGImagePropertyOrientation)[properties[(__bridge NSString *)kCGImagePropertyOrientation] unsignedIntegerValue]; if (!exifOrientation) { exifOrientation = kCGImagePropertyOrientationUp; @@ -503,8 +503,8 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination maxPixelSize = maxPixelSizeValue.CGSizeValue; #endif } - NSUInteger pixelWidth = CGImageGetWidth(imageRef); - NSUInteger pixelHeight = CGImageGetHeight(imageRef); + CGFloat pixelWidth = (CGFloat)CGImageGetWidth(imageRef); + CGFloat pixelHeight = (CGFloat)CGImageGetHeight(imageRef); CGFloat finalPixelSize = 0; if (maxPixelSize.width > 0 && maxPixelSize.height > 0 && pixelWidth > maxPixelSize.width && pixelHeight > maxPixelSize.height) { CGFloat pixelRatio = pixelWidth / pixelHeight; diff --git a/SDWebImage/Core/SDImageIOCoder.m b/SDWebImage/Core/SDImageIOCoder.m index d858125d..8e1199f4 100644 --- a/SDWebImage/Core/SDImageIOCoder.m +++ b/SDWebImage/Core/SDImageIOCoder.m @@ -250,8 +250,8 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination maxPixelSize = maxPixelSizeValue.CGSizeValue; #endif } - NSUInteger pixelWidth = CGImageGetWidth(imageRef); - NSUInteger pixelHeight = CGImageGetHeight(imageRef); + CGFloat pixelWidth = (CGFloat)CGImageGetWidth(imageRef); + CGFloat pixelHeight = (CGFloat)CGImageGetHeight(imageRef); if (maxPixelSize.width > 0 && maxPixelSize.height > 0 && pixelWidth > maxPixelSize.width && pixelHeight > maxPixelSize.height) { CGFloat pixelRatio = pixelWidth / pixelHeight; CGFloat maxPixelSizeRatio = maxPixelSize.width / maxPixelSize.height;