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

Method add_fixed_color

src/image.rs:209–214  ·  view source on GitHub ↗

Reserves a color in the output palette created from this image. It behaves as if the given color was used in the image and was very important. The RGB values are assumed to have the same gamma as the image. It must be called before the image is quantized. Returns error if more than 256 colors are added. If image is quantized to fewer colors than the number of fixed colors added, then excess fix

(&mut self, color: RGBA)

Source from the content-addressed store, hash-verified

207 ///
208 /// Returns error if more than 256 colors are added. If image is quantized to fewer colors than the number of fixed colors added, then excess fixed colors will be ignored.
209 pub fn add_fixed_color(&mut self, color: RGBA) -> Result<(), Error> {
210 if self.fixed_colors.len() >= MAX_COLORS { return Err(Unsupported); }
211 self.fixed_colors.try_reserve(1)?;
212 self.fixed_colors.push_in_cap(color);
213 Ok(())
214 }
215
216 /// Width of the image in pixels
217 #[must_use]

Callers

nothing calls this directly

Calls 2

push_in_capMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected