Fix the edge case when incrementalDecodedImageWithOptions provide custom scale factor and override the one from init method

This commit is contained in:
DreamPiggy 2020-01-06 18:45:38 +08:00
parent c9dffc64dc
commit ec620438b9
2 changed files with 12 additions and 2 deletions

View File

@ -339,7 +339,12 @@
if (_width + _height > 0) { if (_width + _height > 0) {
// Create the image // Create the image
image = [SDImageIOAnimatedCoder createFrameAtIndex:0 source:_imageSource scale:_scale preserveAspectRatio:_preserveAspectRatio thumbnailSize:_thumbnailSize]; CGFloat scale = _scale;
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
if (scaleFactor != nil) {
scale = MAX([scaleFactor doubleValue], 1);
}
image = [SDImageIOAnimatedCoder createFrameAtIndex:0 source:_imageSource scale:scale preserveAspectRatio:_preserveAspectRatio thumbnailSize:_thumbnailSize];
if (image) { if (image) {
image.sd_imageFormat = self.class.imageFormat; image.sd_imageFormat = self.class.imageFormat;
} }

View File

@ -185,7 +185,12 @@
if (_width + _height > 0) { if (_width + _height > 0) {
// Create the image // Create the image
image = [SDImageIOAnimatedCoder createFrameAtIndex:0 source:_imageSource scale:_scale preserveAspectRatio:_preserveAspectRatio thumbnailSize:_thumbnailSize]; CGFloat scale = _scale;
NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor];
if (scaleFactor != nil) {
scale = MAX([scaleFactor doubleValue], 1);
}
image = [SDImageIOAnimatedCoder createFrameAtIndex:0 source:_imageSource scale:scale preserveAspectRatio:_preserveAspectRatio thumbnailSize:_thumbnailSize];
if (image) { if (image) {
CFStringRef uttype = CGImageSourceGetType(_imageSource); CFStringRef uttype = CGImageSourceGetType(_imageSource);
image.sd_imageFormat = [NSData sd_imageFormatFromUTType:uttype]; image.sd_imageFormat = [NSData sd_imageFormatFromUTType:uttype];