Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
18 changes: 12 additions & 6 deletions shared-module/displayio/ColorConverter.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,12 @@ uint32_t displayio_colorconverter_convert_pixel(displayio_colorspace_t colorspac
pixel = __builtin_bswap16(pixel);
MP_FALLTHROUGH;
case DISPLAYIO_COLORSPACE_RGB555: {
uint32_t r8 = (pixel >> 10) << 3;
uint32_t g8 = ((pixel >> 5) << 3) & 0xff;
uint32_t b8 = (pixel << 3) & 0xff;
uint32_t r8 = (pixel >> 10) & 0x1f;
uint32_t g8 = (pixel >> 5) & 0x1f;
uint32_t b8 = pixel & 0x1f;
r8 = (r8 << 3) | ((r8 >> 2) & 0b111);
g8 = (g8 << 3) | ((g8 >> 2) & 0b111);
b8 = (b8 << 3) | ((b8 >> 2) & 0b111);
pixel = (r8 << 16) | (g8 << 8) | b8;
}
break;
Expand All @@ -219,9 +222,12 @@ uint32_t displayio_colorconverter_convert_pixel(displayio_colorspace_t colorspac
pixel = __builtin_bswap16(pixel);
MP_FALLTHROUGH;
case DISPLAYIO_COLORSPACE_BGR555: {
uint32_t b8 = (pixel >> 10) << 3;
uint32_t g8 = ((pixel >> 5) << 3) & 0xff;
uint32_t r8 = (pixel << 3) & 0xff;
uint32_t b8 = (pixel >> 10) & 0x1f;
uint32_t g8 = (pixel >> 5) & 0x1f;
uint32_t r8 = pixel & 0x1f;
r8 = (r8 << 3) | ((r8 >> 2) & 0b111);
g8 = (g8 << 3) | ((g8 >> 2) & 0b111);
b8 = (b8 << 3) | ((b8 >> 2) & 0b111);
pixel = (r8 << 16) | (g8 << 8) | b8;
}
break;
Expand Down
Loading