Bitmap manipulation programs

bitmapdd

This program creates a bitmap from a file (or device). It’s mainly used for creating a usage map of input but it can also do conversions.

You can download bitmapdd from GitHub:

$ git clone https://github.com/andmaj/bitmapdd.git

Scenario 1:

You have a file which consists of blocks of data. If a block is full of zeros than it’s free, otherwise it’s used. You want to make a bitmap from it where a bit in the file is 0 if the corresponding block is zero, otherwise it’s 1.

For example with block size set to 4:

$ bitmapdd --bs 4 --if input.dat --of output.dat

bitmapdd1

Scenerio 2:

Converting a text of zeros and ones to a binary file where every bit corresponds to one character in the original file.

$ bitmapdd --bs 1 --null 48 --if usagemap.txt --of usagemap.dat

Note: null byte has been set to 48 which is the code of character “0” in the ASCII character table. 

usagemap.txt contains text:
001100000100000001000001

usagemap.dat will contain text:
0@A

Character Decimal code Binary code
0 48 00110000
@ 64 01000000
A 65 01000001

bitmap2pbm

Creates a P4 type PBM image from a binary file. With this program you can visualize your binary (for example a usage map).

You can download bitmap2pbm from GitHub:

$ git clone https://github.com/andmaj/bitmap2pbm.git

How to use

For example creating an image of the first 10000 bytes of memtest binary:

$ head -c 10000 /boot/memtest86+-4.20 | bitmap2pbm --of memtest.pbm

You can view the image in Gimp.

bitmap2pbm

 

fat2bitmap

Creates a bitmap from FAT file system free/used clusters. The bitmap is in text format so contains zero (character 48) and one (character 49) bytes.

A zero means that the cluster is free, a one means that the cluster is used.

You can download fat2bitmap from GitHub:

$ git clone https://github.com/andmaj/fat2bitmap.git

How to use

Create a usage map of FAT file system (from filesys.iso image file)

$ fat2bitmap --if filesys.iso --of usagemap.txt

Convert the result to a binary image map with bitmapdd:

$ bitmapdd --bs 1 --null 48 --if usagemap.txt --of usagemap.dat

And finally display the usage map:

$ bitmap2pbm --if usagemap.dat --of usagemap.pbm
$ gimp usagemap.pbm &

You can also do these steps with one command:

$ fat2bitmap --if filesys.iso | bitmapdd --bs 1 --null 48 | bitmap2pbm --of usagem
ap.pbm

Note:
To create a FAT file system image file follow my guide:
http://fejlesztek.hu/create-a-fat-file-system-image-on-linux/

Leave a Reply

Your email address will not be published. Required fields are marked *

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