View Full Version : Neat way to visualize binary data
brywilharris
April 18th, 2009, 12:53 PM
Hey all,
I wrote this cool little tool to visualize binary data!
Bryan
smartboyathome
April 18th, 2009, 03:47 PM
I made one modification. I changed it to PNG instead of BMP (why does BMP exist still?!). It produces random noise?
Nevon
April 19th, 2009, 04:03 PM
I made one modification. I changed it to PNG instead of BMP (why does BMP exist still?!). It produces random noise?
You feel like sharing that? :P
brywilharris
April 20th, 2009, 08:34 AM
Png does compression and the contents are no longer a faithful representation of what's underneath.
With minimal work, you could convert back from the bitmap to the file you were mapping. With a png information is lost. It makes almost the same pretty picture, but the picture is blurred.
Try running the program on a text file and look at the difference. Or do: dd if=/dev/sda of=mbr.img count=100; bin2bmp.py mbr.img 128
This shows you your master boot record. I would like to munge the colors a little to automatically exphasize text files, executables, pictures, etc, but this is a first pass.
brywilharris
April 20th, 2009, 08:59 AM
In the last line of the program change BMP to PNG to output png files. Or you can make it JPEG to output jpg's. Of GIF to make gifs.
red_Marvin
April 21st, 2009, 06:57 PM
Fyi png uses a non destructive compression method, so no pixel data should be lost.
brywilharris
April 22nd, 2009, 08:46 AM
Yes I noticed that. with bitmap I knew wouldn't mangle anything. The newest version actually defaults to jpeg. I don't have anything against png, I'm just more familiar with the other formats.
Here are the newest options:
bin2bmp.py -h, --help
usage: /home/bryan-user/bin/bin2bmp.py <options> ... <filename>
-i, --input filename to visualize [mandatory]
-w, --width width of output image
-o, --output output filename (default is <input_filename>.jpg)
-V, --verbose print lots of extra stuff
-b, --bmp reverts to the old bitmap style output(jpg is default)
-m, --monochrome one bit per pixel
-c, --compress highly compressed jpeg
http://sourceforge.net/projects/bin2bmp/
brywilharris
April 22nd, 2009, 08:48 AM
The default is UNCOMPRESSED jpeg, CMYK. quality=100.
compressed jpeg uses quality=10
monochrome makes a pixel for each bit and uses gif output
bitmap output is still selectable.
brywilharris
April 22nd, 2009, 08:57 AM
I added png in to the latest release. -p or --png. It makes ~40% smaller pictures than bitmap with the same pixels.
Martje_001
April 22nd, 2009, 12:24 PM
With a png information is lost. It makes almost the same pretty picture, but the picture is blurred.
Not true! PNG uses lossless compressions (gzip IIRC).
brywilharris
April 22nd, 2009, 11:43 PM
Not true! PNG uses lossless compressions (gzip IIRC).
You're right. I didn't realize that! Check this out!
I think I need to write a fuse filesystem for this. It's almost too simple and so cool. It's a file system where you can see the contents.
http://randommusingsofarealgeek.blogspot.com/2009/04/bmpfs.html
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.