Image file format that use palleted colors and simple [run length encoding]
? lossless compresion algoritm.
PCX was quite popular on early
DOS and
Windows systems, but it nowadays very rare, replaced by formats which support much better compression and full 24-bit images, like
GIF,
JPEG and
PNG.
PCX compresion
Decompression algorithm is very simple. Every byte from range 0x00 to 0xc0 encodes a single pixel of this value.
Bytes from range 0xc1 to 0xff mean that the next 1 to 63 pixels have the same color, which is encoded in the next byte.
Colors 0xc1 to 0xff are encoded using length 1 prefix followed by their code: 0xc1 COLOR.
Because colors 0x00..0xc0 are compressed better than colors 0xc1..0xff, good palette sorting is important.
It's usually (but not allways) enough to move the most-common colors into palette positions 0x00..0xc0, and least-used to palette positions 0xc1..0xff.
This compression algorithm is very fast and takes very little memory, but its not very efficient, especially in compressing real-world images.