The same color pixels in one row (or column, zigzag) are coded with a counter and pixel value. For example, aaabccccccddeee is coded to 3a1b6c2d3e
That is lossless data compression. It works well if the pixel values are the same in large regions. If every two pixel values are different, the algorithm will double the data, instead of compression.