Skip to content

add support for 24 bit color depth #9882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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