projects
/
Printer-Zebra.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
10b7a07
)
rename variables for better understaning of code
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Mon, 6 Feb 2012 18:15:18 +0000
(19:15 +0100)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Mon, 6 Feb 2012 18:15:18 +0000
(19:15 +0100)
ZPL2pbm.pl
patch
|
blob
|
history
diff --git
a/ZPL2pbm.pl
b/ZPL2pbm.pl
index
692fb66
..
e312665
100755
(executable)
--- a/
ZPL2pbm.pl
+++ b/
ZPL2pbm.pl
@@
-27,29
+27,32
@@
while( $line ) {
$line =~ s/[\r\n]+$// && warn "## removed CR/LF\n";
warn "# line ",dump($line),$/ if length($line) < 80 or $ENV{DEBUG};
if ( $line =~ s/~DG(\w+:)?(.+)// ) {
$line =~ s/[\r\n]+$// && warn "## removed CR/LF\n";
warn "# line ",dump($line),$/ if length($line) < 80 or $ENV{DEBUG};
if ( $line =~ s/~DG(\w+:)?(.+)// ) {
- my ( $name, $t
,$w
) = split(/,/,$2,4);
+ my ( $name, $t
otal_bytes, $row_bytes
) = split(/,/,$2,4);
- warn "# ~DG$1 => [$name]
t=$t w=$
w\n";
+ warn "# ~DG$1 => [$name]
$total_bytes bytes $row_bytes in ro
w\n";
my $data = <$in>;
my $data = <$in>;
+ my $w = $row_bytes * 2; # hex digits
+
my $out;
# ZPL decompress
my $repeat = 0;
foreach my $p ( 0 .. length($data) - 1 ) {
my $c = substr($data,$p,1);
if ( $c eq ',' ) {
my $out;
# ZPL decompress
my $repeat = 0;
foreach my $p ( 0 .. length($data) - 1 ) {
my $c = substr($data,$p,1);
if ( $c eq ',' ) {
- my $l =
( $w * 2 ) - length($out) % ( $w * 2
);
- $l = $w
* 2
if $l == 0;
+ my $l =
$w - ( length($out) % $w
);
+ $l = $w if $l == 0;
warn "# $p ZERO-to-EOL $c [$l]\n";
$out .= "0" x $l;
} elsif ( $c eq '!' ) {
warn "# $p ZERO-to-EOL $c [$l]\n";
$out .= "0" x $l;
} elsif ( $c eq '!' ) {
- my $l =
( $w * 2 ) - length($out) % ( $w * 2
);
- $l = $w
* 2
if $l == 0;
+ my $l =
$w - ( length($out) % $w
);
+ $l = $w if $l == 0;
warn "# $p ONE-to-EOL $c [$l]\n";
$out .= "F" x $l;
} elsif ( $c eq ':' ) {
warn "# $p ONE-to-EOL $c [$l]\n";
$out .= "F" x $l;
} elsif ( $c eq ':' ) {
- $out .= length($out) > $w ? substr($out,-$w*2) : "00" x $w;
+# $out .= length($out) > $w ? substr($out,-$w) : "0" x $w;
+ $out .= substr($out,-$w);
warn "# $p repeat last line\n";
} elsif ( $c eq 'z' ) {
$repeat += 400;
warn "# $p repeat last line\n";
} elsif ( $c eq 'z' ) {
$repeat += 400;
@@
-78,9
+81,9
@@
while( $line ) {
my $bitmap = pack('H*', $out);
warn "# graphics of ",length($data)," bytes ZPL decompressed to ",length($out)," hex and ", length($bitmap), " bytes bitmap\n";
my $bitmap = pack('H*', $out);
warn "# graphics of ",length($data)," bytes ZPL decompressed to ",length($out)," hex and ", length($bitmap), " bytes bitmap\n";
- my $pw = $
w
* 8;
- my $ph = int(length($bitmap) / $
w
);
- print "P4\n$pw $ph\n", substr($bitmap,0,$ph*$
w
);
+ my $pw = $
row_bytes
* 8;
+ my $ph = int(length($bitmap) / $
row_bytes
);
+ print "P4\n$pw $ph\n", substr($bitmap,0,$ph*$
row_bytes
);
} elsif ( $line =~ s/^([~\^][^~\^\r\n]*)// ) {
my $cmd = substr($1,0,3);
} elsif ( $line =~ s/^([~\^][^~\^\r\n]*)// ) {
my $cmd = substr($1,0,3);