Il giorno 27/mar/2012, alle ore 09:38, Ray ha scritto: > OK, so I have this iOS 3.x code base that I need to update. I have the > following code, to make a thumbnail image: > Code is simplified, just for illustrative purposes. I store imageData as a > binary property (called "listImage") in a Core Data entity and use it as a > thumbnail image in a UITableView, like so: > > But this seems kludgy and it's using programmer's knowledge, so to speak. I > watched WWDC2010 session 134 "Optimize your iPhone App for the Retina > Display" again, searched stackoverflow etc. but I can't find a more elegant > solution. What would be a more thorough approach? Maybe it's staring me in > the face but I don't see it...
That's what I use to generate a thumbnail of sideSize side lenght in iOS3.x code. It uses iOS4+ functions for retina displays (I remember that you can assume iOS4+ with retina displays). CGSize newSize = CGSizeMake(sideSize, sideSize); #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 if(UIGraphicsBeginImageContextWithOptions != NULL) UIGraphicsBeginImageContextWithOptions(newSize, NO, [[UIScreen mainScreen] scale]); else #endif UIGraphicsBeginImageContext(newSize); UIGraphicsBeginImageContext(newSize); [self drawInRect:CGRectMake(0, 0, sideSize, sideSize)]; // Get the new image from the context UIImage *thumbnailImage = UIGraphicsGetImageFromCurrentImageContext(); // End the context UIGraphicsEndImageContext(); It works correctly on retina displays. To be honest I don't remember why I use that macro to test for iOS4, there were a reason and that was a workaround but cannot remember why. It works, anyway. :) HTH, gt --- Giacomo Tufano Stat rosa pristina nomine, nomina nuda tenemus. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com