A Run-Length Encoding for Monochromatic Images The Apple iPad I own displays a monochromatic image of the Apple Computer logo upon boot, and I grew to think about how that image must be stored. It's widely considered foolhardy to include an entire image format parser in low-level boot software, not unreasonably, but this nevertheless serves as an indictment of poor programming practices presently common. I started to wonder how I'd approach the problem, keeping it simple, and arrived at a pleasant and very simple solution I believe works well. The first matter is arbitrary, the decision to store the image by row or column, and encoding images without other regards to these boundaries seems more than reasonable; the second matter is similarly arbitrary, the machinery's starting value of one colour or the other, which deserves little thought. Unlike normal run-length encoding, such machinery encoding runs of only two states absolutely has no need to pair the value with the count, as the count by itself suffices; alternating counts alternate between the values. The conversion of such states to colours using a palette is trivial and boring. The final matter is whether the counts use a fixed-length or a variable-length representation. I so prefer the variable-length representation I designed, but it's inappropriate in some cases, and that question of which representation be smaller depends on the data to compress. The primary difference between these representations is the matter of alternating the states: A fixed-length representation will be unable to encode arbitrary counts, which seemingly calls for values to accompany counts, but using a count of zero for the next state nicely solves the problem; a variable-length representation has no need for this trick, as there will be no such counts too large, and is a reason to prefer it. The scheme can be extended to the odd case of more than two states, but its utility is questionable. .