From: Dobrica Pavlinusic Date: Mon, 6 Feb 2012 18:29:49 +0000 (+0100) Subject: detect end of bitmap from ~DG total bytes X-Git-Url: http://git.rot13.org/?p=Printer-Zebra.git;a=commitdiff_plain;h=0b31384d80e8b9c07418e71ebb833c6bc81165af;hp=0808a503457e90939e3a767770fb0815c55d6324 detect end of bitmap from ~DG total bytes --- diff --git a/ZPL2pbm.pl b/ZPL2pbm.pl index e312665..ead04d8 100755 --- a/ZPL2pbm.pl +++ b/ZPL2pbm.pl @@ -35,11 +35,20 @@ while( $line ) { my $w = $row_bytes * 2; # hex digits - my $out; + my $out = ''; # ZPL decompress my $repeat = 0; foreach my $p ( 0 .. length($data) - 1 ) { + + if ( length($out) == $total_bytes * 2 ) { + warn "END of bitmap\n"; + $line = substr($data,$p); + slurp_line; + last; + }; + my $c = substr($data,$p,1); + if ( $c eq ',' ) { my $l = $w - ( length($out) % $w ); $l = $w if $l == 0; @@ -70,10 +79,7 @@ while( $line ) { $out .= $c; } } else { - warn "ABORT: offset $p data [$c]"; - $line = $c . substr($data,$p); - slurp_line; - last; + die "ABORT: offset $p data [$c]"; } warn "## $repeat [$c] out = ",length($out),$/;