Here is the sprite compression tool I created for my 2007 entry I have made it a little more user friendly and thought I would give it to the community.
The tool is useful for entrants who are using (or going to use) pre generated sprites in their game.
Features:
-Single or Multiple images can be stored in one output file
-When used with DataInjector can be embedded in the class file.
-Generates java source code for loading the images tailored for input images. This is to reduce overhead.
-1 bit transparancy
-Images are stored in a highly compressable format. For most sprites the file size is significantly less than crushed pngs.
-By using command line options you are able to reduce the file size even further by removing known properties from the images’ header portions. E.g. constant sprite dimensions, No transparancy, etc
-Able to store pixel colours in HSB format to cheaply generate different coloured versions of sprites by adding an offset to the HSB colour.
Download the tool here
Further information on the Image Format:
The main Idea to convert the image into a highly compressable format is to store an index of the different colours used in the image by order of similarity, thus pink is stored closer to red, different shades of yellow are next to each other and so forth. As it is likely that pixels with similar shades of colour are located near eachother due to shading and gradients in the sprites we can now record the difference between the previous pixel’s colour index and the current pixel’s colour index instead of recording the index of the colour used by each pixel.
This process can make long strings of similar bytes which Deflate can then compress extreamly well.
Comparision Results:
Each image format had been compressed into a ZIP file using KZIP to simulate embedding into a class file in a JAR
The BMP as been created using the 4 bit RLE option
The PNG has been passed though pngcrush using the brute and reduce options
The GIF has no extra options
The Ordered Index Differences version used the -auto and -noTrans options
Image Sprite used:
http://www.cuteandcuddlypet.com.au/moogie/toad_crushed.png
FORMAT BYTES
GIF.zip 1060
BMP.zip 1074
PNG.zip 1111
OID.zip 625