3 # Simulate EVOLIS Dualys printer
8 use Data::Dump qw(dump);
20 my $name = $ARGV[0] || 'page';
25 die "no escape at beginning",dump($_) unless s/^(\x00*)\x1B//;
26 warn "WARNING: ", length($1), " extra nulls before ESC\n" if $1;
28 my @a = split(/;/,$_);
31 my $f = $a[0] || die 'missing feeder';
32 print "$_ feeder: $feeder->{$f}\n";
34 } elsif ( $c eq 'Pc' ) {
37 my $temperature = $a[2];
38 print "$_ temperature $color = $temperature\n";
39 } elsif ( $c eq 'Pl' ) {
41 print "$_ brightnes? $a[0] = $a[2]\n";
42 } elsif ( $c eq 'Ps' ) {
45 print "$_ qualityK $a[0] = $a[2]\n";
46 } elsif ( $c eq 'Pr' ) {
47 print "$_ improve (not in cups)\n";
48 } elsif ( $c eq 'Ss' ) {
49 print "$_ encoding download",dump(@a),"\n";
50 } elsif ( $c eq 'Sv' ) {
51 print "$_ even page on duplex printing\n";
52 } elsif ( $c eq 'Sr' ) {
53 print "$_ odd page\n";
54 } elsif ( $c eq 'Db' ) { # XXX not in cups
55 my ( $color, $two, $data ) = @a;
56 print "$c;$color;$two;... bitmap\n";
57 $two eq '2' or die '2';
58 my $path = "$name-Db-$color-$page.pbm"; $page++;
59 save_pbm $path, 648, 1015, $data; # FIXME 1016?
60 } elsif ( $c eq 'Dbc' ) { # XXX not in cups
61 my ( $color, $line, $len, $comp ) = @a;
62 print "$c;$color;$line;$len;... FIXME bitmap - compressed?\n";
63 while ( $len > length($comp) ) {
64 warn "# slurp more ",length($comp), " < $len\n";
67 $len == length $comp or warn "wrong length $len != ", length $comp;
76 while ( $i < length $comp ) {
77 my $len = ord(substr($comp,$i,4));
79 warn "$i comp $len\n";
80 $data .= substr($comp,$i,$len);
81 $data .= "\x00" x ( $w - $len );
89 my $path = "$name-Dbc-$color-$page.pbm"; $page++;
90 my $h = int( $len / 128 );
91 save_pbm $path, $w, $h, $data;
93 } elsif ( $c eq 'Se' ) {
95 print "$_ slurping zero bytes at end ",dump($zero),"\n";
103 my ( $path, $w, $h, $data ) = @_;
104 open(my $pbm, '>', $path);
105 print $pbm "P4\n$w $h\n", $data;
107 print "saved $path $w * $h size ", -s $path, "\n";