Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions
Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions
- Subject: Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions
- From: Ray <email@hidden>
- Date: Tue, 27 Mar 2012 14:48:50 +0200
Hi Marco,
Thanks for your thoughts!
Let me first say, the original app is already out there, using the old UIGraphicsBeginImageContext (at the time there was no UIGraphicsBeginImageContextWithOptions to begin with), used now on a variety of devices with normal and retina screens etc. The problem you describe below (transferring between various iPhones/iPod Touches with different screens etc.) exists already, but still using UIGraphicsBeginImageContext so I guess I know all existing saved images are (as per the example) 44 *pixels*.
On Mar 27, 2012, at 1:47 PM, Marco Tabini wrote:
> When the filename convention is not available, that metadata needs to be saved somewhere—in your case, you derive it from the file size, which, as you mention, is not very portable. I would have saved the scale in a separate Core Object
Right, this crossed my mind as well, which would also mean a little Core Data data model migration.
> property, or avoided saving the image in a data store to start with, and used a file cache, in which case UIImage is a bit more self-reliant.
At the time it seemed overkill, but now that would make sense. I checked some sample code (iPhoneCoreDataRecipes comes to mind) and it exhibits the same problem.
> In practice, I would want to look at more significant problems with your approach in a real-life deployment scenario. For example, what happens when your Core Data store is transferred from a non-Retina device to a Retina device? This could happen in a variety of scenarios: the user could start using your app on a non-Retina device (say, an iPad 2), then buy a new Retina device (a New iPad), back up the old one and restore on the new one. Now, your images are cached at 1x scale, but the device wants to run at 2x. Or, perhaps, you may, at some point, want to sync your data store using iCloud,
Yup, already happening. With the old UIGraphicsBeginImageContext, that is.
> Conversely, if your data is only ever used for caching purposes and is stored in the Caches directory, then this is a non-problem. Since the images are both going to be generated and used on the very same device, you don't need to derive the scale of the image from its size—you can just use the scale of your main screen both when creating and recreating your UIImage objects.
No, the images are meant to be persistent (coming off camera).
> Then again, if you move your images to individual files and save them with the appropriate @2x suffix, this whole problem goes away altogether—so, perhaps, that may be a better solution.
It might be indeed.
Thanks again, food for thought regarding this pesky problem!
- Ray.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden