Skip to content

Commit

Permalink
bug: Use device scale when loading images.
Browse files Browse the repository at this point in the history
  • Loading branch information
tberman authored and DylanVann committed Jun 25, 2019
1 parent 7f080bf commit 5cb5d6b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ios/FastImage/FFFastImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(@{
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 5cb5d6b

Please sign in to comment.