Skip to content

Commit 3006464

Browse files
committed
Fix rendering for 1-bit, XTC
1 parent c75992e commit 3006464

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

cli/encoder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function encodeXTG(data, width, height) {
4141
const srcIdx = (y * width + x) * 4;
4242
const gray = data[srcIdx]; // Already grayscale after dithering
4343

44-
if (gray < 128) {
45-
// Black pixel - set bit
44+
if (gray >= 128) {
45+
// White pixel - set bit (per XTG spec: 0=black, 1=white)
4646
const byteIdx = y * rowBytes + Math.floor(x / 8);
4747
const bitIdx = 7 - (x % 8); // MSB first
4848
bitmap[byteIdx] |= (1 << bitIdx);

web/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,8 +1515,8 @@ function encodeXTG(imageData) {
15151515
var srcIdx = (y * width + x) * 4;
15161516
var gray = data[srcIdx]; // Already grayscale after dithering
15171517

1518-
if (gray < 128) {
1519-
// Black pixel - set bit
1518+
if (gray >= 128) {
1519+
// White pixel - set bit (per XTG spec: 0=black, 1=white)
15201520
var byteIdx = y * rowBytes + Math.floor(x / 8);
15211521
var bitIdx = 7 - (x % 8); // MSB first
15221522
bitmap[byteIdx] |= (1 << bitIdx);

0 commit comments

Comments
 (0)