checking if uiimage supports the scale parameter for retina display phones (only supported form ios 4 onwards)
This commit is contained in:
parent
baea8eed4a
commit
3ef0f609fd
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in New Issue