-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retina image resources? #12
Comments
I solved this by replacing the following in EGOImageLoader: - (void)imageLoadConnectionDidFinishLoading:(EGOImageLoadConnection *)connection {
UIImage* anImage = [UIImage imageWithData:connection.responseData];
... with: - (void)imageLoadConnectionDidFinishLoading:(EGOImageLoadConnection *)connection {
CFDataRef imageData = (CFDataRef)connection.responseData;
CGDataProviderRef imageDataProvider = CGDataProviderCreateWithCFData(imageData);
CGImageRef image = CGImageCreateWithPNGDataProvider(imageDataProvider, NULL, true, kCGRenderingIntentDefault);
UIImage* anImage = [UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp];
CGDataProviderRelease(imageDataProvider);
CGImageRelease(image);
... Works for PNGs. Replace |
Two things in there : You can actually try for CGIImageCreatWithPNG and use JPEG if it failed like so : - (void)imageLoadConnectionDidFinishLoading:(EGOImageLoadConnection *)connection {
CFDataRef imageData = (CFDataRef)connection.responseData;
CGDataProviderRef imageDataProvider = CGDataProviderCreateWithCFData(imageData);
CGImageRef image = CGImageCreateWithPNGDataProvider(imageDataProvider, NULL, true, kCGRenderingIntentDefault);
if (!image) image = CGImageCreateWithJPEGDataProvider(imageDataProvider, NULL, true, kCGRenderingIntentDefault);
UIImage* anImage = [UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp];
CGDataProviderRelease(imageDataProvider);
CGImageRelease(image); The other point is that you also need to do the same for the EGOCache class. I'm using that : - (UIImage*)imageForKey:(NSString*)key {
NSData* d = [[NSFileManager defaultManager] contentsAtPath:cachePathForKey(key)];
if (d) {
CFDataRef imageData = (CFDataRef) d;
CGDataProviderRef imageDataProvider = CGDataProviderCreateWithCFData(imageData);
CGImageRef image = CGImageCreateWithPNGDataProvider(imageDataProvider, NULL, true, kCGRenderingIntentDefault);
if (!image) image = CGImageCreateWithJPEGDataProvider(imageDataProvider, NULL, true, kCGRenderingIntentDefault);
UIImage* anImage = [UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp];
CGDataProviderRelease(imageDataProvider);
CGImageRelease(image);
return anImage;
} else {
return nil;
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any advice or information on how to use this to handle loading up retina (@2x) vs. standard resolution images?
The text was updated successfully, but these errors were encountered: