开发者

Iphone Retina Display with Core Data user-generated images

I have been looking at this forum on this topic for a while now and still don't have a clear picture of how to store images in Core Data successfully for Retina Display.

I understand that storing images through Core Data may not be the best for everyone, but in cases where it is being done for one reason or another, it is important to understand how these images are read and displayed.

Since the images don't have a file extension, the retina versions (if they exist) obviously cannot have a 2x extension.

So I am hoping someone can advise me as to how to what resolutions would be best to store bitmap images created through the app so that they have the best display in both retina and non-retina devices.

For example, if on my non-retina 3GS iPhone I have a UIImageView that displays a 55x60 image, I currently store an image "thumbnail" that is 55x60.

On the retina display, obviously I would like to have an image that is 110x120 to display.

But, since I can't create an image with an extension in core-data, how would I go about doing this?

If I decide just to create one image that will be used for both devices, do I just go with a 110x120 image? How does that work - will it use the full image for the retina display device and scale down the image for the non-retina device? Or (and I hope NOT) will it scale the image down for the non-retina device and scale it back up again fo开发者_StackOverflow中文版r retina?

Thanks in advance!


First and foremost: don't store images in Core Data. It is just easier (and more performant!) to store an image on the filesystem (ie. documents directory) and use Core Data to store the reference.

That said, if you are insistent in using Core Data to store that data, you could store the Retina version and then detect when you are on a non-retina device and do an in-memory scale to the non-Retina version.


Is part of the reason you want to store UIImages in CoreData so that your Images do not get "Cleaned" automatically by the OS?

If not, you should do as Wayne mentioned and just create references to a file path in the Documents directory.

If "cleaning" is the problem you are trying to avoid, then just store the UIImage's NSData as one of the NSManagedObject's properties, and then upon use scale it appropriately. Alternatively, you could always scale the images before putting them into CoreData.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜