Trait quantette::ColorCounts
source · pub trait ColorCounts<Color, Component, const N: usize>where
Color: ColorComponents<Component, N>,{
// Required methods
fn colors(&self) -> &[Color];
fn total_count(&self) -> u32;
fn counts(&self) -> Option<&[u32]>;
fn indices(&self) -> Option<&[u32]>;
// Provided methods
fn color_components(&self) -> &[[Component; N]] { ... }
fn num_colors(&self) -> u32 { ... }
fn len(&self) -> usize { ... }
fn is_empty(&self) -> bool { ... }
}Expand description
A generalization trait over regular ColorSlices and deduplicated pixels like UniqueColorCounts.
Required Methods§
sourcefn colors(&self) -> &[Color]
fn colors(&self) -> &[Color]
The slice of colors to quantize.
The colors need not be unique,
but the length of this slice must not be greater than MAX_PIXELS.
sourcefn total_count(&self) -> u32
fn total_count(&self) -> u32
The total number of pixels/colors in the (original) color slice.
For ColorSlices, this is simply the length of the slice.
For deduplicated pixels like UniqueColorCounts,
this is the length of the input ColorSlice before deduplication.
This must be equal to the sum of counts (or num_colors if counts is None).
sourcefn counts(&self) -> Option<&[u32]>
fn counts(&self) -> Option<&[u32]>
The number of pixels corresponding to each Color in the slice returned by colors.
For ColorSlices, this returns None, indicating each Color has a count of 1.
For deduplicated pixels like UniqueColorCounts,
each count indicates the number times each unique color was present in the original color slice.
Each count must be nonzero, and the length of the returned slice (if any)
must have the same length as the slice returned by colors.
As such, the length of this slice must also not be greater than MAX_PIXELS.
sourcefn indices(&self) -> Option<&[u32]>
fn indices(&self) -> Option<&[u32]>
A slice of indices into the color slice returned by colors.
This is used to retain the original color slice/image after deduplication.
The length of this slice must not be greater than MAX_PIXELS,
and each index must be valid index into the slice returned by colors.
Provided Methods§
sourcefn color_components(&self) -> &[[Component; N]]
fn color_components(&self) -> &[[Component; N]]
The slice returned by colors casted to a slice of component arrays.
sourcefn num_colors(&self) -> u32
fn num_colors(&self) -> u32
The length of the slice returned by colors as a u32.