Committed by
Olivier Poitrey
checking if uiimage supports the scale parameter for retina display phones (only…
… supported form ios 4 onwards)
Showing
2 changed files
with
13 additions
and
6 deletions
@@ -174,11 +174,14 @@ static SDImageCache *instance; | @@ -174,11 +174,14 @@ static SDImageCache *instance; | ||
174 | NSData *imageData = [NSData dataWithContentsOfFile:file]; | 174 | NSData *imageData = [NSData dataWithContentsOfFile:file]; |
175 | if (imageData) { | 175 | if (imageData) { |
176 | UIImage *image = [[[UIImage alloc] initWithData:imageData ] autorelease]; | 176 | UIImage *image = [[[UIImage alloc] initWithData:imageData ] autorelease]; |
177 | - CGFloat scale = 1.0; | ||
178 | - if ([fileKey hasSuffix:@"@2x.png"] || [fileKey hasSuffix:@"@2x.jpg"]) { | ||
179 | - scale = 2.0; | 177 | + if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { |
178 | + CGFloat scale = 1.0; | ||
179 | + if ([fileKey hasSuffix:@"@2x.png"] || [fileKey hasSuffix:@"@2x.jpg"]) { | ||
180 | + scale = 2.0; | ||
181 | + } | ||
182 | + image = [[[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:UIImageOrientationUp] autorelease]; | ||
180 | } | 183 | } |
181 | - return [[[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:UIImageOrientationUp] autorelease]; | 184 | + return image; |
182 | } | 185 | } |
183 | return nil; | 186 | return nil; |
184 | } | 187 | } |
@@ -131,8 +131,12 @@ NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNot | @@ -131,8 +131,12 @@ NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNot | ||
131 | scale = 2.0; | 131 | scale = 2.0; |
132 | } | 132 | } |
133 | 133 | ||
134 | - UIImage *image = [[[UIImage alloc] initWithData:imageData ] autorelease]; | ||
135 | - image = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:UIImageOrientationUp]; | 134 | + UIImage *image = [[UIImage alloc] initWithData:imageData ]; |
135 | + if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { | ||
136 | + UIImage *originalImage = image; | ||
137 | + image = [[UIImage alloc] initWithCGImage:originalImage.CGImage scale:scale orientation:UIImageOrientationUp]; | ||
138 | + [originalImage release]; | ||
139 | + } | ||
136 | 140 | ||
137 | #ifdef ENABLE_SDWEBIMAGE_DECODER | 141 | #ifdef ENABLE_SDWEBIMAGE_DECODER |
138 | [[SDWebImageDecoder sharedImageDecoder] decodeImage:image withDelegate:self userInfo:nil]; | 142 | [[SDWebImageDecoder sharedImageDecoder] decodeImage:image withDelegate:self userInfo:nil]; |
-
Please register or login to post a comment