开发者

Most efficient method of loading a smaller representation of an image

开发者 https://www.devze.com 2023-02-09 02:05 出处:网络
I want to load a thumbnail representation of an image that is located in the Documents directory. If I were just using the Camera Roll I could use the Assets Library Framework to do this. With movie

I want to load a thumbnail representation of an image that is located in the Documents directory.

If I were just using the Camera Roll I could use the Assets Library Framework to do this. With movies I can use AV Foundation.

However, in my use case all I can figure out is to load the entire image into memory (2 megs and beyond),开发者_开发技巧 then grab a smaller representation of that image and release the larger.

I'm thinking there must be a better way.


Unless there's already a thumbnail image somewhere, then no, there's no more efficient way to do it. A JPEG or PNG image does not, by default or definition, contain a smaller version of itself.

Consider checking for a "[filename].thumbnail" file in the same directory as "[filename]". If you find it, use that; if not, load "[filename]", create the thumbnail, and write it to "[filename].thumbnail" so that the next time you use the image, a thumbnail version exists.

0

精彩评论

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