Skip to content

Commit ce08e69

Browse files
committed
Convert encoders to use rowmult
1 parent c0c25f4 commit ce08e69

29 files changed

+142
-98
lines changed

src/codablockf.ps.src

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -629,11 +629,12 @@ begin
629629
} for
630630

631631
%
632-
% Populate the bitmap
632+
% Populate the bitmap with one copy of each unique row
633633
%
634634
/symwid c 11 mul 57 add def
635635
/symhgt sepheight r 1 add mul r rowheight mul add def
636-
symwid symhgt mul { array } stopped {
636+
/numcomprows r 2 mul 1 add def
637+
symwid numcomprows mul { array } stopped {
637638
pop /bwipp.codablockfSymbolTooLarge (The symbol size exceeds the implementation limits) //raiseerror exec
638639
} if /pixs exch def
639640

@@ -645,44 +646,40 @@ begin
645646
1 1 0 0 0 1 1 1 0 1 0 1 1
646647
] def
647648

648-
/pos 0 def
649+
/rowmult numcomprows array def
650+
/pos 0 def /ri 0 def
649651

650652
% Top separator
651-
sepheight {
652-
pixs pos allone putinterval
653-
/pos pos symwid add def
654-
} repeat
653+
pixs pos allone putinterval
654+
/pos pos symwid add def
655+
rowmult ri sepheight put /ri ri 1 add def
655656

656657
% Data rows with separators
657658
0 1 r 2 sub {
658659
/i exch def
659-
rowheight {
660-
pixs pos rowbits i get putinterval
661-
/pos pos symwid add def
662-
} repeat
663-
sepheight {
664-
pixs pos seprow putinterval
665-
/pos pos symwid add def
666-
} repeat
660+
pixs pos rowbits i get putinterval
661+
/pos pos symwid add def
662+
rowmult ri rowheight put /ri ri 1 add def
663+
pixs pos seprow putinterval
664+
/pos pos symwid add def
665+
rowmult ri sepheight put /ri ri 1 add def
667666
} for
668667

669668
% Last data row
670-
rowheight {
671-
pixs pos rowbits r 1 sub get putinterval
672-
/pos pos symwid add def
673-
} repeat
669+
pixs pos rowbits r 1 sub get putinterval
670+
/pos pos symwid add def
671+
rowmult ri rowheight put /ri ri 1 add def
674672

675673
% Bottom separator
676-
sepheight {
677-
pixs pos allone putinterval
678-
/pos pos symwid add def
679-
} repeat
674+
pixs pos allone putinterval
675+
rowmult ri sepheight put
680676

681677
<<
682678
/ren /renmatrix
683679
/pixs pixs
684680
/pixx symwid
685681
/pixy symhgt
682+
/rowmult rowmult
686683
/height symhgt 72 div
687684
/width symwid 72 div
688685
/physspec physspec

src/code16k.ps.src

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -836,55 +836,52 @@ begin
836836
} for
837837

838838
%
839-
% Populate the bitmap
839+
% Populate the bitmap with one copy of each unique row
840840
%
841841
/symhgt sepheight r 1 add mul r rowheight mul add def
842-
81 symhgt mul { array } stopped {
842+
/numcomprows r 2 mul 1 add def
843+
81 numcomprows mul { array } stopped {
843844
pop /bwipp.code16kSymbolTooLarge (The symbol size exceeds the implementation limits) //raiseerror exec
844845
} if /pixs exch def
845846

846847
% Reusable row templates
847848
/allone [ 81 {1} repeat ] def
848849
/seprow [ 10 {0} repeat 70 {1} repeat 0 ] def
849850

850-
/pos 0 def
851+
/rowmult numcomprows array def
852+
/pos 0 def /ri 0 def
851853

852854
% Top separator
853-
sepheight {
854-
pixs pos allone putinterval
855-
/pos pos 81 add def
856-
} repeat
855+
pixs pos allone putinterval
856+
/pos pos 81 add def
857+
rowmult ri sepheight put /ri ri 1 add def
857858

858859
% Data rows with separators
859860
0 1 r 2 sub {
860861
/i exch def
861-
rowheight {
862-
pixs pos rowbits i get putinterval
863-
/pos pos 81 add def
864-
} repeat
865-
sepheight {
866-
pixs pos seprow putinterval
867-
/pos pos 81 add def
868-
} repeat
862+
pixs pos rowbits i get putinterval
863+
/pos pos 81 add def
864+
rowmult ri rowheight put /ri ri 1 add def
865+
pixs pos seprow putinterval
866+
/pos pos 81 add def
867+
rowmult ri sepheight put /ri ri 1 add def
869868
} for
870869

871870
% Last data row
872-
rowheight {
873-
pixs pos rowbits r 1 sub get putinterval
874-
/pos pos 81 add def
875-
} repeat
871+
pixs pos rowbits r 1 sub get putinterval
872+
/pos pos 81 add def
873+
rowmult ri rowheight put /ri ri 1 add def
876874

877875
% Bottom separator
878-
sepheight {
879-
pixs pos allone putinterval
880-
/pos pos 81 add def
881-
} repeat
876+
pixs pos allone putinterval
877+
rowmult ri sepheight put
882878

883879
<<
884880
/ren /renmatrix
885881
/pixs pixs
886882
/pixx 81
887883
/pixy symhgt
884+
/rowmult rowmult
888885
/height symhgt 72 div
889886
/width 81 72 div
890887
/physspec physspec

src/code49.ps.src

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,25 +1183,35 @@ dup [ exch 16 exch 1 32 getinterval aload pop ] /code49.weighty exch readonly de
11831183
} for
11841184

11851185
%
1186-
% Populate the bitmap
1186+
% Populate the bitmap with one copy of each unique row
11871187
%
1188+
/numcomprows r 2 mul 1 add def
11881189
/pixs [
1189-
81 sepheight mul {1} repeat
1190+
81 {1} repeat
11901191
0 1 r 2 sub {
11911192
/i exch def
1192-
rowheight {rowbits i get aload pop} repeat
1193-
sepheight {10 {0} repeat 70 {1} repeat 0} repeat
1193+
rowbits i get aload pop
1194+
10 {0} repeat 70 {1} repeat 0
11941195
} for
1195-
rowheight {rowbits r 1 sub get aload pop} repeat
1196-
81 sepheight mul {1} repeat
1196+
rowbits r 1 sub get aload pop
1197+
81 {1} repeat
1198+
] def
1199+
/symhgt sepheight r 1 add mul r rowheight mul add def
1200+
1201+
/rowmult [
1202+
sepheight
1203+
0 1 r 2 sub { pop rowheight sepheight } for
1204+
rowheight
1205+
sepheight
11971206
] def
11981207

11991208
<<
12001209
/ren /renmatrix
12011210
/pixs pixs
12021211
/pixx 81
1203-
/pixy pixs length 81 idiv
1204-
/height pixs length 81 idiv 72 div
1212+
/pixy symhgt
1213+
/rowmult rowmult
1214+
/height symhgt 72 div
12051215
/width 81 72 div
12061216
/physspec physspec
12071217
/xdim xdim

src/databarexpanded.ps.src

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -957,28 +957,38 @@ begin
957957
sep pixx 4 sub //databarexpanded.seppad putinterval
958958

959959
%
960-
% Compose the symbol
960+
% Compose the symbol with one copy of each unique row
961961
%
962962
/pixs [
963963
0 1 numrows 1 sub {
964964
/r exch def
965965
r 0 ne {
966966
seps r get aload pop
967967
} if
968-
barxmult {rows r get aload pop} repeat
968+
rows r get aload pop
969969
r numrows 1 sub ne {
970970
seps r get aload pop
971971
sep aload pop
972972
} if
973973
} for
974974
] def
975+
/rowmult [
976+
0 1 numrows 1 sub {
977+
/r exch def
978+
r 0 ne { 1 } if
979+
barxmult
980+
r numrows 1 sub ne { 1 1 } if
981+
} for
982+
] def
983+
/pixy 0 rowmult {add} forall def
975984

976985
<<
977986
/ren /renmatrix
978987
/pixs pixs
979988
/pixx pixx
980-
/pixy pixs length pixx idiv
981-
/height pixs length pixx idiv 72 div
989+
/pixy pixy
990+
/rowmult rowmult
991+
/height pixy 72 div
982992
/width pixx 72 div
983993
/borderleft 0.0
984994
/borderright 0.0

src/databarexpandedcomposite.ps.src

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,17 @@ begin
155155
/sep [ 0 sep aload pop ] def % Offset by 1
156156

157157
/linheight linheight cvi def
158+
/ccrows ccpixs length ccpixx idiv def
158159
/diff linpixs length ccpixx sub def % Minimum linpixs length is 102, ccpixx is 99
159160
/ccrpad [ diff 2 sub {0} repeat ] def
160161
/pixs [
161162
0 ccpixx ccpixs length 1 sub {
162163
/i exch def
163164
0 0 ccpixs i ccpixx getinterval aload pop ccrpad aload pop
164165
} for
165-
sep aload pop linheight { linpixs aload pop } repeat
166+
sep aload pop linpixs aload pop
166167
] def
168+
/rowmult [ ccrows { 1 } repeat 1 linheight ] def
167169

168170
/pixx linpixs length def
169171

@@ -173,7 +175,7 @@ begin
173175
} forall } { pop pop } ifelse
174176
] def
175177

176-
/pixy pixs length pixx idiv def
178+
/pixy ccrows 1 add linheight add def
177179

178180
/borderleft
179181
linsym /borderleft 2 copy known { get } { pop pop 10 } ifelse pixx linpixs length sub 1 add sub
@@ -193,6 +195,7 @@ begin
193195
/pixs pixs
194196
/pixx pixx
195197
/pixy pixy
198+
/rowmult rowmult
196199
/height pixy 72 div
197200
/width pixx 72 div
198201
/borderleft borderleft

src/databarexpandedstackedcomposite.ps.src

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ begin
118118
dup (pixy) get /linheight exch def
119119
/linsym exch def
120120
/linpixs linsym /pixs get def
121+
/linrowmult linsym /rowmult get def
121122

122123
%
123124
% Plot the separator
@@ -153,21 +154,23 @@ begin
153154
/pixx sep length def
154155
/cclpad [ pixx ccpixx sub 1 add 2 idiv {0} repeat ] def % Add 1 to allow for odd difference
155156
/ccrpad [ pixx ccpixx sub 2 idiv {0} repeat ] def
157+
/ccrows ccpixs length ccpixx idiv def
156158
/pixs [
157159
0 ccpixx ccpixs length 1 sub { % Centre align composite
158160
/i exch def
159161
cclpad aload pop ccpixs i ccpixx getinterval aload pop ccrpad aload pop
160162
} for
161163
sep aload pop linpixs aload pop
162164
] def
165+
/rowmult [ ccrows { 1 } repeat 1 linrowmult aload pop ] def
163166

164167
/txt [
165168
linsym /txt 2 copy known { get {
166169
aload pop 5 array astore % No x offset needed; linear at column 0
167170
} forall } { pop pop } ifelse
168171
] def
169172

170-
/pixy pixs length pixx idiv def
173+
/pixy 0 rowmult {add} forall def
171174

172175
% Quiet zone borders: T=2D, L/R=max(1D,2D), B=1D
173176
/borderleft
@@ -188,6 +191,7 @@ begin
188191
/pixs pixs
189192
/pixx pixx
190193
/pixy pixy
194+
/rowmult rowmult
191195
/height pixy 72 div
192196
/width pixx 72 div
193197
/borderleft borderleft

src/databarlimitedcomposite.ps.src

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,15 @@ begin
139139
/sep [ 0 sep 0 linpixs length 1 sub getinterval aload pop ] def % Offset by 1; trim to match
140140

141141
/linheight linheight cvi def
142+
/ccrows ccpixs length ccpixx idiv def
142143
% ccpixx is 72 for CC-A and 82 for CC-B; linpixs length is 74
143144
ccpixx 72 eq { % 3-col CC-A
144145
/pixs [
145146
0 ccpixx ccpixs length 1 sub { % Left pad composite with 1 space & right pad with 1 space
146147
/i exch def
147148
0 ccpixs i ccpixx getinterval aload pop 0
148149
} for
149-
sep aload pop linheight { linpixs aload pop } repeat
150+
sep aload pop linpixs aload pop
150151
] def
151152
/pixx linpixs length def % 74
152153
} { % 3-col CC-B
@@ -155,18 +156,19 @@ begin
155156
/i exch def
156157
ccpixs i ccpixx getinterval aload pop 0
157158
} for
158-
0 0 0 0 0 0 0 0 0 sep aload pop linheight { 0 0 0 0 0 0 0 0 0 linpixs aload pop } repeat % Left pad with 9 spaces
159+
0 0 0 0 0 0 0 0 0 sep aload pop 0 0 0 0 0 0 0 0 0 linpixs aload pop % Left pad with 9 spaces
159160
] def
160161
/pixx ccpixx 1 add def % 83
161162
} ifelse
163+
/rowmult [ ccrows { 1 } repeat 1 linheight ] def
162164

163165
/txt [
164166
linsym /txt 2 copy known { get {
165167
aload pop 4 -1 roll pixx linpixs length sub 1 add add 4 1 roll 5 array astore
166168
} forall } { pop pop } ifelse
167169
] def
168170

169-
/pixy pixs length pixx idiv def
171+
/pixy ccrows 1 add linheight add def
170172

171173
/borderleft
172174
linsym /borderleft 2 copy known { get } { pop pop 10 } ifelse pixx linpixs length sub 1 add sub
@@ -186,6 +188,7 @@ begin
186188
/pixs pixs
187189
/pixx pixx
188190
/pixy pixy
191+
/rowmult rowmult
189192
/height pixy 72 div
190193
/width pixx 72 div
191194
/borderleft borderleft

0 commit comments

Comments
 (0)