Authored by Sebastian Vieira
Committed by Olivier Poitrey

checking if uiimage supports the scale parameter for retina display phones (only…

… supported form ios 4 onwards)
... ... @@ -174,11 +174,14 @@ static SDImageCache *instance;
NSData *imageData = [NSData dataWithContentsOfFile:file];
if (imageData) {
UIImage *image = [[[UIImage alloc] initWithData:imageData ] autorelease];
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
CGFloat scale = 1.0;
if ([fileKey hasSuffix:@"@2x.png"] || [fileKey hasSuffix:@"@2x.jpg"]) {
scale = 2.0;
}
return [[[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:UIImageOrientationUp] autorelease];
image = [[[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:UIImageOrientationUp] autorelease];
}
return image;
}
return nil;
}
... ...
... ... @@ -131,8 +131,12 @@ NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNot
scale = 2.0;
}
UIImage *image = [[[UIImage alloc] initWithData:imageData ] autorelease];
image = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:UIImageOrientationUp];
UIImage *image = [[UIImage alloc] initWithData:imageData ];
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
UIImage *originalImage = image;
image = [[UIImage alloc] initWithCGImage:originalImage.CGImage scale:scale orientation:UIImageOrientationUp];
[originalImage release];
}
#ifdef ENABLE_SDWEBIMAGE_DECODER
[[SDWebImageDecoder sharedImageDecoder] decodeImage:image withDelegate:self userInfo:nil];
... ...