Skip to content

Commit 6232e87

Browse files
authored
Merge pull request #9882 from ddrown/24-bit-display
add support for 24 bit color depth
2 parents 27456d5 + 61e44f2 commit 6232e87

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

shared-module/displayio/ColorConverter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ void displayio_convert_color(const _displayio_colorspace_t *colorspace, bool dit
292292
output_color->pixel = (luma >> colorspace->grayscale_bit) & bitmask;
293293
output_color->opaque = true;
294294
return;
295-
} else if (colorspace->depth == 32) {
295+
} else if (colorspace->depth == 32 || colorspace->depth == 24) {
296296
output_color->pixel = pixel;
297297
output_color->opaque = true;
298298
return;

shared-module/displayio/TileGrid.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,6 @@ bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self,
448448
y_shift = temp_shift;
449449
}
450450

451-
uint8_t pixels_per_byte = 8 / colorspace->depth;
452-
453451
displayio_input_pixel_t input_pixel;
454452
displayio_output_pixel_t output_pixel;
455453

@@ -503,9 +501,13 @@ bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self,
503501
*(((uint16_t *)buffer) + offset) = output_pixel.pixel;
504502
} else if (colorspace->depth == 32) {
505503
*(((uint32_t *)buffer) + offset) = output_pixel.pixel;
504+
} else if (colorspace->depth == 24) {
505+
memcpy(((uint8_t *)buffer) + offset * 3, &output_pixel.pixel, 3);
506506
} else if (colorspace->depth == 8) {
507507
*(((uint8_t *)buffer) + offset) = output_pixel.pixel;
508508
} else if (colorspace->depth < 8) {
509+
uint8_t pixels_per_byte = 8 / colorspace->depth;
510+
509511
// Reorder the offsets to pack multiple rows into a byte (meaning they share a column).
510512
if (!colorspace->pixels_in_byte_share_row) {
511513
uint16_t width = displayio_area_width(area);

0 commit comments

Comments
 (0)