Skip to content

Commit

Permalink
Merge pull request #6146 from vishalduggal/timob-17734
Browse files Browse the repository at this point in the history
[TIMOB-17734] iOS: ImageLoader doesn't support @3x
  • Loading branch information
pec1985 committed Sep 22, 2014
2 parents dfcafe2 + 9be99ea commit cc77ed4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions iphone/Classes/ImageLoader.m
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,12 @@ -(void)serialize:(NSData*)imageData
if (!local && imageData != nil) {
NSFileManager* fm = [NSFileManager defaultManager];
NSString* path = localPath;
if (hires && [TiUtils isRetinaDisplay]) { // Save as @2x w/retina
path = [NSString stringWithFormat:@"%@@2x.%@", [localPath stringByDeletingPathExtension], [localPath pathExtension]];
if (hires) {
if ([TiUtils isRetinaHDDisplay]) { // Save as @3x w/retina-hd
path = [NSString stringWithFormat:@"%@@3x.%@", [localPath stringByDeletingPathExtension], [localPath pathExtension]];
} else if ([TiUtils isRetinaDisplay]) { // Save as @2x w/retina
path = [NSString stringWithFormat:@"%@@2x.%@", [localPath stringByDeletingPathExtension], [localPath pathExtension]];
}
}

if ([fm isDeletableFileAtPath:path]) {
Expand Down Expand Up @@ -496,7 +500,7 @@ -(ImageCacheEntry *)entryForKey:(NSURL *)url
NSLog(@"[CACHE DEBUG] Loading locally from path %@", path);
#endif
BOOL scaleUp = NO;
if ([TiUtils isRetinaDisplay] && [path rangeOfString:@"@2x"].location!=NSNotFound)
if (([TiUtils isRetinaDisplay] && [path rangeOfString:@"@2x"].location!=NSNotFound) || ([TiUtils isRetinaHDDisplay] && [path rangeOfString:@"@3x"].location!=NSNotFound))
{
scaleUp = YES;
}
Expand All @@ -508,7 +512,7 @@ -(ImageCacheEntry *)entryForKey:(NSURL *)url
if ([UIImage instancesRespondToSelector:@selector(imageWithCGImage:scale:orientation:)])
{
// if we specified a 2x, we need to upscale it
resultImage = [UIImage imageWithCGImage:[resultImage CGImage] scale:2.0 orientation:[resultImage imageOrientation]];
resultImage = [UIImage imageWithCGImage:[resultImage CGImage] scale:([TiUtils isRetinaHDDisplay] ? 3.0 : 2.0) orientation:[resultImage imageOrientation]];
}
}
result = [self setImage:resultImage forKey:url hires:NO];
Expand Down

0 comments on commit cc77ed4

Please sign in to comment.