X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=evolis-printer.pl;h=23f431af13acccc1cc9a6d081752ac0eb988a8b8;hb=6313a21d73dcc4ff9b00b0f5cbcb19ed8a400b6c;hp=08669a77fcdb9cf18fe1ef7a8cbc1a346f32c00a;hpb=5783ae0a5d5e1dd0149d47a73d640f48c742cf29;p=Printer-EVOLIS.git diff --git a/evolis-printer.pl b/evolis-printer.pl index 08669a7..23f431a 100755 --- a/evolis-printer.pl +++ b/evolis-printer.pl @@ -17,10 +17,13 @@ local $/ = "\r"; my $page = 1; +my $name = $ARGV[0] || 'page'; + sub save_pbm; while(<>) { - die "no escape at beginning",dump($_) unless s/^\x1B//; + 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; @@ -36,26 +39,46 @@ while(<>) { } elsif ( $c eq 'Pr' ) { print "improve $a[0]\n"; # FIXME windows sends it, cups doesn't + } elsif ( $c eq 'Sv' ) { + print "even page on duplex printing\n"; } elsif ( $c eq 'Db' ) { # XXX not in cups my ( $color, $two, $data ) = @a; $two eq '2' or die '2'; - my $path = "page-Db-$color-$page.pbm"; + 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, $data ) = @a; - while ( $len > length($data) ) { - warn "# slurp more ",length($data), " < $len\n"; - $data .= <>; + my ( $color, $line, $len, $comp ) = @a; + 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 + + 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; } - $len == length $data or warn "wrong length $len != ", length $data; - my $path = "page-Dbc-$color-$page.pbm"; +=cut + + my $data = $comp; + + my $path = "$name-Dbc-$color-$page.pbm"; $page++; - my ( $w, $h ) = ( 646, 1081 ); # from driver -# ( $w, $h ) = ( 636, 994 ); # from test card - $h = int( length($data) * 8 / $w ); + my $h = int( $len / 128 ); save_pbm $path, $w, $h, $data; } else {