Skip to content

Commit

Permalink
Merge pull request #9882 from ddrown/24-bit-display
Browse files Browse the repository at this point in the history
add support for 24 bit color depth
  • Loading branch information
tannewt authored Dec 12, 2024
2 parents 27456d5 + 61e44f2 commit 6232e87
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion shared-module/displayio/ColorConverter.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void displayio_convert_color(const _displayio_colorspace_t *colorspace, bool dit
output_color->pixel = (luma >> colorspace->grayscale_bit) & bitmask;
output_color->opaque = true;
return;
} else if (colorspace->depth == 32) {
} else if (colorspace->depth == 32 || colorspace->depth == 24) {
output_color->pixel = pixel;
output_color->opaque = true;
return;
Expand Down
6 changes: 4 additions & 2 deletions shared-module/displayio/TileGrid.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,6 @@ bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self,
y_shift = temp_shift;
}

uint8_t pixels_per_byte = 8 / colorspace->depth;

displayio_input_pixel_t input_pixel;
displayio_output_pixel_t output_pixel;

Expand Down Expand Up @@ -503,9 +501,13 @@ bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self,
*(((uint16_t *)buffer) + offset) = output_pixel.pixel;
} else if (colorspace->depth == 32) {
*(((uint32_t *)buffer) + offset) = output_pixel.pixel;
} else if (colorspace->depth == 24) {
memcpy(((uint8_t *)buffer) + offset * 3, &output_pixel.pixel, 3);
} else if (colorspace->depth == 8) {
*(((uint8_t *)buffer) + offset) = output_pixel.pixel;
} else if (colorspace->depth < 8) {
uint8_t pixels_per_byte = 8 / colorspace->depth;

// Reorder the offsets to pack multiple rows into a byte (meaning they share a column).
if (!colorspace->pixels_in_byte_share_row) {
uint16_t width = displayio_area_width(area);
Expand Down

0 comments on commit 6232e87

Please sign in to comment.