From 8498e7f2cd896cf92c2fe17f7d8601ce9fff41b2 Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Wed, 29 Jul 2020 23:35:45 +0200 Subject: [PATCH] Fix inability to set values in 32-bit Bitmap. --- shared-bindings/displayio/Bitmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 65d80fba62..0a45bbdfdb 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -163,8 +163,8 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val // load return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_bitmap_get_pixel(self, x, y)); } else { - mp_int_t value = mp_obj_get_int(value_obj); - if (value >= 1 << common_hal_displayio_bitmap_get_bits_per_value(self)) { + mp_uint_t value = (mp_uint_t)mp_obj_get_int(value_obj); + if ((value >> common_hal_displayio_bitmap_get_bits_per_value(self)) != 0) { mp_raise_ValueError(translate("pixel value requires too many bits")); } common_hal_displayio_bitmap_set_pixel(self, x, y, value); @@ -179,8 +179,8 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val STATIC mp_obj_t displayio_bitmap_obj_fill(mp_obj_t self_in, mp_obj_t value_obj) { displayio_bitmap_t *self = MP_OBJ_TO_PTR(self_in); - mp_int_t value = mp_obj_get_int(value_obj); - if (value >= 1 << common_hal_displayio_bitmap_get_bits_per_value(self)) { + mp_uint_t value = (mp_uint_t)mp_obj_get_int(value_obj); + if ((value >> common_hal_displayio_bitmap_get_bits_per_value(self)) != 0) { mp_raise_ValueError(translate("pixel value requires too many bits")); } common_hal_displayio_bitmap_fill(self, value);