Replace if judge with MAX() function in scale less 1
This commit is contained in:
parent
83997ca9e4
commit
806e228867
|
@ -146,17 +146,14 @@ static CGFloat SDImageScaleFromPath(NSString *string) {
|
||||||
if (!animatedCoder) {
|
if (!animatedCoder) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
if (scale <= 0) {
|
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
UIImage *image = [animatedCoder animatedImageFrameAtIndex:0];
|
UIImage *image = [animatedCoder animatedImageFrameAtIndex:0];
|
||||||
if (!image) {
|
if (!image) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
#if SD_MAC
|
#if SD_MAC
|
||||||
self = [super initWithCGImage:image.CGImage scale:scale orientation:kCGImagePropertyOrientationUp];
|
self = [super initWithCGImage:image.CGImage scale:MAX(scale, 1) orientation:kCGImagePropertyOrientationUp];
|
||||||
#else
|
#else
|
||||||
self = [super initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation];
|
self = [super initWithCGImage:image.CGImage scale:MAX(scale, 1) orientation:image.imageOrientation];
|
||||||
#endif
|
#endif
|
||||||
if (self) {
|
if (self) {
|
||||||
_coder = animatedCoder;
|
_coder = animatedCoder;
|
||||||
|
|
|
@ -83,10 +83,7 @@ const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef
|
||||||
CGFloat scale = 1;
|
CGFloat scale = 1;
|
||||||
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
||||||
if (scaleFactor != nil) {
|
if (scaleFactor != nil) {
|
||||||
scale = [scaleFactor doubleValue];
|
scale = MAX([scaleFactor doubleValue], 1);
|
||||||
if (scale < 1) {
|
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SD_MAC
|
#if SD_MAC
|
||||||
|
@ -252,10 +249,7 @@ const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef
|
||||||
CGFloat scale = 1;
|
CGFloat scale = 1;
|
||||||
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
||||||
if (scaleFactor != nil) {
|
if (scaleFactor != nil) {
|
||||||
scale = [scaleFactor doubleValue];
|
scale = MAX([scaleFactor doubleValue], 1);
|
||||||
if (scale < 1) {
|
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_scale = scale;
|
_scale = scale;
|
||||||
#if SD_UIKIT
|
#if SD_UIKIT
|
||||||
|
@ -304,10 +298,7 @@ const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef
|
||||||
CGFloat scale = _scale;
|
CGFloat scale = _scale;
|
||||||
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
||||||
if (scaleFactor != nil) {
|
if (scaleFactor != nil) {
|
||||||
scale = [scaleFactor doubleValue];
|
scale = MAX([scaleFactor doubleValue], 1);
|
||||||
if (scale < 1) {
|
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#if SD_UIKIT || SD_WATCH
|
#if SD_UIKIT || SD_WATCH
|
||||||
image = [[UIImage alloc] initWithCGImage:partialImageRef scale:scale orientation:UIImageOrientationUp];
|
image = [[UIImage alloc] initWithCGImage:partialImageRef scale:scale orientation:UIImageOrientationUp];
|
||||||
|
@ -341,10 +332,7 @@ const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef
|
||||||
CGFloat scale = 1;
|
CGFloat scale = 1;
|
||||||
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
||||||
if (scaleFactor != nil) {
|
if (scaleFactor != nil) {
|
||||||
scale = [scaleFactor doubleValue];
|
scale = MAX([scaleFactor doubleValue], 1);
|
||||||
if (scale < 1) {
|
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_scale = scale;
|
_scale = scale;
|
||||||
_imageSource = imageSource;
|
_imageSource = imageSource;
|
||||||
|
|
|
@ -17,10 +17,7 @@ UIImage * _Nullable SDImageCacheDecodeImageData(NSData * _Nonnull imageData, NSS
|
||||||
BOOL decodeFirstFrame = options & SDWebImageDecodeFirstFrameOnly;
|
BOOL decodeFirstFrame = options & SDWebImageDecodeFirstFrameOnly;
|
||||||
NSNumber *scaleValue = context[SDWebImageContextImageScaleFactor];
|
NSNumber *scaleValue = context[SDWebImageContextImageScaleFactor];
|
||||||
CGFloat scale = scaleValue.doubleValue >= 1 ? scaleValue.doubleValue : SDImageScaleFactorForKey(cacheKey);
|
CGFloat scale = scaleValue.doubleValue >= 1 ? scaleValue.doubleValue : SDImageScaleFactorForKey(cacheKey);
|
||||||
if (scale < 1) {
|
SDImageCoderOptions *coderOptions = @{SDImageCoderDecodeFirstFrameOnly : @(decodeFirstFrame), SDImageCoderDecodeScaleFactor : @(MAX(scale, 1))};
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
SDImageCoderOptions *coderOptions = @{SDImageCoderDecodeFirstFrameOnly : @(decodeFirstFrame), SDImageCoderDecodeScaleFactor : @(scale)};
|
|
||||||
if (context) {
|
if (context) {
|
||||||
SDImageCoderMutableOptions *mutableCoderOptions = [coderOptions mutableCopy];
|
SDImageCoderMutableOptions *mutableCoderOptions = [coderOptions mutableCopy];
|
||||||
[mutableCoderOptions setValue:context forKey:SDImageCoderWebImageContext];
|
[mutableCoderOptions setValue:context forKey:SDImageCoderWebImageContext];
|
||||||
|
|
|
@ -104,10 +104,8 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
CFRelease(imageDestination);
|
CFRelease(imageDestination);
|
||||||
CGFloat scale = frames.firstObject.image.scale;
|
CGFloat scale = MAX(frames.firstObject.image.scale, 1);
|
||||||
if (scale < 1) {
|
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
SDAnimatedImageRep *imageRep = [[SDAnimatedImageRep alloc] initWithData:imageData];
|
SDAnimatedImageRep *imageRep = [[SDAnimatedImageRep alloc] initWithData:imageData];
|
||||||
NSSize size = NSMakeSize(imageRep.pixelsWide / scale, imageRep.pixelsHigh / scale);
|
NSSize size = NSMakeSize(imageRep.pixelsWide / scale, imageRep.pixelsHigh / scale);
|
||||||
imageRep.size = size;
|
imageRep.size = size;
|
||||||
|
|
|
@ -76,10 +76,7 @@
|
||||||
CGFloat scale = 1;
|
CGFloat scale = 1;
|
||||||
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
||||||
if (scaleFactor != nil) {
|
if (scaleFactor != nil) {
|
||||||
scale = [scaleFactor doubleValue];
|
scale = MAX([scaleFactor doubleValue], 1);
|
||||||
if (scale < 1) {
|
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SD_MAC
|
#if SD_MAC
|
||||||
|
@ -189,10 +186,7 @@
|
||||||
CGFloat scale = 1;
|
CGFloat scale = 1;
|
||||||
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
||||||
if (scaleFactor != nil) {
|
if (scaleFactor != nil) {
|
||||||
scale = [scaleFactor doubleValue];
|
scale = MAX([scaleFactor doubleValue], 1);
|
||||||
if (scale < 1) {
|
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_scale = scale;
|
_scale = scale;
|
||||||
#if SD_UIKIT
|
#if SD_UIKIT
|
||||||
|
@ -241,10 +235,7 @@
|
||||||
CGFloat scale = _scale;
|
CGFloat scale = _scale;
|
||||||
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
||||||
if (scaleFactor != nil) {
|
if (scaleFactor != nil) {
|
||||||
scale = [scaleFactor doubleValue];
|
scale = MAX([scaleFactor doubleValue], 1);
|
||||||
if (scale < 1) {
|
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#if SD_UIKIT || SD_WATCH
|
#if SD_UIKIT || SD_WATCH
|
||||||
image = [[UIImage alloc] initWithCGImage:partialImageRef scale:scale orientation:UIImageOrientationUp];
|
image = [[UIImage alloc] initWithCGImage:partialImageRef scale:scale orientation:UIImageOrientationUp];
|
||||||
|
@ -339,10 +330,7 @@
|
||||||
CGFloat scale = 1;
|
CGFloat scale = 1;
|
||||||
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
||||||
if (scaleFactor != nil) {
|
if (scaleFactor != nil) {
|
||||||
scale = [scaleFactor doubleValue];
|
scale = MAX([scaleFactor doubleValue], 1);
|
||||||
if (scale < 1) {
|
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_scale = scale;
|
_scale = scale;
|
||||||
_imageSource = imageSource;
|
_imageSource = imageSource;
|
||||||
|
|
|
@ -70,10 +70,7 @@
|
||||||
CGFloat scale = 1;
|
CGFloat scale = 1;
|
||||||
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
||||||
if (scaleFactor != nil) {
|
if (scaleFactor != nil) {
|
||||||
scale = [scaleFactor doubleValue];
|
scale = MAX([scaleFactor doubleValue], 1) ;
|
||||||
if (scale < 1) {
|
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UIImage *image = [[UIImage alloc] initWithData:data scale:scale];
|
UIImage *image = [[UIImage alloc] initWithData:data scale:scale];
|
||||||
|
@ -94,10 +91,7 @@
|
||||||
CGFloat scale = 1;
|
CGFloat scale = 1;
|
||||||
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
||||||
if (scaleFactor != nil) {
|
if (scaleFactor != nil) {
|
||||||
scale = [scaleFactor doubleValue];
|
scale = MAX([scaleFactor doubleValue], 1);
|
||||||
if (scale < 1) {
|
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_scale = scale;
|
_scale = scale;
|
||||||
#if SD_UIKIT
|
#if SD_UIKIT
|
||||||
|
@ -151,10 +145,7 @@
|
||||||
CGFloat scale = _scale;
|
CGFloat scale = _scale;
|
||||||
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
|
||||||
if (scaleFactor != nil) {
|
if (scaleFactor != nil) {
|
||||||
scale = [scaleFactor doubleValue];
|
scale = MAX([scaleFactor doubleValue], 1);
|
||||||
if (scale < 1) {
|
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#if SD_UIKIT || SD_WATCH
|
#if SD_UIKIT || SD_WATCH
|
||||||
UIImageOrientation imageOrientation = [SDImageCoderHelper imageOrientationFromEXIFOrientation:_orientation];
|
UIImageOrientation imageOrientation = [SDImageCoderHelper imageOrientationFromEXIFOrientation:_orientation];
|
||||||
|
|
|
@ -31,10 +31,7 @@ UIImage * _Nullable SDImageLoaderDecodeImageData(NSData * _Nonnull imageData, NS
|
||||||
BOOL decodeFirstFrame = options & SDWebImageDecodeFirstFrameOnly;
|
BOOL decodeFirstFrame = options & SDWebImageDecodeFirstFrameOnly;
|
||||||
NSNumber *scaleValue = context[SDWebImageContextImageScaleFactor];
|
NSNumber *scaleValue = context[SDWebImageContextImageScaleFactor];
|
||||||
CGFloat scale = scaleValue.doubleValue >= 1 ? scaleValue.doubleValue : SDImageScaleFactorForKey(cacheKey);
|
CGFloat scale = scaleValue.doubleValue >= 1 ? scaleValue.doubleValue : SDImageScaleFactorForKey(cacheKey);
|
||||||
if (scale < 1) {
|
SDImageCoderOptions *coderOptions = @{SDImageCoderDecodeFirstFrameOnly : @(decodeFirstFrame), SDImageCoderDecodeScaleFactor : @(MAX(scale, 1))};
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
SDImageCoderOptions *coderOptions = @{SDImageCoderDecodeFirstFrameOnly : @(decodeFirstFrame), SDImageCoderDecodeScaleFactor : @(scale)};
|
|
||||||
if (context) {
|
if (context) {
|
||||||
SDImageCoderMutableOptions *mutableCoderOptions = [coderOptions mutableCopy];
|
SDImageCoderMutableOptions *mutableCoderOptions = [coderOptions mutableCopy];
|
||||||
[mutableCoderOptions setValue:context forKey:SDImageCoderWebImageContext];
|
[mutableCoderOptions setValue:context forKey:SDImageCoderWebImageContext];
|
||||||
|
@ -93,10 +90,7 @@ UIImage * _Nullable SDImageLoaderDecodeProgressiveImageData(NSData * _Nonnull im
|
||||||
BOOL decodeFirstFrame = options & SDWebImageDecodeFirstFrameOnly;
|
BOOL decodeFirstFrame = options & SDWebImageDecodeFirstFrameOnly;
|
||||||
NSNumber *scaleValue = context[SDWebImageContextImageScaleFactor];
|
NSNumber *scaleValue = context[SDWebImageContextImageScaleFactor];
|
||||||
CGFloat scale = scaleValue.doubleValue >= 1 ? scaleValue.doubleValue : SDImageScaleFactorForKey(cacheKey);
|
CGFloat scale = scaleValue.doubleValue >= 1 ? scaleValue.doubleValue : SDImageScaleFactorForKey(cacheKey);
|
||||||
if (scale < 1) {
|
SDImageCoderOptions *coderOptions = @{SDImageCoderDecodeFirstFrameOnly : @(decodeFirstFrame), SDImageCoderDecodeScaleFactor : @(MAX(scale, 1))};
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
SDImageCoderOptions *coderOptions = @{SDImageCoderDecodeFirstFrameOnly : @(decodeFirstFrame), SDImageCoderDecodeScaleFactor : @(scale)};
|
|
||||||
if (context) {
|
if (context) {
|
||||||
SDImageCoderMutableOptions *mutableCoderOptions = [coderOptions mutableCopy];
|
SDImageCoderMutableOptions *mutableCoderOptions = [coderOptions mutableCopy];
|
||||||
[mutableCoderOptions setValue:context forKey:SDImageCoderWebImageContext];
|
[mutableCoderOptions setValue:context forKey:SDImageCoderWebImageContext];
|
||||||
|
|
|
@ -23,10 +23,7 @@
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
if (scale < 1) {
|
SDImageCoderOptions *options = @{SDImageCoderDecodeScaleFactor : @(MAX(scale, 1)), SDImageCoderDecodeFirstFrameOnly : @(firstFrameOnly)};
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
SDImageCoderOptions *options = @{SDImageCoderDecodeScaleFactor : @(scale), SDImageCoderDecodeFirstFrameOnly : @(firstFrameOnly)};
|
|
||||||
return [[SDImageCodersManager sharedManager] decodedImageWithData:data options:options];
|
return [[SDImageCodersManager sharedManager] decodedImageWithData:data options:options];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue