开发者

iPhone memory warning for high resolution images

开发者 https://www.devze.com 2023-04-05 04:08 出处:网络
I have an app which display images in full Screen. Some of the images are 1952x3680 pixels and these images are raising memory w开发者_如何转开发arning level=1 and level=2.

I have an app which display images in full Screen. Some of the images are 1952x3680 pixels and these images are raising memory w开发者_如何转开发arning level=1 and level=2.

How should i handle these image?


Scale your images down considerably. There is absolutely no reason you need images at that resolution in an iPhone app.


Don't use them. Either get your server to deliver a thumbnail version of the image (maybe using a thumb.php/jsp/asp/... file with GET params x=<width>&y=<height>), or scale the image down on the iPhone and discard the original data. The former method is vastly preferred as it saves on both bandwidth and large memory allocations client-side.

The largest images you should be working with are 480x320 (iPhone 3GS and earlier) and 960x640 (iPhone 4).

EDIT: The other situation I didn't think of is if you're bundling these images with the app. Please, please don't do that. If you have images that big, scale them down in Apple's Preview or any image editor to the sizes noted, and ideally have two copies, image.png and image@2x.png which are shown depending on the scale of the device's screen.


The screen itself is only 320x460 (not considering the clock bar on top), and 640x960 for retina display. There is no reason to have images this large to begin with. Scale them down. It'll both prevent the memory warnings and stymie unnecessary image size.


As said before, scale it down if you only want to show the image without zooming in fullscreen. If you need to zoom and show it detailed, google for CATiledLayer. There are good examples around.

0

精彩评论

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