开发者

Loading Huge Image

开发者 https://www.devze.com 2022-12-25 04:20 出处:网络
I Want to load Image size 2550X3300 (i.e 1.7 Mb size), i have loaded the image into UIImageView and application gets crash due to low memory,

I Want to load Image size 2550X3300 (i.e 1.7 Mb size), i have loaded the image into UIImageView and application gets crash due to low memory, Now i have loaded into uiWebview it works fine but i have to save this image into an PDF file in local resource. While iam saving UIImage in background same app gets crash due to low memory.

Anyone has some suggestion or help to solve this issue.

开发者_如何学运维

Thank You.


It is not possible to load the whole image on the iPhone memory. Applications have a memory limit of 32MB, and a quick calculation shows that 2550*3300*4 (RGBA) = 33600000 bytes, which, in addition to the code, other resources and any buffers you create, is far beyond the 32MB limit. You should try to load just a piece of the image.


Look into splitting it up and using something like CATiledLayer to show parts at a time and to zoom in and out.


As I understand the iPhone has some virtual memory handler. If you pre-decode the image into a 33 something MB large file as pau.estalella calculate it to, you could look into accessing this file with mmap(..) and this way extract some usefull portion to be presented, scaled etc. A long shoot I think, but should be doable.

0

精彩评论

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