开发者

Loading Huge resolution images causing Heap error in j2me

I am trying to load a 3776 * 2816 PNG, 24 bit image - 804KB onto my phone , the MOTO ROKR e6.It gives up with java.lang.OutOfMemoryError,Is their a general 开发者_JAVA技巧way to handle loading such high resolution images.The phone's internal memory is only 8MB, I think this has something to do with the error.

I have also, tried to split the image to 16 parts and load them, still there seems to be some limit on what it can handle.

Please advise.


So just some quick calculations:

24 bits = 3 bytes
space required (in bytes) = 3776 * 2816 * 3 
                          = 31,899,648 bytes
                          = 31.9MB

That means once you've loaded the image (using ImageIO or JAI or whatever) you need 31.9MB to store the raw image data. As a result you can't load it on a device with only 8MB of memory (and I'm assuming no other kind of swap space).

You could load the raw file as bytes of data rather than an image -- the data is heavily compressed -- but I don't think that's what you're looking for.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜