diff options
| author | Damien George <damien@micropython.org> | 2025-05-26 00:17:56 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-06-04 02:40:45 +1000 |
| commit | b15348415e9d5ad2a978ca38a8da356faee88e91 (patch) | |
| tree | 0ee8d030b11964f8218a46c60addf91024da144e /docs/library | |
| parent | d5f2fc239af2d69407170fa290ba6752c8f1790c (diff) | |
extmod/modframebuf: Add support for blit'ing read-only data.
Currently the `FrameBuffer.blit(buf, x, y)` method requires the `buf`
argument to be another `FrameBuffer`, which is quite restrictive because it
doesn't allow blit'ing read-only memory/data.
This commit extends `blit()` to allow the `buf` argument to be a tuple or
list of the form:
(buffer, width, height, format[, stride])
where `buffer` can be anything with the buffer protocol and may be
read-only, eg `bytes`.
Also, the palette argument to `blit()` may be of the same form.
The form of this tuple/list was chosen to be the same as the signature of
the `FrameBuffer` constructor (that saves quite a bit of code size doing it
that way).
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'docs/library')
| -rw-r--r-- | docs/library/framebuf.rst | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/library/framebuf.rst b/docs/library/framebuf.rst index f22a3613b..e2a231207 100644 --- a/docs/library/framebuf.rst +++ b/docs/library/framebuf.rst @@ -137,6 +137,18 @@ Other methods is compared to the value from *palette*, not to the value directly from *fbuf*.) + *fbuf* can be another FrameBuffer instance, or a tuple or list of the form:: + + (buffer, width, height, format) + + or:: + + (buffer, width, height, format, stride) + + This matches the signature of the FrameBuffer constructor, and the elements + of the tuple/list are the same as the arguments to the constructor except that + the *buffer* here can be read-only. + The *palette* argument enables blitting between FrameBuffers with differing formats. Typical usage is to render a monochrome or grayscale glyph/icon to a color display. The *palette* is a FrameBuffer instance whose format is |
