Well, I've got this compiler & interpreter I'm writing for the heck of it. So far I've written 4 compression methods for its sprite data; the data conversion program chooses the smallest compression result and makes usable data out of it that will be read by the interpreter's sprite drawing command.
Each pixel is comprised of 4 bits, which will be colors on a pallet at some point. At the moment, the valid RGB values are 0,0,0 64,64,64 128,128,128 and 256,256,256 - anything else is automatically counted by the interpreter as 0.
Note that the fourth compression method (which searches for 12 simple patterns 4096 pixels ahead, for each pixel) can take quite a while to process.
Please see if you can find any specific image characteristics that are ineffectively compressed by all methods. Also notify me of bugs, if you please.
Download it hereIt'll ask for the image path (just put it in the same directory and type the image's filename, extension included) and frame size. This will be used for spritesheets, not individual sprites, so that's merely how many pixels large each tile will be.
TECHNICAL ASPECTS:
The random data test is an image generated by spraying the MS spraycan tool all over the place to where all colors made up appx. 25% of the image. The compressor is not intended to be compressing truly random data.
Mode 0 is an uncompressed bitmap storing each pixel in 2 bits.
Mode 1 is RLE compression that stores each 2 bit color value as a byte and how many, up to 256, of the same color follow it. Strength: small images
Random data test: 145% expansion
Mode 2 is similar to the above, except the RLE data is stored in 1 byte. 6 bits are for the number following and 2 bits are for the color. Strength: typical pixel art imagery
Random data test: 73% compression
Mode 3 stores the RLE compressed data for 2 pixel data in 1 byte. 2 bits are for each quantity and 2 bits are for each color. Strength: Unpatterned data
Random data test: 36% compression
Mode 4 scans for 12 simple patterns: 4096 consecutive zeros, 1024 consecutive zeros, 256 consecutive zeros, 64 consecutive zeros, four consecutive of every color, and three consecutive of every color. 4 values are reserved for single colors that are part of none of these patterns. The data for 2 patterns is stored in 1 byte. Strength: Images with generous amounts of empty space
Random data test: 44% compression
I am still looking into additional compression methods that won't be too difficult to implement.