The standard way to load an image in a J2ME application is using the Image.createImage method and the recommended image format is PNG.
Now, the J2ME specs dont lay down any restrictions on the implementation of this method or the in memory representation of an Image so, each vendor has a different implementation.
Motorola in particular has this really crappy implementation where in the PNG is completely decoded into ARGB byte array at the time of image creation. This means that an 8K png with dimensions 176x208 takes up a peak memory of about 170K to load and the memory utilized by the Image object itself is about 145K! On other phones like Nokia, Sony Ericsson etc, the same image only takes about 16K to load and store in memory.I dont know what smart optimizations they use, but for some incomprehensible reason, Motorola's JVM does not.
This is wreaking havoc in my J2ME app, making it almost impossible to run a decent version of it on Motorola phones. I tried various workarounds like using a gzip'd ARGB byte array of the image and deflating it during paint, but that causes the paint to slow down by a factor of 10!
Anyone know of a workaround to this issue? An open source PNG image decoder for J2ME with the smarts that Motorola lacks? Or is there something that can be done to the PNG image to reduce its in memory footprint? (I currently used Indexed mode PNG) Any pointers at all would be welcome..
Gowri