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

source

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.

source

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.

source

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.

source

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.

source

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.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.