#[non_exhaustive]pub enum Samples {
Packed(Packed),
Whole(Pixels),
}Expand description
An image’s samples, in whichever state the decode ladder left them.
The two states are genuinely different things, not one thing with a flag.
Samples::Packed is what every path that does not run a codec of its own
produces: the filter chain’s bytes, still at the dictionary’s
/BitsPerComponent, which the row pipeline widens as it walks
(Unpacked). Samples::Whole is what a codec produced — DCT, JPEG
2000 and JBIG2 all hand back eight-bit samples — together with the two
arms that cannot be lazy at all: a stencil’s bits, and the palettes an
indexed or tint image resolves once.
Nothing widens a packed image until someone asks for whole-image
Pixels, which is Samples::to_pixels and nowhere else.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Packed(Packed)
Still packed, walked by Unpacked.
Whole(Pixels)
Already one byte per component, or a shape that has no packed form.
Implementations§
Source§impl Samples
impl Samples
Sourcepub fn components(&self) -> usize
pub fn components(&self) -> usize
How many components each pixel carries.
Sourcepub fn byte_size(&self) -> usize
pub fn byte_size(&self) -> usize
Bytes held, for the render cache’s budget.
Honest about what is actually held: a packed image is its packed bytes and its decode table, which is what the cache is keeping alive, and is smaller than the widened form it never builds.
Sourcepub const fn is_stencil(&self) -> bool
pub const fn is_stencil(&self) -> bool
Whether these samples are a stencil mask’s bits.
A stencil never has a packed form — its bits are its representation —
so this is a question about the Whole arm alone.
Sourcepub fn palette(&self) -> Option<&[Rgb]>
pub fn palette(&self) -> Option<&[Rgb]>
The resolved palette, when these samples are indices into one.
Only Pixels::Indexed has one; every other representation carries
its colours in the samples themselves.
Sourcepub fn to_pixels(&self) -> Pixels
pub fn to_pixels(&self) -> Pixels
The whole image as Pixels, widening a packed one if it has to.
The one place the full-size buffer the row pipeline exists to avoid is built. Three callers want it and no more: the CLI’s image export, the facade’s edit path, and a test that names the representation.