Reputation: 933
I have an app which display images in full Screen. Some of the images are 1952x3680 pixels and these images are raising memory warning level=1 and level=2.
How should i handle these image?
Upvotes: 0
Views: 405
Reputation: 7103
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.
Upvotes: 3
Reputation: 1302
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.
Upvotes: 0
Reputation:
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 [email protected]
which are shown depending on the scale
of the device's screen.
Upvotes: 2
Reputation: 50707
Scale your images down considerably. There is absolutely no reason you need images at that resolution in an iPhone app.
Upvotes: 4