@@ -76,11 +76,13 @@ auto Font::ligKern(const GlyphCode glyphCode1, GlyphCode *glyphCode2, FIX16 *ker
7676 * versa)
7777 *
7878 * For 1-bit font resolution:
79+ * - With 24-bit display: Converts to RGB format (0 or 0xFF, 0xFF, 0xFF)
7980 * - With 16-bit display: Converts to RGB565 format (0 or 0xFFFF)
8081 * - With 8-bit display: Converts to grayscale (0 or 0xFF)
8182 * - With 1-bit display: Performs bit-by-bit copy with proper masking
8283 *
8384 * For 8-bit font resolution:
85+ * - With 24-bit display: Converts grayscale to RGB format
8486 * - With 16-bit display: Converts grayscale to RGB565 format
8587 * - With 8-bit display: Direct grayscale copy
8688 *
@@ -127,6 +129,48 @@ void Font::copyBitmap(Bitmap &to, const Bitmap &from, Pos atPos, bool inverted)
127129 }
128130 }
129131 }
132+ } else if (displayPixelResolution_ == PixelResolution::TWENTYFOUR_BITS) {
133+ uint8_t data;
134+ auto fromPtr = from.pixels ;
135+ auto toPtr = to.pixels + static_cast <size_t >((atPos.y * to.pitch ) * 3 );
136+
137+ for (uint16_t fromRow = 0 ; fromRow < from.dim .height ;
138+ fromRow++, toPtr += to.pitch * 3 , fromPtr += from.pitch ) {
139+ int toIdx = atPos.x * 3 ;
140+ int fromIdx = 0 ;
141+ uint8_t fromMask = 0 ;
142+ if (inverted) {
143+ for (uint16_t i = 0 ; i < from.dim .width ; i++) {
144+ if (fromMask == 0 ) {
145+ fromMask = 0x80 ;
146+ data = fromPtr[fromIdx++];
147+ }
148+ if (data & fromMask) {
149+ // Set RGB to white (0xFF, 0xFF, 0xFF)
150+ toPtr[toIdx] = 0xFF ; // R
151+ toPtr[toIdx + 1 ] = 0xFF ; // G
152+ toPtr[toIdx + 2 ] = 0xFF ; // B
153+ }
154+ fromMask >>= 1 ;
155+ toIdx += 3 ;
156+ }
157+ } else {
158+ for (uint16_t i = 0 ; i < from.dim .width ; i++) {
159+ if (fromMask == 0 ) {
160+ fromMask = 0x80 ;
161+ data = fromPtr[fromIdx++];
162+ }
163+ if (data & fromMask) {
164+ // Set RGB to black (0, 0, 0)
165+ toPtr[toIdx] = 0 ; // R
166+ toPtr[toIdx + 1 ] = 0 ; // G
167+ toPtr[toIdx + 2 ] = 0 ; // B
168+ }
169+ fromMask >>= 1 ;
170+ toIdx += 3 ;
171+ }
172+ }
173+ }
130174 } else if (displayPixelResolution_ == PixelResolution::EIGHT_BITS) {
131175 uint8_t data;
132176 auto fromPtr = from.pixels ;
@@ -234,6 +278,35 @@ void Font::copyBitmap(Bitmap &to, const Bitmap &from, Pos atPos, bool inverted)
234278 fromPtr += from.pitch ;
235279 toPtr += to.pitch ;
236280 }
281+ } else if (displayPixelResolution_ == PixelResolution::TWENTYFOUR_BITS) {
282+ auto rowCount = from.dim .height ;
283+ auto fromPtr = from.pixels ;
284+ auto toPtr = &to.pixels [(to.pitch * atPos.y + atPos.x ) * 3 ];
285+ while (rowCount-- > 0 ) {
286+ if (inverted) {
287+ for (uint16_t i = 0 ; i < from.dim .width ; i++) {
288+ if (fromPtr[i] != 0 ) {
289+ // Convert grayscale to RGB
290+ uint8_t val = fromPtr[i];
291+ toPtr[i * 3 ] = val; // R
292+ toPtr[i * 3 + 1 ] = val; // G
293+ toPtr[i * 3 + 2 ] = val; // B
294+ }
295+ }
296+ } else {
297+ for (uint16_t i = 0 ; i < from.dim .width ; i++) {
298+ if (fromPtr[i] != 0 ) {
299+ // Convert inverted grayscale to RGB
300+ uint8_t val = 255 - fromPtr[i];
301+ toPtr[i * 3 ] = val; // R
302+ toPtr[i * 3 + 1 ] = val; // G
303+ toPtr[i * 3 + 2 ] = val; // B
304+ }
305+ }
306+ }
307+ fromPtr += from.pitch ;
308+ toPtr += to.pitch * 3 ;
309+ }
237310 } else if (displayPixelResolution_ == PixelResolution::EIGHT_BITS) {
238311 auto rowCount = from.dim .height ;
239312 auto fromPtr = from.pixels ;
0 commit comments