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

Method add_color

src/hist.rs:209–222  ·  view source on GitHub ↗
(&mut self, rgba: RGBA, boost: u32)

Source from the content-addressed store, hash-verified

207
208 #[inline(always)]
209 fn add_color(&mut self, rgba: RGBA, boost: u32) {
210 if boost == 0 {
211 return;
212 }
213
214 let px_int = if rgba.a != 0 {
215 self.posterize_mask() & unsafe { RGBAInt { rgba }.int }
216 } else { 0 };
217
218 self.hashmap.entry(px_int)
219 // it can overflow on images over 2^24 pixels large
220 .and_modify(move |e| e.0 = e.0.saturating_add(boost))
221 .or_insert((boost, rgba));
222 }
223
224 fn reserve(&mut self, entries: usize) {
225 let new_entries = entries.saturating_sub(self.hashmap.len() / 3); // assume some will be dupes, if called multiple times

Callers 2

add_colorsMethod · 0.80
add_pixel_rowsMethod · 0.80

Calls 1

posterize_maskMethod · 0.80

Tested by

no test coverage detected