Skip to content

Commit d056b89

Browse files
committed
fix(image,ios): fix for decodeWidth/decodeHeight
1 parent 95005c4 commit d056b89

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

packages/image/platforms/ios/src/NSImageDecodeSizeTransformer.m

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,18 @@ - (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key {
2525
if (!image) {
2626
return nil;
2727
}
28-
CGFloat widthRatio = 1.0f;
29-
CGFloat heightRatio = 1.0f;
28+
CGFloat ratio = 1.0f;
3029

3130
CGFloat width = (CGFloat)image.size.width;
3231
CGFloat height = (CGFloat)image.size.height;
3332
if (self.decodeWidth && self.decodeHeight) {
34-
widthRatio = self.decodeWidth / width;
35-
heightRatio = self.decodeHeight / height;
33+
ratio = MIN(self.decodeWidth / width, self.decodeHeight / height);
3634
} else if (self.decodeWidth > 0) {
37-
widthRatio = self.decodeWidth / width;
35+
ratio = self.decodeWidth / width;
3836
} else {
39-
heightRatio = self.decodeHeight / height;
37+
ratio = self.decodeHeight / height;
4038
}
41-
return [image sd_resizedImageWithSize:CGSizeMake(width * widthRatio, height * heightRatio) scaleMode:2];
39+
return [image sd_resizedImageWithSize:CGSizeMake(width * ratio, height * ratio) scaleMode:2];
4240
}
4341

4442
@end

0 commit comments

Comments
 (0)