Skip to content

Commit 0bb649f

Browse files
committed
dotcode: Resolve the codeword placement walk once and share it between masks
1 parent 91dd68a commit 0bb649f

1 file changed

Lines changed: 38 additions & 22 deletions

File tree

src/dotcode.ps.src

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,38 @@ begin
11531153
fast { [ 2#11 2#10 2#01 2#00 ] } { [ 2#00 2#01 2#10 2#11 ] } ifelse
11541154
} ifelse def
11551155
/litmasks 4 array def
1156+
1157+
%
1158+
% The walk visits vacant positions in an order that is independent of the
1159+
% mask, so resolve the position sequence once and share it between masks
1160+
%
1161+
(matrix.layout.walk) //dotcode.before exec
1162+
/dataposs ndots 6 sub array def
1163+
/scratch outline dup length array copy def
1164+
/posx 0 def
1165+
/posy rows 2 mod 0 eq {0} {rows 1 sub} ifelse def
1166+
0 1 dataposs length 1 sub {
1167+
/i exch def
1168+
{ % Move to next vacant position
1169+
scratch posx posy dmv get -1 eq {exit} if
1170+
rows 2 mod 0 eq {
1171+
/posy posy 1 add def
1172+
posy rows eq {
1173+
/posy 0 def
1174+
/posx posx 1 add def
1175+
} if
1176+
} {
1177+
/posx posx 1 add def
1178+
posx columns eq {
1179+
/posx 0 def
1180+
/posy posy 1 sub def
1181+
} if
1182+
} ifelse
1183+
} loop
1184+
dataposs i posx posy dmv put
1185+
scratch posx posy dmv 0 put
1186+
} for
1187+
(matrix.layout.walk) //dotcode.after exec
11561188
masks { % For each mask pattern
11571189

11581190
/mask exch def
@@ -1214,30 +1246,14 @@ begin
12141246
} if
12151247

12161248
%
1217-
% Walk the symbol placing the bitstream
1249+
% Place the bitstream at the pre-resolved walk positions
12181250
%
12191251
/pixs outline dup length array copy def
1220-
/posx 0 def
1221-
/posy rows 2 mod 0 eq {0} {rows 1 sub} ifelse def
1222-
bits 0 bits length 6 sub getinterval {
1223-
{ % Move to next vacant position
1224-
pixs posx posy dmv get -1 eq {exit} if
1225-
rows 2 mod 0 eq {
1226-
/posy posy 1 add def
1227-
posy rows eq {
1228-
/posy 0 def
1229-
/posx posx 1 add def
1230-
} if
1231-
} {
1232-
/posx posx 1 add def
1233-
posx columns eq {
1234-
/posx 0 def
1235-
/posy posy 1 sub def
1236-
} if
1237-
} ifelse
1238-
} loop
1239-
pixs posx posy dmv 3 -1 roll 48 sub put
1240-
} forall
1252+
0 1 ndots 7 sub { % i
1253+
dup dataposs exch get % i pos
1254+
exch bits exch get 48 sub % pos bit
1255+
pixs 3 1 roll put
1256+
} for
12411257
0 1 5 { % Last six edge dots
12421258
/i exch def
12431259
pixs sixedges i get aload pop dmv

0 commit comments

Comments
 (0)