X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=evolis-printer.pl;h=1a7a1f2a0d50cfd2527476f89f6c2d8240813bfb;hb=91c5ef9236ab1225cd4461c5c599c0ebf90ef675;hp=23f431af13acccc1cc9a6d081752ac0eb988a8b8;hpb=6313a21d73dcc4ff9b00b0f5cbcb19ed8a400b6c;p=Printer-EVOLIS.git diff --git a/evolis-printer.pl b/evolis-printer.pl index 23f431a..1a7a1f2 100755 --- a/evolis-printer.pl +++ b/evolis-printer.pl @@ -7,12 +7,6 @@ use strict; use Data::Dump qw(dump); -my $feeder = {qw( -F Feeder -M Manual -B Auto -)}; - local $/ = "\r"; my $page = 1; @@ -24,65 +18,67 @@ sub save_pbm; while(<>) { die "no escape at beginning",dump($_) unless s/^(\x00*)\x1B//; warn "WARNING: ", length($1), " extra nulls before ESC\n" if $1; - chomp; my @a = split(/;/,$_); my $c = shift @a; + chomp $c; if ( $c eq 'Pmi' ) { - my $f = $a[0] || die 'missing feeder'; - print "feeder $f | $feeder->{$f}\n"; - $a[1] eq 's' or die; + print "$_ mode insertion @a\n"; } elsif ( $c eq 'Pc' ) { - my $color = $a[0]; - $a[1] eq '=' or die; - my $temperature = $a[2]; - print "temperature $color = $temperature\n"; + print "$_ contrast @a\n"; + } elsif ( $c eq 'Pl' ) { + print "$_ luminosity @a\n"; + } elsif ( $c eq 'Ps' ) { + print "$_ speed @a\n"; } elsif ( $c eq 'Pr' ) { - print "improve $a[0]\n"; - # FIXME windows sends it, cups doesn't + print "$_ ribbon $a[0]\n"; + } elsif ( $c eq 'Ss' ) { + print "$_ sequence start\n"; + } elsif ( $c eq 'Se' ) { + print "$_ sequence end\n"; + } elsif ( $c eq 'Sr' ) { + print "$_ sequence recto - card side\n"; } elsif ( $c eq 'Sv' ) { - print "even page on duplex printing\n"; - } elsif ( $c eq 'Db' ) { # XXX not in cups + print "$_ sequence verso - back side\n"; + } elsif ( $c eq 'Db' ) { my ( $color, $two, $data ) = @a; - $two eq '2' or die '2'; - my $path = "$name-Db-$color-$page.pbm"; - $page++; + print "$c;$color;$two;... bitmap\n"; + $two eq '2' or die 'only 2 colors supported'; + my $path = "$name-Db-$color-$page.pbm"; $page++; save_pbm $path, 648, 1015, $data; # FIXME 1016? } elsif ( $c eq 'Dbc' ) { # XXX not in cups my ( $color, $line, $len, $comp ) = @a; + print "$c;$color;$line;$len;... download bitmap compressed\n"; while ( $len > length($comp) ) { warn "# slurp more ",length($comp), " < $len\n"; $comp .= <>; } $len == length $comp or warn "wrong length $len != ", length $comp; - my $w = 648 / 2; - -=for non-working + die "compression not supported" unless $color =~ m/[ko]/; my $data; - my $i = 0; while ( $i < length $comp ) { - my $len = ord(substr($comp,$i,4)); - $i += 1; - warn "$i comp $len\n"; - $data .= substr($comp,$i,$len); - $data .= "\x00" x ( $w - $len ); - $i += $len; + my $first = substr($comp,$i++,1); + if ( $first eq "\x00" ) { + $data .= "\x00" x 81; + } elsif ( $first eq "\xFF" ) { + $data .= "\xFF" x 81; + } else { + my $len = ord $first; + $data .= substr($comp,$i,$len); + my $padding = 81 - $len; +warn "# $len $padding\n"; + $data .= "\x00" x $padding; + $i += $len; + } } -=cut - - my $data = $comp; - - my $path = "$name-Dbc-$color-$page.pbm"; - $page++; - - my $h = int( $len / 128 ); - save_pbm $path, $w, $h, $data; + my $path = "$name-Dbc-$color-$page.pbm"; $page++; + save_pbm $path, 648, 1015, $data; } else { - warn "UNKNOWN: $c ", dump(@a); + print "FIXME: $_\n"; } }