Small program to convert a binary file to grayscale 1-byte-1-pixel png
and
back using stb_image and stb_image_write.
To allow for converting back the image is padded to a rectangle with some pixel that is different value than last valid one (so the decoding can strip it). Even images of 'nice' size like 16 byte binary file that'd be a 4x4 image with no padding will be padded so decoder always knows that all trailing pixels of same value are padding and not data. This allows for a byte perfect roundtrip.
The idea for this program appeared when I ran across a multi-meg file that had most of its bytes set to 0 but due to its size even tiny font and a fullscreen hex viewer weren't enough to show it. An image generated by this program would make such large swathes of 0s or other patterns easy to see at a glance.
Example of image generated from exe of this very program:
Go to releases to download a Windows exe compiled with Pelles C with no -O2
to avoid running into any -O2
optimizer bug similar to this one that affected
stb_image
: Pelles C forum bug report