#!/usr/bin/perl -w $width = 192; $height = 64; $c0 = 0; $c1 = 1; $c2 = 15; $c3 = 14; $bmp = shift || die; $char = shift || die; open(BMP, $bmp) || die; binmode(BMP); while () { $bmp .= $_; } close(BMP); $bitmap = substr($bmp, -$width * $height); foreach $yy (0 .. $height - 1) { $y = $height - $yy - 1; $line = substr($bitmap, $width * $yy); for ($x = 0; $x < $width; $x += 2) { $c = ord(substr($line, $x)); if ($c == $c0) { $out[$y] .= "00"; } elsif ($c == $c1) { $out[$y] .= "01"; } elsif ($c == $c2) { $out[$y] .= "10"; } elsif ($c == $c3) { $out[$y] .= "11"; } else { $out[$y] .= ".."; } } } for ($y = 0; $y < $height; $y++) { print substr($out[$y], 0, 80) . "\n"; } for ($y = 0; $y < $height / 8; $y++) { print $y . "\n"; for ($x = 0; $x < $width / 8; $x++) { foreach $i (0 .. 7) { $line = substr($out[$y*8 + $i], $x*8, 8); $charset .= pack("B8", $line); } } } print "Writing " . length($charset) . " bytes, plus 2\n"; open(CHAR, ">$char") || die; binmode(CHAR); print CHAR "\x00\x20"; print CHAR $charset; close(CHAR);