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

Method quantize_internal

src/hist.rs:190–206  ·  view source on GitHub ↗
(&mut self, attr: &Attributes, freeze_result_colors: bool)

Source from the content-addressed store, hash-verified

188
189 #[inline(never)]
190 pub(crate) fn quantize_internal(&mut self, attr: &Attributes, freeze_result_colors: bool) -> Result<QuantizationResult, Error> {
191 if self.hashmap.is_empty() && self.fixed_colors.is_empty() {
192 return Err(Unsupported);
193 }
194
195 if attr.progress(0.) { return Err(Aborted); }
196 if attr.progress(f32::from(attr.progress_stage1) * 0.89) {
197 return Err(Aborted);
198 }
199
200 let gamma = self.gamma.unwrap_or(0.45455);
201 let hist = self.finalize_builder(gamma).map_err(|_| OutOfMemory)?;
202
203 attr.verbose_print(format!(" made histogram...{} colors found", hist.items.len()));
204
205 QuantizationResult::new(attr, hist, freeze_result_colors, gamma)
206 }
207
208 #[inline(always)]
209 fn add_color(&mut self, rgba: RGBA, boost: u32) {

Callers 2

quantizeMethod · 0.80
quantizeMethod · 0.80

Calls 4

newFunction · 0.85
progressMethod · 0.80
finalize_builderMethod · 0.80
verbose_printMethod · 0.80

Tested by

no test coverage detected