diff --git a/SDImageCache.m b/SDImageCache.m index be9e7d8..3bf426d 100644 --- a/SDImageCache.m +++ b/SDImageCache.m @@ -174,11 +174,14 @@ static SDImageCache *instance; NSData *imageData = [NSData dataWithContentsOfFile:file]; if (imageData) { UIImage *image = [[[UIImage alloc] initWithData:imageData ] autorelease]; - CGFloat scale = 1.0; - if ([fileKey hasSuffix:@"@2x.png"] || [fileKey hasSuffix:@"@2x.jpg"]) { - scale = 2.0; + if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { + CGFloat scale = 1.0; + if ([fileKey hasSuffix:@"@2x.png"] || [fileKey hasSuffix:@"@2x.jpg"]) { + scale = 2.0; + } + image = [[[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:UIImageOrientationUp] autorelease]; } - return [[[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:UIImageOrientationUp] autorelease]; + return image; } return nil; } diff --git a/SDWebImageDownloader.m b/SDWebImageDownloader.m index 737e2bd..bded6ae 100644 --- a/SDWebImageDownloader.m +++ b/SDWebImageDownloader.m @@ -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];