MCPcopy Create free account
hub / github.com/ImageOptim/libimagequant / from_palette

Method from_palette

src/quant.rs:295–305  ·  view source on GitHub ↗

Shortcut for making [`Histogram`] with `add_fixed_color` Set `gamma` to `0.` for sRGB colors.

(attr: &Attributes, palette: &[RGBA], gamma: f64)

Source from the content-addressed store, hash-verified

293 ///
294 /// Set `gamma` to `0.` for sRGB colors.
295 pub fn from_palette(attr: &Attributes, palette: &[RGBA], gamma: f64) -> Result<Self, Error> {
296 if palette.len() > MAX_COLORS {
297 return Err(Unsupported);
298 }
299
300 let mut hist = Histogram::new(attr);
301 for &c in palette {
302 hist.add_fixed_color(c, gamma)?;
303 }
304 hist.quantize(attr)
305 }
306
307 /// Getter for the value set in [`set_dithering_level`]
308 pub fn dithering_level(&self) -> f32 {

Callers

nothing calls this directly

Calls 4

newFunction · 0.85
lenMethod · 0.45
add_fixed_colorMethod · 0.45
quantizeMethod · 0.45

Tested by

no test coverage detected