From 5cb5d6bab3a8da533114de4b643797a6981c71bd Mon Sep 17 00:00:00 2001 From: Todd Berman Date: Mon, 24 Jun 2019 18:20:32 -0700 Subject: [PATCH] bug: Use device scale when loading images. --- ios/FastImage/FFFastImageView.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ios/FastImage/FFFastImageView.m b/ios/FastImage/FFFastImageView.m index ff5d36984..892e33c1a 100644 --- a/ios/FastImage/FFFastImageView.m +++ b/ios/FastImage/FFFastImageView.m @@ -68,9 +68,9 @@ - (void)setImageColor:(UIColor *)imageColor { - (UIImage*)makeImage:(UIImage *)image withTint:(UIColor *)color { UIImage *newImage = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; - UIGraphicsBeginImageContextWithOptions(image.size, NO, newImage.scale); + UIGraphicsBeginImageContextWithOptions(image.size, NO, 0.0); [color set]; - [newImage drawInRect:CGRectMake(0, 0, image.size.width, newImage.size.height)]; + [newImage drawInRect:CGRectMake(0, 0, newImage.size.width, newImage.size.height)]; newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage; @@ -107,7 +107,7 @@ - (void)setSource:(FFFastImageSource *)source { } { self.hasSentOnLoadStart = NO; } - UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:_source.url]]; + UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:_source.url] scale:[[UIScreen mainScreen] scale]]; [self setImage:image]; if (self.onFastImageProgress) { self.onFastImageProgress(@{ @@ -192,6 +192,13 @@ - (void)downloadImage:(FFFastImageSource *) source options:(SDWebImageOptions) o weakSelf.onFastImageLoadEnd(@{}); } } else { + CGFloat scale = [UIScreen mainScreen].scale; + + if (scale > 1.0) { + image = [UIImage imageWithCGImage:[image CGImage] scale: scale orientation:UIImageOrientationUp]; + [weakSelf setImage:image]; + } + weakSelf.hasCompleted = YES; [weakSelf sendOnLoad:image]; if (weakSelf.onFastImageLoadEnd) {