material_color_utils/quantize/quantizer.rs
1use crate::utils::color_utils::Argb;
2use indexmap::IndexMap;
3
4/// Represents result of a quantizer run.
5#[derive(Debug, Clone, Default)]
6pub struct QuantizerResult {
7 /// Map with keys of colors in ARGB format, values of how many of the input pixels belong to the color.
8 pub color_to_count: IndexMap<Argb, u32>,
9}
10
11impl QuantizerResult {
12 #[must_use]
13 pub const fn new(color_to_count: IndexMap<Argb, u32>) -> Self {
14 Self { color_to_count }
15 }
16}
17
18/// An interface to allow use of different quantization techniques.
19pub trait Quantizer {
20 fn quantize(&mut self, pixels: &[Argb], max_colors: usize) -> QuantizerResult;
21}