diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2018-08-31 14:21:48 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2018-08-31 14:21:48 -0700 |
| commit | 121903b6eeb9712cae86a24c5fe82cb7b144e504 (patch) | |
| tree | e3069df09931554476226b8025b277655a4c777d /shared-module/displayio/Bitmap.c | |
| parent | 6697544cdf87d0df5b761d401ad6ffe3a8d752fc (diff) | |
Tweaks based on feedback
Diffstat (limited to 'shared-module/displayio/Bitmap.c')
| -rw-r--r-- | shared-module/displayio/Bitmap.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/shared-module/displayio/Bitmap.c b/shared-module/displayio/Bitmap.c index 7c6a2ee80..453dc1c59 100644 --- a/shared-module/displayio/Bitmap.c +++ b/shared-module/displayio/Bitmap.c @@ -56,7 +56,7 @@ void common_hal_displayio_bitmap_construct(displayio_bitmap_t *self, uint32_t wi } void common_hal_displayio_bitmap_load_row(displayio_bitmap_t *self, uint16_t y, uint8_t* data, uint16_t len) { - if (len != self->stride * 4) { + if (len != self->stride * sizeof(uint32_t)) { mp_raise_ValueError(translate("row must be packed and word aligned")); } uint32_t* row_value = self->data + (y * self->stride); @@ -77,6 +77,9 @@ void common_hal_displayio_bitmap_load_row(displayio_bitmap_t *self, uint16_t y, } } uint32_t common_hal_displayio_bitmap_get_pixel(displayio_bitmap_t *self, int16_t x, int16_t y) { + if (x >= self->width || x < 0 || y >= self->height || y < 0) { + return 0; + } int32_t row_start = y * self->stride; if (self->bits_per_value < 8) { uint32_t word = self->data[row_start + (x >> self->x_shift)]; |
