Tue 18 Feb 2014 @ 11:53 AM


Bitmap from Geometry

Someone posted a challenge at the Programming Puzzles and Code Golf Stack Exchange site and I decided to take a crack at it. My first approach was to break the image down into 24 bitplanes and scan each of those for solid rectangular regions that could then be drawn to reconstruct an approximation of the original image. It works (approximately) and the source is just a tiny bit smaller (about 11 KB) than the original PNG image from which it originated. Here is the original image:

The originally provided image.

And here is my approximation of it:

My approximation of the image.

If there is any interest, I can make the code available that creates the image. Note that the code itself is only about 11 KB, but the data is about 364 KB. It's a bunch of strings that encode integers describing the location and size of solid rectangles to draw into various bitplanes.

Update: Click here to download source code as tdwfb.cxx.xz.

Go Top