Expand description
Pixel formats and the packed-pixel newtype.
Format is the crate’s only source of truth for channel layout. It is
a plain value with private fields, so a caller cannot build an
inconsistent format (mask without shift, or the reverse) by accident.
Colour conversion happens only through Format::pack,
Format::unpack and Format::convert. Bulk blits require identical
formats; the conversion path is explicit and therefore visible at the
call site, which is exactly what the old CanvasBuffer::blit_rect
(packed XRGB in, native-format screen out) made impossible to see.
Structs§
- Format
- Native pixel layout of a contiguous surface.
- Packed
- A pixel already encoded in a
Format, with no implicit conversion. - Rgb
- An 8-bit-per-channel RGB triple, used at the boundaries.
Functions§
- channel_
is_ 🔒valid - A channel is a contiguous run of ones at exactly
shift. An empty mask has no shift, and any other shift would makeFormat::packoverflow. - channel_
to_ 🔒u8 - Extract one channel and scale it to 8 bits.
- mask_
fits 🔒 - A mask must not use bits above the pixel width.