Hi all
To colorise a binary file to help me in reverse engineering it's format this is
what I'm eventually doing. I have a small shell script that converts an *.img
file (unknown file format) to a png for viewing.
zimg takes a matrix of numbers and converts it to an image. The matrix if say
3x4 needs to be 12 numbers each on its own line.
With this I'm now looking at a few small files and looking for differences and
patterns in the image. Great xmassy fun eh :-)
#!/bin/sh
# Create a bitmap of a XXXXX image file.
function usage {
program_name=`basename $0`
echo 1>&2 "Usage: $program_name image_file ";
exit 1;
}
# Show usage if there are no args supplied.
if [ $# -lt 1 ]; then usage; fi
if [ ! -e $1 ]; then
echo "Can't find file $1"
exit 1
fi
echo "Processing $1"
# Get rid of last line of the dump.
hexdump -v -d $1 | head --lines=-1 > temp1
# Take field 1 only
cat temp1 | cut -d' ' --complement -f1 > temp2
# We need the number of rows for zimg.
ROWS=`cat temp3 | wc -l`
echo " cols=8 rows=$ROWS"
# Convert multiple spaces to single spaces.
cat temp2 | sed -r "s/\s+/ /g" | sed 's/ //' > temp3
# Spaces to newlines.
cat temp3 | tr ' ' '\n' > temp4
OUT_FILENAME=`echo "$1" | sed s/img/png/`
zimg --size=8,$ROWS temp4 > $OUT_FILENAME
_______________________________________________
coders mailing list
[email protected]
http://lists.slug.org.au/listinfo/coders