
MS-Windows .bmp RLE4
In principle RLE4 coding is based on the same scheme as RLE8. The primary difference is the resolution of the colour index using 4 bit and a range of values between 0 and 15 (16 colours).
RLE4 coding scheme:

Within a run two colour indices are stored together in a byte value. If direct repititions of a single index appear, both the lower and the most significant 4 bits of the run value has to be identical. The run counter relates to the number of pixels and not to the entire byte.
encoded decoded
01 0F 0
02 0F 0 F
03 0F 0 F 0
04 0F 0 F 0 F
04 00 0 0 0 0
As defined for 8 bit RLE, the coding in absolute mode has to be extended to word boundaries too:
encoded decoded
00 03 12 30 1 2 3
00 04 12 34 1 2 3 4
00 05 12 34 50 00 1 2 3 4 5
00 06 12 34 56 00 1 2 3 4 5 6
00 07 12 34 56 70 1 2 3 4 5 6 7
00 08 12 34 56 78 1 2 3 4 5 6 7 8
< ^ >
|