1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-12-22 22:55:31 +02:00

tools/bit2ant: X bitmap to Antorcha image converter

This commit is contained in:
Werner Almesberger 2012-06-20 18:27:41 -03:00
parent 87f0ed17fc
commit 647f029775

47
tools/bit2ant Executable file
View File

@ -0,0 +1,47 @@
#!/usr/bin/perl
#
# tools/bit2ant - Convert X bitmap file to Antorcha image binary
#
# Written 2012 by Werner Almesberger
# Copyright 2012 Werner Almesberger
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
sub add
{
local $v = $_[0];
for (my $i = 0; $i != 8; $i++) {
push(@v, ($v >> $i) & 1);
}
}
while (<>) {
if (/width (\d+)/) {
$xm = $1;
next;
}
if (/height (\d+)/) {
$ym = $1;
die "no more than 16 rows" if $ym > 16;
next;
}
next unless /^\s*(0x.*[0-9abcdef])/;
for (split(/,\s*/, $1)) {
&add(hex($_));
}
}
$span = ($xm+7) & ~7;
for ($x = 0; $x != $xm; $x++) {
$v = 0;
for ($y = 0; $y != 16; $y++) {
$v |= 1 << $y if $v[$x+$y*$span];
}
print pack("v", $v);
}