The Pixel module provides shared types and drawing primitives for software framebuffers and display-backed surfaces.
More...
|
| | Bitmap |
| | A bitmap is a plain, backend-agnostic pixel buffer descriptor - see pix_bitmap_t's own doc.
|
| |
| | Display |
| | Displays can be created by a backend, which returns a pix_display_t handle.
|
| |
|
| file | color.h |
| | RGBA color type and helpers.
|
| |
|
| bool | pix_poll (void) |
| | Service whichever allocated display needs updating. More...
|
| |
The Pixel module provides shared types and drawing primitives for software framebuffers and display-backed surfaces.
◆ PIX_COLOR_RGBA
| #define PIX_COLOR_RGBA |
( |
|
r, |
|
|
|
g, |
|
|
|
b, |
|
|
|
a |
|
) |
| |
Value: ((uint32_t)(uint8_t)(g) << 16) | \
((uint32_t)(uint8_t)(b) << 8) | \
(uint32_t)(uint8_t)(a)))
uint32_t pix_color_t
Color value type for pixel operations.
Construct a pix_color_t from separate R/G/B/A components.
Definition at line 46 of file color.h.
◆ pix_color_t
Color value type for pixel operations.
Encoded as 0xRRGGBBAA (red in the most-significant byte, alpha in the least-significant byte). This is independent of any particular storage layout (e.g. a bitmap's own pixel format) - it's how a single color is passed around, not how a buffer of pixels is packed in memory.
Definition at line 17 of file color.h.
◆ pix_format_t
Pixel format enumeration defining color depth and layout.
| Enumerator |
|---|
| PIX_FMT_RGBA32 | 32-bit RGBA format with alpha channel
|
| PIX_FMT_RGB888 | 24-bit RGB format without alpha channel
|
| PIX_FMT_RGB565 | 16-bit RGB format without alpha channel
|
| PIX_FMT_MONO | Monochrome format (1-bit per pixel)
|
Definition at line 35 of file types.h.
16-bit RGB format without alpha channel
24-bit RGB format without alpha channel
Monochrome format (1-bit per pixel)
pix_format_t
Pixel format enumeration defining color depth and layout.
32-bit RGBA format with alpha channel
◆ pix_op_t
Compositing mode for drawing operations.
| Enumerator |
|---|
| PIX_SET | Overwrite the destination outright with the drawn color as given, alpha channel included - no compositing against the destination's previous color.
|
| PIX_BLEND | Alpha-composite the drawn color over the destination's existing color ("src over dst") - see pix_color_blend.
|
Definition at line 46 of file types.h.
Alpha-composite the drawn color over the destination's existing color ("src over dst") - see pix_colo...
Overwrite the destination outright with the drawn color as given, alpha channel included - no composi...
pix_op_t
Compositing mode for drawing operations.
◆ pix_color_blend()
Alpha-composite src over dst ("over" compositing).
- Parameters
-
| src | The color being drawn. |
| dst | The color already there. |
- Returns
- The blended color. Exactly
src when src is fully opaque, exactly dst when src is fully transparent - callers on a hot path may want to special-case those rather than call this.
Definition at line 99 of file color.h.
102 uint32_t ia = 255u - sa;
109 uint32_t out_a = sa + (da * ia + 127u) / 255u;
114 uint32_t denom = out_a * 255u;
115 uint32_t half = denom / 2u;
116 uint8_t r = (uint8_t)((
pix_color_r(src) * sa * 255u +
118 uint8_t g = (uint8_t)((
pix_color_g(src) * sa * 255u +
120 uint8_t b = (uint8_t)((
pix_color_b(src) * sa * 255u +
static uint8_t pix_color_b(pix_color_t color)
Extract the blue channel.
static uint8_t pix_color_a(pix_color_t color)
Extract the alpha channel.
static uint8_t pix_color_r(pix_color_t color)
Extract the red channel.
#define PIX_COLOR_NONE
Fully transparent (all channels zero) - a "no color" sentinel, distinct from the opaque PIX_COLOR_BLA...
#define PIX_COLOR_RGBA(r, g, b, a)
Construct a pix_color_t from separate R/G/B/A components.
static uint8_t pix_color_g(pix_color_t color)
Extract the green channel.
◆ pix_poll()
Service whichever allocated display needs updating.
- Returns
true if a display is found and polled.
Call this from the application's own main loop. It picks the next display which needs updated, polls it, and - if its backend reports it's due a redraw and a draw callback is registered (see pix_display_set_callback()) - locks it, runs the callback, and unlocks it again.