diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-05-23 12:44:33 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-05-24 13:19:04 (GMT) |
| commit | 57999226fdf8e36021c37478730084424947f604 (patch) | |
| tree | 781579b99bd02fcde479ba8e785ef8289735e3f9 /wasp/draw565.py | |
| parent | f56cf0e6d1e9d4b6ce5617c37d9c8030816dd767 (diff) | |
draw565: rle2bit: Add support for palette overrides
This allows some interesting manipulations of 2-bit images.
Diffstat (limited to 'wasp/draw565.py')
| -rw-r--r-- | wasp/draw565.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/wasp/draw565.py b/wasp/draw565.py index 21b23ed..2e248b4 100644 --- a/wasp/draw565.py +++ b/wasp/draw565.py @@ -130,7 +130,7 @@ class Draw565(object): self._display.fill(bg, x, y, w, h) @micropython.native - def blit(self, image, x, y): + def blit(self, image, x, y, fg=0xffff, c1=0x4a69, c2=0x7bef): """Decode and draw an encoded image. :param image: Image data in either 1-bit RLE or 2-bit RLE formats. The @@ -140,10 +140,10 @@ class Draw565(object): """ if len(image) == 3: # Legacy 1-bit image - self.rleblit(image, (x, y)) + self.rleblit(image, (x, y), fg) else: #elif image[0] == 2: # 2-bit RLE image, (255x255, v1) - self._rle2bit(image, x, y) + self._rle2bit(image, x, y, fg, c1, c2) @micropython.native def rleblit(self, image, pos=(0, 0), fg=0xffff, bg=0): @@ -179,7 +179,7 @@ class Draw565(object): color = bg @micropython.native - def _rle2bit(self, image, x, y): + def _rle2bit(self, image, x, y, fg, c1, c2): """Decode and draw a 2-bit RLE image.""" display = self._display quick_write = display.quick_write @@ -193,7 +193,7 @@ class Draw565(object): sx *= 2 sy //= 2 - palette = array.array('H', (0, 0x4a69, 0x7bef, 0xffff)) + palette = array.array('H', (0, c1, c2, fg)) next_color = 1 rl = 0 buf = memoryview(display.linebuffer)[0:2*sx] |
