Sun Java Solaris Communities My SDN Account Join SDN
 
FAQ

What image types does MIDP support?

 
 
 

Question

What image types does MIDP support?

Answer

You can find the easy answer on page 9 of the "Mobile Information Device Profile, v.2.0" document. It states that a compliant MIDP 2.0 implementation "MUST support PNG image transparency"; that is, the Portable Network Graphics format.

The next statement in the document is: "MAY include support for additional formats." What other formats could be supported? A quick scan of the alphabet soup of file extensions yields a few popular graphic types such as:

  • Graphics Interchange Format (GIF)
  • Joint Photographic Experts Group (JPEG, JPG)
  • Windows or OS/2 Bitmap (BMP)
  • Tag Image File Format (TIF)
  • PC Paintbrush bitmap (PCX)
  • Raw signed PCM data (RAW)

The question is then, does a given MIDP device support any format other than the required PNG? I tried an empirical solution to the problem:

  1. Find an image in some common format - easy enough if you have a digital camera and a non-copyrighted subject.
  2. Use some graphics application to save the image in various formats. I used Adobe Photoshop 7.0 to save a 16-bit color image, 96 x 96 pixels in size, in seven different formats: PNG, GIF, JPG, TIF, BMP, RAW, and PCX.
  3. Write a MIDlet that uses the method javax.microedition.lcdui.Image.createImage(String) to attempt to load the various graphic images that are part of the MIDlet's resources. The assumption built into this step was that if createImage() does not throw a java.io.IOException, the image is in a supported format.
  4. Report which image types could be created. I used a read-only TextField on a Form with an exit command.

After a few iterations to get the MIDlet to behave, I was able to make the following observations:

  • PNG was supported on the test platforms as it should be.
  • No other format was supported.
  • Resource names are case-sensitive; for example, /ellen-png.png is not the same resource as /ellen-png.PNG or any other variation.
  • File sizes varied from 9.1 Kbytes for GIF to 69.5 Kbytes for TIF.

Note that the sizes of JAR files that specific devices can load depend on multiple factors, including limitations imposed by handset manufacturers and carriers, or even the available memory configuration on a specific device.

References:

Trademarks

Java, J2EE, J2SE, J2ME, and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Adobe Photoshop is a registered trademark of Adobe Systems Incorporated in the United States and/or other countries.

Thanks to Vincent Hardy and Nicolas Lorain of Sun Microsystems for their reviews.