Imagize: Convert your files from BINARY values to a BMP image

I woke up one day saying “Hey, wouldn’t it be cool to convert a software to an image?”

When you google “convert files to bmp”, you’d either get links that converts an image from one format to another, or if you’re lucky, how to inject a malicious software (*COUGH*VIRUS*COUGH*BACKDOOR*COUGH).

I remember there was a post in my blog made by one of the ex-writers; SIGTERMer. Building an image out of a few MB-sized OS.

Because I couldn’t find a program that does that. I figured I’d do that myself.

So here it is, I made a C# project that can convert any file from its binary values to an BMP image representation of it.

Here’s how it happens:

  1. Read file’s data in Binary.
  2. Do some math magic to figure out the width and height
    1. Gets file length.
    2. Pad it with FF values (Or 255) until it has a square root has an integer value (No fractions).
    3. Square root the total size to get the width and height.
  3. Convert Binary values to Integers (As in, from 0 to 255).
  4. Do for-loop for each dimension (Which means two), have the height’s width divided by 3, because we’re using three bytes to represent a color (Each byte for a color in RGB mode).
  5. Save the result in BMP

I really don’t know how to explain what I wrote up there, I tried my best (And my English is bananas right now because I just woke up, wife forced me… Don’t ask).

If you have Visual Studio 2015 (Could work on earlier releases, but that’s what I used for this project), you can check my Github to download and compile it.

The image in this post is what “explorer.exe” looks like. I’ll have to refine and comment my code. But for the time being, I’m too excited to alter anything in my code. I’ll get to it eventually, but not now.

If you’re feeling artistic in a glitchy way, I think this will be very useful for you.

7 thoughts on “Imagize: Convert your files from BINARY values to a BMP image

  1. Cool project. It’s nice to see you actually hosting source code in a public repository instead of just throwing up a link to an opaque binary. I don’t know C# nor do I have VS installed so I’ll just admire the post’s header image instead; for some reason, visual studio refuses to install on my windows 7 work machine, requires a service pack my IT dept. refuses to install, older versions won’t work.

    I’ll probably sound like a moron, but that header image is cropped, right? Also, either you mistook columns for rows and rows for columns. or windows has a really funky way of storing executables.

    1. Good luck with your IT department. It doesn’t hurt to install a VM in your box and have a Windows machine there to boot up every once in a while.

      For the image, its not cropped. Maybe it looks cropped, but its not.

      At my first attempts, I used to export a picture with 1:1 ratio. That doesn’t look so nice because only the top 1/3 of the picture is displayable while the rest is white (Since I’m padding everything in white).

      My second (And last, so far) attempt was shortening the row loop by third to appear like this.

      Mistaking columns and rows is a mistake I always make, for some odd reason. Its like saying Banana; I sometimes add another na or drop the last na.

  2. I actually created my own blog and own captcha writing numbers and converting that into jpg and own spam system using PHP. This was about 7 years ago. I read your blog and thought to share. Keep up your work.

  3. you don’t have to have a square image!!, you can have a rectangular so you don’t have to search for a square root.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.