diff options
| author | Lucian Copeland <hierophect@gmail.com> | 2020-04-15 10:29:05 -0400 |
|---|---|---|
| committer | Lucian Copeland <hierophect@gmail.com> | 2020-04-15 10:29:05 -0400 |
| commit | 54abfc2e8b88ed0dd1caaf3ac926466b0aba717a (patch) | |
| tree | b5154c84f807ee6ce3b0716b3a8d7b64dca46061 /shared-module/displayio/Bitmap.c | |
| parent | 0f87a75f4f0675ff55e31437907101226d5fb66b (diff) | |
| parent | ae549fc9da555778884ff64a2ffe45df0a5248db (diff) | |
translations-merge
Diffstat (limited to 'shared-module/displayio/Bitmap.c')
| -rw-r--r-- | shared-module/displayio/Bitmap.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/shared-module/displayio/Bitmap.c b/shared-module/displayio/Bitmap.c index 59971d25c..8bcda6086 100644 --- a/shared-module/displayio/Bitmap.c +++ b/shared-module/displayio/Bitmap.c @@ -162,3 +162,24 @@ void displayio_bitmap_finish_refresh(displayio_bitmap_t *self) { self->dirty_area.x1 = 0; self->dirty_area.x2 = 0; } + +void common_hal_displayio_bitmap_fill(displayio_bitmap_t *self, uint32_t value) { + if (self->read_only) { + mp_raise_RuntimeError(translate("Read-only object")); + } + // Update the dirty area. + self->dirty_area.x1 = 0; + self->dirty_area.x2 = self->width; + self->dirty_area.y1 = 0; + self->dirty_area.y2 = self->height; + + // build the packed word + uint32_t word = 0; + for (uint8_t i=0; i<32 / self->bits_per_value; i++) { + word |= (value & self->bitmask) << (32 - ((i+1)*self->bits_per_value)); + } + // copy it in + for (uint32_t i=0; i<self->stride * self->height; i++) { + self->data[i] = word; + } +} |
