#!/usr/bin/perl # Pilot bitmap creation tool 1.0, March 1997 by Ka-Ping Yee # # On stdin accepts a text file describing the bitmap: the first line # contains 2 to 4 numbers (width, height, optional bytes per row, and # optional flags), then the next lines contain characters # representing the pixels (space, hyphen, or dot for an empty pixel, # anything else for a filled pixel). Writes a bitmap resource to stdout. ($wid, $hgt, $bpr, $flags) = split(' ', <>); if (! $bpr) { $bpr = int(($wid+7)/8); } print pack('nn', $wid, $hgt); print "\x00" . chr($bpr) . chr($flags) . ("\x00" x 9); for $y (0..$hgt-1) { chop($_ = eof() ? '' : <>); for $b (0..$bpr-1) { ($byte = substr($_, $b*8, 8)) =~ tr/-. /1/c; $byte =~ tr/1/0/c; print pack('B*', substr($byte . '00000000', 0, 8)); } }