The following definition and example are quoted from the Windows 3.1 API online help file.
“When the biCompression member is set to BI_RLE8, the bitmap is compressed using a run-length encoding format for an 8-bit bitmap. This format may be compressed in either of two modes: encoded and absolute. Both modes can occur anywhere throughout a single bitmap.
Encoded mode consists of two bytes: the first byte specifies the number of consecutive pixels to be drawn using the color index contained in the second byte. In addition, the first byte of the pair can be set to zero to indicate an escape that denotes an end of line, end of bitmap, or a delta. The interpretation of the escape depends on the value of the second byte of the pair. The following list shows the meaning of the second byte:
Value Meaning 0 End of line 1 End of bitmap 2 Delta. The two bytes following the escape contain unsigned values indicating the horizontal and vertical offset of the next pixel from the current position.
Absolute mode is signaled by the first byte set to zero and the second byte set to a value between 0x03 and 0xFF. In absolute mode, the second byte represents the number of bytes that follow, each of which contains the color index of a single pixel. When the second byte is set to 2 or less, the escape has the same meaning as in encoded mode. In absolute mode, each run must be aligned on a u_int16 boundary.
The following example shows the hexadecimal values of an 8-bit compressed bitmap:
03 04 05 06 00 03 45 56
67 00 02 78 00 02 05 01
02 78 00 00 09 1E 00 01
This bitmap would expand as follows (two-digit values represent a color index for a single pixel):
04 04 04
06 06 06 06 06
45 56 67
move current position 5 right and 1 down
end of line
1E 1E 1E 1E 1E 1E 1E 1E 1E
end of RLE bitmap”
Duplicate formats: RLE8
Return to YUV pixel formats