|
|
@@ -12,6 +12,7 @@
|
|
|
#import "SDImageCoderHelper.h"
|
|
|
#import "SDAnimatedImage.h"
|
|
|
#import "UIImage+Metadata.h"
|
|
|
+#import "SDInternalMacros.h"
|
|
|
#import "objc/runtime.h"
|
|
|
|
|
|
static void * SDImageLoaderProgressiveCoderKey = &SDImageLoaderProgressiveCoderKey;
|
|
|
@@ -28,7 +29,7 @@ UIImage * _Nullable SDImageLoaderDecodeImageData(NSData * _Nonnull imageData, NS
|
|
|
} else {
|
|
|
cacheKey = imageURL.absoluteString;
|
|
|
}
|
|
|
- BOOL decodeFirstFrame = options & SDWebImageDecodeFirstFrameOnly;
|
|
|
+ BOOL decodeFirstFrame = SD_OPTIONS_CONTAINS(options, SDWebImageDecodeFirstFrameOnly);
|
|
|
NSNumber *scaleValue = context[SDWebImageContextImageScaleFactor];
|
|
|
CGFloat scale = scaleValue.doubleValue >= 1 ? scaleValue.doubleValue : SDImageScaleFactorForKey(cacheKey);
|
|
|
SDImageCoderOptions *coderOptions = @{SDImageCoderDecodeFirstFrameOnly : @(decodeFirstFrame), SDImageCoderDecodeScaleFactor : @(scale)};
|
|
|
@@ -60,8 +61,8 @@ UIImage * _Nullable SDImageLoaderDecodeImageData(NSData * _Nonnull imageData, NS
|
|
|
image = [[SDImageCodersManager sharedManager] decodedImageWithData:imageData options:coderOptions];
|
|
|
}
|
|
|
if (image) {
|
|
|
- BOOL shouldDecode = (options & SDWebImageAvoidDecodeImage) == 0;
|
|
|
- if ([image conformsToProtocol:@protocol(SDAnimatedImage)]) {
|
|
|
+ BOOL shouldDecode = !SD_OPTIONS_CONTAINS(options, SDWebImageAvoidDecodeImage);
|
|
|
+ if ([image.class conformsToProtocol:@protocol(SDAnimatedImage)]) {
|
|
|
// `SDAnimatedImage` do not decode
|
|
|
shouldDecode = NO;
|
|
|
} else if (image.sd_isAnimated) {
|
|
|
@@ -70,7 +71,7 @@ UIImage * _Nullable SDImageLoaderDecodeImageData(NSData * _Nonnull imageData, NS
|
|
|
}
|
|
|
|
|
|
if (shouldDecode) {
|
|
|
- BOOL shouldScaleDown = options & SDWebImageScaleDownLargeImages;
|
|
|
+ BOOL shouldScaleDown = SD_OPTIONS_CONTAINS(options, SDWebImageScaleDownLargeImages);
|
|
|
if (shouldScaleDown) {
|
|
|
image = [SDImageCoderHelper decodedAndScaledDownImageWithImage:image limitBytes:0];
|
|
|
} else {
|
|
|
@@ -95,7 +96,7 @@ UIImage * _Nullable SDImageLoaderDecodeProgressiveImageData(NSData * _Nonnull im
|
|
|
} else {
|
|
|
cacheKey = imageURL.absoluteString;
|
|
|
}
|
|
|
- BOOL decodeFirstFrame = options & SDWebImageDecodeFirstFrameOnly;
|
|
|
+ BOOL decodeFirstFrame = SD_OPTIONS_CONTAINS(options, SDWebImageDecodeFirstFrameOnly);
|
|
|
NSNumber *scaleValue = context[SDWebImageContextImageScaleFactor];
|
|
|
CGFloat scale = scaleValue.doubleValue >= 1 ? scaleValue.doubleValue : SDImageScaleFactorForKey(cacheKey);
|
|
|
SDImageCoderOptions *coderOptions = @{SDImageCoderDecodeFirstFrameOnly : @(decodeFirstFrame), SDImageCoderDecodeScaleFactor : @(scale)};
|
|
|
@@ -142,8 +143,8 @@ UIImage * _Nullable SDImageLoaderDecodeProgressiveImageData(NSData * _Nonnull im
|
|
|
image = [progressiveCoder incrementalDecodedImageWithOptions:coderOptions];
|
|
|
}
|
|
|
if (image) {
|
|
|
- BOOL shouldDecode = (options & SDWebImageAvoidDecodeImage) == 0;
|
|
|
- if ([image conformsToProtocol:@protocol(SDAnimatedImage)]) {
|
|
|
+ BOOL shouldDecode = !SD_OPTIONS_CONTAINS(options, SDWebImageAvoidDecodeImage);
|
|
|
+ if ([image.class conformsToProtocol:@protocol(SDAnimatedImage)]) {
|
|
|
// `SDAnimatedImage` do not decode
|
|
|
shouldDecode = NO;
|
|
|
} else if (image.sd_isAnimated) {
|