Skip to content

Commit 5cb5d6b

Browse files
tbermanDylanVann
authored andcommitted
bug: Use device scale when loading images.
1 parent 7f080bf commit 5cb5d6b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ios/FastImage/FFFastImageView.m

+10-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ - (void)setImageColor:(UIColor *)imageColor {
6868

6969
- (UIImage*)makeImage:(UIImage *)image withTint:(UIColor *)color {
7070
UIImage *newImage = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
71-
UIGraphicsBeginImageContextWithOptions(image.size, NO, newImage.scale);
71+
UIGraphicsBeginImageContextWithOptions(image.size, NO, 0.0);
7272
[color set];
73-
[newImage drawInRect:CGRectMake(0, 0, image.size.width, newImage.size.height)];
73+
[newImage drawInRect:CGRectMake(0, 0, newImage.size.width, newImage.size.height)];
7474
newImage = UIGraphicsGetImageFromCurrentImageContext();
7575
UIGraphicsEndImageContext();
7676
return newImage;
@@ -107,7 +107,7 @@ - (void)setSource:(FFFastImageSource *)source {
107107
} {
108108
self.hasSentOnLoadStart = NO;
109109
}
110-
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:_source.url]];
110+
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:_source.url] scale:[[UIScreen mainScreen] scale]];
111111
[self setImage:image];
112112
if (self.onFastImageProgress) {
113113
self.onFastImageProgress(@{
@@ -192,6 +192,13 @@ - (void)downloadImage:(FFFastImageSource *) source options:(SDWebImageOptions) o
192192
weakSelf.onFastImageLoadEnd(@{});
193193
}
194194
} else {
195+
CGFloat scale = [UIScreen mainScreen].scale;
196+
197+
if (scale > 1.0) {
198+
image = [UIImage imageWithCGImage:[image CGImage] scale: scale orientation:UIImageOrientationUp];
199+
[weakSelf setImage:image];
200+
}
201+
195202
weakSelf.hasCompleted = YES;
196203
[weakSelf sendOnLoad:image];
197204
if (weakSelf.onFastImageLoadEnd) {

0 commit comments

Comments
 (0)