And so many applications of bitmaps of text and other things like that, this is
very effective in its use in all kind of technologies like JPEG and fax and others.
It's very simple to implement, so this is our warm up data compression
algorithm that implements run-length encoding.
Actually, we left the compress for the book, this is just the expand.
So I'm given a bunch of counts,
how do I reproduce the original uncompressed text string?
And so, it's as simple as that.
So log R is the number of bits per count.
And so basically, what we do is read log R bits
at a time into an int, whatever the value is, so we put that into the int run.
So that's a number between 0 and 256,
which is the maximum you can get in 8 bits.
And then starting with 0, the first count, that's the number of 0s we need to write.
So we just write them out one bit at a time, 0s one bit at a time.
And then we flip the bit to make it 1 and read the next count.
And now, we write out that many 1s and so forth.
So, this is a ten line program that does expansion for run-length encoding.