Update to use scale factor instead of that firstFrameOnly, since it's not used frequently as scale
This commit is contained in:
parent
b9773d09c0
commit
e829637a30
|
@ -13,7 +13,6 @@
|
||||||
#pragma mark - Decode
|
#pragma mark - Decode
|
||||||
/**
|
/**
|
||||||
Create and decode a image with the specify image data
|
Create and decode a image with the specify image data
|
||||||
If the image data is animated image format, create an animated image if possible
|
|
||||||
|
|
||||||
@param data The image data
|
@param data The image data
|
||||||
@return The created image
|
@return The created image
|
||||||
|
@ -21,13 +20,13 @@
|
||||||
+ (nullable UIImage *)sd_imageWithData:(nullable NSData *)data;
|
+ (nullable UIImage *)sd_imageWithData:(nullable NSData *)data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create and decode a image with the specify image data
|
Create and decode a image with the specify image data and scale
|
||||||
|
|
||||||
@param data The image data
|
@param data The image data
|
||||||
@param firstFrameOnly Even if the image data is animated image format, decode the first frame only
|
@param scale The image scale factor. Should be greater than or equal to 1.0.
|
||||||
@return The created image
|
@return The created image
|
||||||
*/
|
*/
|
||||||
+ (nullable UIImage *)sd_imageWithData:(nullable NSData *)data firstFrameOnly:(BOOL)firstFrameOnly;
|
+ (nullable UIImage *)sd_imageWithData:(nullable NSData *)data scale:(CGFloat)scale;
|
||||||
|
|
||||||
#pragma mark - Encode
|
#pragma mark - Encode
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +45,7 @@
|
||||||
- (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat;
|
- (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Encode the current image to data with the specify image format
|
Encode the current image to data with the specify image format and compression quality
|
||||||
|
|
||||||
@param imageFormat The specify image format
|
@param imageFormat The specify image format
|
||||||
@param compressionQuality The quality of the resulting image data. Value between 0.0-1.0. Some coders may not support compression quality.
|
@param compressionQuality The quality of the resulting image data. Value between 0.0-1.0. Some coders may not support compression quality.
|
||||||
|
|
|
@ -12,14 +12,17 @@
|
||||||
@implementation UIImage (MultiFormat)
|
@implementation UIImage (MultiFormat)
|
||||||
|
|
||||||
+ (nullable UIImage *)sd_imageWithData:(nullable NSData *)data {
|
+ (nullable UIImage *)sd_imageWithData:(nullable NSData *)data {
|
||||||
return [self sd_imageWithData:data firstFrameOnly:NO];
|
return [self sd_imageWithData:data scale:1];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (nullable UIImage *)sd_imageWithData:(nullable NSData *)data firstFrameOnly:(BOOL)firstFrameOnly {
|
+ (nullable UIImage *)sd_imageWithData:(nullable NSData *)data scale:(CGFloat)scale {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
SDWebImageCoderOptions *options = @{SDWebImageCoderDecodeFirstFrameOnly : @(firstFrameOnly)};
|
if (scale < 1) {
|
||||||
|
scale = 1;
|
||||||
|
}
|
||||||
|
SDWebImageCoderOptions *options = @{SDWebImageCoderDecodeScaleFactor : @(scale)};
|
||||||
return [[SDWebImageCodersManager sharedManager] decodedImageWithData:data options:options];
|
return [[SDWebImageCodersManager sharedManager] decodedImageWithData:data options:options];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue