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