summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2020-11-18 16:28:21 -0800
committerScott Shawcroft <scott@tannewt.org>2020-11-18 16:32:07 -0800
commit2463a6d6ac3fb53fa471c77bc585c8ef350d2b96 (patch)
tree5478087729ac45b95710021eb5f6b672f0ec0a93 /shared-module
parent8ac9b176c961faf7672f081953de6f78ec3005e2 (diff)
Fix Palette grayscale for EInk.
It needs to do the bitmasking that was only added to ColorConverter in #3611
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/displayio/Palette.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/shared-module/displayio/Palette.c b/shared-module/displayio/Palette.c
index facb1fa73..ba5ff665c 100644
--- a/shared-module/displayio/Palette.c
+++ b/shared-module/displayio/Palette.c
@@ -83,7 +83,8 @@ bool displayio_palette_get_color(displayio_palette_t *self, const _displayio_col
uint8_t pixel_hue = self->colors[palette_index].hue;
displayio_colorconverter_compute_tricolor(colorspace, pixel_hue, luma, color);
} else if (colorspace->grayscale) {
- *color = self->colors[palette_index].luma >> (8 - colorspace->depth);
+ size_t bitmask = (1 << colorspace->depth) - 1;
+ *color = (self->colors[palette_index].luma >> colorspace->grayscale_bit) & bitmask;
} else {
uint16_t packed = self->colors[palette_index].rgb565;
if (colorspace->reverse_bytes_in_word) {