Skip to content

Commit 81d0c5e

Browse files
authored
Merge pull request #82 from u8array/fix/gfa-opacity
fix(parser): render ^GFA zero-bits as transparent, not opaque white
2 parents 9bbe10b + a4c159c commit 81d0c5e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎src/lib/zplParser.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,11 +1158,12 @@ export function parseZPL(zpl: string, dpmm = 8): ParsedZPL {
11581158
for (let bit = 0; bit < 8; bit++) {
11591159
const px = byteIdx * 8 + bit;
11601160
const idx = (row * gfWidthDots + px) * 4;
1161-
const isBlack = (byte & (0x80 >> bit)) !== 0;
1162-
pixels[idx] = isBlack ? 0 : 255;
1163-
pixels[idx + 1] = isBlack ? 0 : 255;
1164-
pixels[idx + 2] = isBlack ? 0 : 255;
1165-
pixels[idx + 3] = 255;
1161+
// ZPL ^GF: 1-bit = black (printed), 0-bit = transparent.
1162+
// ImageData starts zero-filled (rgba(0,0,0,0)), which is exactly
1163+
// the 0-bit case — only the 1-bit case needs a write.
1164+
if ((byte & (0x80 >> bit)) !== 0) {
1165+
pixels[idx + 3] = 255;
1166+
}
11661167
}
11671168
}
11681169
}

0 commit comments

Comments
 (0)