Fix XTC grayscale mapping for dark/light gray pixels

Swap the grayscale values for pixel values 1 and 2 to match the cover's kXthToBmp mapping. Previously 1 mapped to 170 (light gray) and 2 to 85 (dark gray), now corrected to 1->85 (dark gray) and 2->170 (light gray). Use lookup table for clarity.
This commit is contained in:
Justin Mitchell
2026-06-12 16:40:26 -04:00
parent be5ce94c0f
commit 737b22a2df
+4 -3
View File
@@ -432,9 +432,10 @@ bool Xtc::generateThumbBmp(int height) const {
const uint8_t bit1 = (plane1[byteOffset] >> bitInByte) & 1;
const uint8_t bit2 = (plane2[byteOffset] >> bitInByte) & 1;
const uint8_t pixelValue = (bit1 << 1) | bit2;
// Convert 2-bit (0-3) to grayscale: 0=black, 3=white
// pixelValue: 0=white, 1=light gray, 2=dark gray, 3=black (XTC polarity)
grayValue = (3 - pixelValue) * 85; // 0->255, 1->170, 2->85, 3->0
// pixelValue: 0=white, 1=dark gray, 2=light gray, 3=black —
// same semantics as the cover's kXthToBmp mapping above
static constexpr uint8_t kXthToGray[4] = {255, 85, 170, 0};
grayValue = kXthToGray[pixelValue];
}
}
} else {