Run-Length Encoding



Consider the following bitmap "picture" of a letter K:



	OOOOOOOOOOOOOOOOOOOO
        OOOO|OOOOOO|OOOOOOOO
        OOOO|OOOOO|OOOOOOOOO
        OOOO|OOOO|OOOOOOOOOO
        OOOO|OOO|OOOOOOOOOOO
        OOOO|OO|OOOOOOOOOOOO
        OOOO|O|OOOOOOOOOOOOO
        OOOO||OOOOOOOOOOOOOO
        OOOO|O|OOOOOOOOOOOOO
        OOOO|OO|OOOOOOOOOOOO
        OOOO|OOO|OOOOOOOOOOO
        OOOO|OOOO|OOOOOOOOOO
        OOOO|OOOOO|OOOOOOOOO
        OOOO|OOOOOO|OOOOOOOO
        OOOOOOOOOOOOOOOOOOOO
This contains 20 x 15 = 300 pixels.

It can be compressed by a method called run-length encoding which records the sequences of 0's and 1's:


20x0
4x0 1x1 6x0 1x1 8x0
4x0 1x1 5x0 1x1 9x0
4x0 1x1 4x0 1x1 10x0
etc.

Data Compression Reference Center