Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
Image Optimization for JavaME
Since size optimization is a major process while creating Java ME applications, we have to take special care to optimize the images before they are used in the application.
Following are a few tips on how to optimize especially 'PNG' images (since they are mostly used because of transparency support and small size).
- When images are created using image editors like Photoshop, then special care should be taken so that the images are saved in the minimum size. For example, before saving the images, the unwanted colors should be removed. If your game/application requires transparency, then the image should be saved in 32-bit format. If this is not required you can go for 8-bit or 24-bit images, which will definitely reduce the image size. Before doing that you have to make sure the image looks good, and details are not lost.
- After the images are created using image editors, you can go for 3rd party image optimizer utilities to optimize the images, following are some of them:
- Pngcrush : Pngcrush is an optimizer for PNG (Portable Network Graphics) files. It can be run from a command line in an MSDOS window, or from a UNIX or LINUX command line.Its main purpose is to reduce the size of the PNG IDAT datastream by trying various compression levels an PNG filter methods. It also can be used to remove unwanted ancillary chunks, or to add certain chunks including gAMA, tRNS, iCCP, and textual chunks.
- OptiPNG: Advanced PNG Optimizer (): OptiPNG is a PNG optimizer that recompresses image files to a smaller size, without losing any information. This program also converts external formats (BMP, GIF, PNM and TIFF) to optimized PNG, and performs PNG integrity checks and corrections. It is based on Pngcrush
- PNGOUT: PNGOUT is a tool which can optimize PNG files created by other programs. It can be run from the Windows Run dialog box or at the command prompt. PNGOUT can produce even smaller files than pngcrush -brute or optipng -o7, however, since PNGOUT does not automate trials, you will have to find the right options yourself. PNGOUT Tutorial
- For games you may be using a number of images, in such cases if possible you may try to combine a number of images & form it into one. The advantage of using this is that if the images are present individually, then each image will have an header & also some other details which add to the jar size. If the images are combined then all together they will have a single header & details.
- You may also try, keeping the images after removing the headers. Now the images will be in byte format. This will definitely reduce the application size.