chiark / gitweb /
WIP yppsc-parsedb-updatereceiver; can convert bitmap to email
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 19 Jun 2009 18:03:28 +0000 (19:03 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 19 Jun 2009 18:03:28 +0000 (19:03 +0100)
pctb/testupdate-char [new file with mode: 0644]
pctb/yppsc-parsedb-updatereceiver

diff --git a/pctb/testupdate-char b/pctb/testupdate-char
new file mode 100644 (file)
index 0000000..0f0c8f0
--- /dev/null
@@ -0,0 +1,9 @@
+15
+Digit
+0
+3e0
+410
+808
+808
+410
+3e0
index bdc76c26c9748acfb9aa1171f6924ed869a37074..9132c4e9d22036ab35a249ffbe8e54d388666662 100755 (executable)
@@ -71,6 +71,43 @@ sub parseentryin__pixmap ($) {
 
 #---------- characters ----------
 
+sub parseentryin__char ($) {
+    my ($ei) = @_;
+    $ei =~ m/^([1-9]\d{0,2})\n(Digit|Upper|Lower)\n((?:[-&\'A-F0-9a-f ]|\x20)+)\n/s or die;
+    my ($h,$ctx,$str)= ($1+0,$2,$3);
+#print STDERR ">$'<\n";
+    my @d= grep { m/./ } split /\n/, $';
+#print STDERR ">@d<\n";
+    die if $h>31;
+    die if @d>400;
+    my $maxval= (1<<$h)-1;
+    map {
+       m/^[0-9a-f]{1,8}$/ or die;
+       $_= hex $_;
+       die "$_ ?" if $_ > $maxval;
+    } @d;
+    my $w= @d;
+    my $ppm= "P2\n$w $h\n1\n";
+    for (my $y=0; $y<$h; $y++) {
+       for (my $x=0; $x<$w; $x++) {
+           $ppm .= sprintf " %d", !!($d[$x] & (1<<$y));
+       }
+       $ppm .= "\n";
+    }
+    my $entry= sprintf "%d\n%s\n%s\n", $h,$ctx,$str;
+    map { $entry .= sprintf "%x\n", $_; } @d;
+    
+#print STDERR "[[[[\n$ppm\n]]]]";
+
+    my $icon= pipeval($ppm,
+#                    "pnmscale -xysize 78 $h",
+                     'pgmtopbm -threshold',
+                     'pnminvert',
+                     'pbmtoascii');
+
+    return ("$ctx",$str,$entry, '',$w,$icon);
+}
+
 #---------- useful stuff ----------
 
 sub pipeval ($@) {