diff --git a/SDWebImage/SDAnimatedImage.h b/SDWebImage/SDAnimatedImage.h index a98bd302..bb452669 100644 --- a/SDWebImage/SDAnimatedImage.h +++ b/SDWebImage/SDAnimatedImage.h @@ -78,7 +78,7 @@ The scale factor of the image. @note For UIKit, this just call super instead. - @note For AppKit, `NSImage` can contains multiple image representations with different scales. However, this class does not do that from the design. We processs the scale like UIKit and store it as a extra information for correctlly rendering in `SDAnimatedImageView`. + @note For AppKit, `NSImage` can contains multiple image representations with different scales. However, this class does not do that from the design. We processs the scale like UIKit. This wil actually be calculated from image size and pixel size. */ @property (nonatomic, readonly) CGFloat scale; diff --git a/SDWebImage/SDAnimatedImage.m b/SDWebImage/SDAnimatedImage.m index 30eedbb4..34d88051 100644 --- a/SDWebImage/SDAnimatedImage.m +++ b/SDWebImage/SDAnimatedImage.m @@ -205,9 +205,7 @@ static NSArray *SDBundlePreferredScales() { @end @implementation SDAnimatedImage -#if SD_UIKIT || SD_WATCH @dynamic scale; // call super -#endif #pragma mark - UIImage override method + (instancetype)imageNamed:(NSString *)name { @@ -316,9 +314,6 @@ static NSArray *SDBundlePreferredScales() { #endif if (self) { _coder = animatedCoder; -#if SD_MAC - _scale = scale; -#endif NSData *data = [animatedCoder animatedImageData]; SDImageFormat format = [NSData sd_imageFormatForImageData:data]; _animatedImageFormat = format; @@ -353,17 +348,7 @@ static NSArray *SDBundlePreferredScales() { self = [super initWithCoder:aDecoder]; if (self) { NSData *animatedImageData = [aDecoder decodeObjectOfClass:[NSData class] forKey:NSStringFromSelector(@selector(animatedImageData))]; - CGFloat scale; -#if SD_MAC - NSNumber *scaleValue = [aDecoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(scale))]; - scale = scaleValue.doubleValue; - if (scale < 1) { - scale = 1; - } - _scale = scale; -#else - scale = self.scale; -#endif + CGFloat scale = self.scale; if (!animatedImageData) { return self; } @@ -388,9 +373,6 @@ static NSArray *SDBundlePreferredScales() { - (void)encodeWithCoder:(NSCoder *)aCoder { [super encodeWithCoder:aCoder]; -#if SD_MAC - [aCoder encodeObject:@(self.scale) forKey:NSStringFromSelector(@selector(scale))]; -#endif NSData *animatedImageData = self.animatedImageData; if (animatedImageData) { [aCoder encodeObject:animatedImageData forKey:NSStringFromSelector(@selector(animatedImageData))]; diff --git a/SDWebImage/SDWebImageGIFCoder.m b/SDWebImage/SDWebImageGIFCoder.m index 3db33284..c44af183 100644 --- a/SDWebImage/SDWebImageGIFCoder.m +++ b/SDWebImage/SDWebImageGIFCoder.m @@ -99,7 +99,7 @@ BOOL decodeFirstFrame = [options[SDWebImageCoderDecodeFirstFrameOnly] boolValue]; if (decodeFirstFrame || count <= 1) { - animatedImage = [[UIImage alloc] initWithData:data]; + animatedImage = [[UIImage alloc] initWithData:data scale:scale]; } else { NSMutableArray *frames = [NSMutableArray array];