From 318cca556b0489aede0cd98d8d0c7f1408ab7bd6 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Sat, 29 Oct 2022 20:34:04 +0800 Subject: [PATCH] Fix the issue that progressive decode logic does not get updated --- SDWebImage/Core/SDImageLoader.m | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/SDWebImage/Core/SDImageLoader.m b/SDWebImage/Core/SDImageLoader.m index 77d30737..03143b0b 100644 --- a/SDWebImage/Core/SDImageLoader.m +++ b/SDWebImage/Core/SDImageLoader.m @@ -108,28 +108,9 @@ UIImage * _Nullable SDImageLoaderDecodeProgressiveImageData(NSData * _Nonnull im } else { cacheKey = imageURL.absoluteString; } + SDImageCoderOptions *coderOptions = SDGetDecodeOptionsFromContext(context, options, cacheKey); BOOL decodeFirstFrame = SD_OPTIONS_CONTAINS(options, SDWebImageDecodeFirstFrameOnly); - NSNumber *scaleValue = context[SDWebImageContextImageScaleFactor]; - CGFloat scale = scaleValue.doubleValue >= 1 ? scaleValue.doubleValue : SDImageScaleFactorForKey(cacheKey); - NSNumber *preserveAspectRatioValue = context[SDWebImageContextImagePreserveAspectRatio]; - NSValue *thumbnailSizeValue; - BOOL shouldScaleDown = SD_OPTIONS_CONTAINS(options, SDWebImageScaleDownLargeImages); - if (shouldScaleDown) { - CGFloat thumbnailPixels = SDImageCoderHelper.defaultScaleDownLimitBytes / 4; - CGFloat dimension = ceil(sqrt(thumbnailPixels)); - thumbnailSizeValue = @(CGSizeMake(dimension, dimension)); - } - if (context[SDWebImageContextImageThumbnailPixelSize]) { - thumbnailSizeValue = context[SDWebImageContextImageThumbnailPixelSize]; - } - - SDImageCoderMutableOptions *mutableCoderOptions = [NSMutableDictionary dictionaryWithCapacity:2]; - mutableCoderOptions[SDImageCoderDecodeFirstFrameOnly] = @(decodeFirstFrame); - mutableCoderOptions[SDImageCoderDecodeScaleFactor] = @(scale); - mutableCoderOptions[SDImageCoderDecodePreserveAspectRatio] = preserveAspectRatioValue; - mutableCoderOptions[SDImageCoderDecodeThumbnailPixelSize] = thumbnailSizeValue; - mutableCoderOptions[SDImageCoderWebImageContext] = context; - SDImageCoderOptions *coderOptions = [mutableCoderOptions copy]; + CGFloat scale = [coderOptions[SDImageCoderDecodeScaleFactor] doubleValue]; // Grab the progressive image coder id progressiveCoder = SDImageLoaderGetProgressiveCoder(operation);