Skip to main content
GameDev.net gamedev.net
🔒 Locked

createImage( ) limitations?

Started by someone2 May 12, 2004 at 3:29 PM 6 replies 450+ views
Original Post
someone2
someone2
Hello all, I hope you are all very fine.. I am working with Nokia S30, S40 and S60 phones. I noticed that Graphics.createImage() on a certain image fails when running on S30 and S40, but works perfectly on S60. The offensive image is a 320*200 png image. Is there a size limitation for S30 and S40 phones? what could it be? or is there something else i am missing? Thank you very much...
McMcDonald
McMcDonald
Hi!

I am sure it''s the heap memory.
320x200x2 = 128k of memory, and the createImage method needs additional memory to create the image - too much for s30/s40.

Regards
McMc
Graylien
Graylien
Is there an error message or an exception of some kind? Otherwise we could guess forever because it could be one of a million things...
------When thirsty for life, drink whisky. When thirsty for water, add ice.
Zahlman
Zahlman
If the program offers you "Details" on the crash screen when it crashes on a Series 40, select that. It will tell you the type of Throwable (to be general - not all things that can go wrong are Exceptions) that was thrown.

If it is indeed a heap size problem, then the thing that is thrown will be OutOfMemoryError (note, not an Exception).

But I do know for a fact that at least for blank images, Series 40 phones will construct as large an image as is possible given the remaining heap space (I have tested this). This is not true of all phones; Siemens phones for example have a limit of 16Kb for any uncompressed .class file (or so I''m told), or object instance (very sure of that one, having run into it with Images in the past).
shmoove
shmoove
It''s definitely a memory issue. Remember that when an Image is loaded into a Series 40 phone, it will use up 2 bytes per pixel (plus a few more bytes for the header). And Series 30/40 phones have around 200 KB of memory, so a 320x200 pixel image is a sure way to run out of memory.

shmoove
Zahlman
Zahlman
Try it in the emulator, and look at the heap usage right before the problem occurs.

A java.io.IOException could be occurring because the image isn''t actually in your jar, or you have the wrong pathname for it - but I assume that''s not the problem if you got the thing running on series 60.
shmoove
shmoove
It''s a memory issue. I''m willing to bet on that. And unless the image is loaded at the beginning of the application, the memory could be fragemented so that even if there is enough total free memory there will be an IOException (no free memory block big enough). I mean, come on, using up 128KB for an image on a Series 40 phone - that''s just asking for trouble.
Try making the image smaller and you''ll see it works.

shmoove

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.