Struct imagequant::Histogram
source · pub struct Histogram { /* private fields */ }
Expand description
Generate one shared palette for multiple images
If you’re converting one image at a time, see Attributes::new_image
instead
Implementations§
source§impl Histogram
impl Histogram
sourcepub fn new(attr: &Attributes) -> Self
pub fn new(attr: &Attributes) -> Self
Creates histogram object that will be used to collect color statistics from multiple images.
All options should be set on attr
before the histogram object is created. Options changed later may not have effect.
sourcepub fn add_image(
&mut self,
attr: &Attributes,
image: &mut Image<'_>,
) -> Result<(), Error>
pub fn add_image( &mut self, attr: &Attributes, image: &mut Image<'_>, ) -> Result<(), Error>
“Learns” colors from the image, which will be later used to generate the palette.
Fixed colors added to the image are also added to the histogram. If the total number of fixed colors exceeds 256,
this function will fail with LIQ_BUFFER_TOO_SMALL
.
sourcepub fn add_colors(
&mut self,
entries: &[HistogramEntry],
gamma: f64,
) -> Result<(), Error>
pub fn add_colors( &mut self, entries: &[HistogramEntry], gamma: f64, ) -> Result<(), Error>
Alternative to add_image()
. Intead of counting colors in an image, it directly takes an array of colors and their counts.
This function is only useful if you already have a histogram of the image from another source.
The gamma may be 0 to mean sRGB. All calls to add_colors
and add_fixed_color
should use the same gamma value.
sourcepub fn add_fixed_color(&mut self, rgba: RGBA, gamma: f64) -> Result<(), Error>
pub fn add_fixed_color(&mut self, rgba: RGBA, gamma: f64) -> Result<(), Error>
Add a color guaranteed to be in the final palette
The gamma may be 0 to mean sRGB. All calls to add_colors
and add_fixed_color
should use the same gamma value.
sourcepub fn quantize(
&mut self,
attr: &Attributes,
) -> Result<QuantizationResult, Error>
pub fn quantize( &mut self, attr: &Attributes, ) -> Result<QuantizationResult, Error>
Generate palette for all images/colors added to the histogram.
Palette generated using this function won’t be improved during remapping.
If you’re generating palette for only one image, it’s better not to use the Histogram
.