On Mar 27, 2012, at 12:38 AM, Ray wrote: > Now, when I generate a new image on an iPhone with a retina screen, in which > case the above UIGraphicsBeginImageContextWithOptions uses a scale of 2.0, > the image in the table view shows too big. This is because [UIImage > imageWithData:item.listImage] always returns a 1.0 scaled image. Now I can > solve this by using something like: > > UIImage *theImage = [UIImage imageWithData:listImage]; > [UIImage imageWithCGImage:theImage.CGImage scale:theImage.size.width > 44.0 ? > 2.0 : 1.0 orientation:theImage.imageOrientation]; > > 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...
Simplest solution is to save the scale along side the image itself (under the assumption that this data can possibly end up on a non-retina device for some reason) or to create a new UIImage with the screen scale via +imageWIthCGImage:scale:orientation: (assuming it cannot) after you load it with +imageWithData:. -- David Duncan _______________________________________________ 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