This is actually a pretty neat mechanism that builds a string (including BMP magic number and header) and shoves it into a dump file, doing a ray trace per byte. I wish there was a commented/not collapsed version of it to better enjoy reading. Right now it's just a blob.