[][src]Struct pix::Palette

pub struct Palette<F> where
    F: Format<Chan = Ch8>, 
{ /* fields omitted */ }

Color table for use with indexed Rasters.

Methods

impl<F> Palette<F> where
    F: Format<Chan = Ch8>, 
[src]

pub fn new(capacity: usize) -> Self[src]

Create a new color Palette.

  • capacity Maximum number of entries.

pub fn len(&self) -> usize[src]

Get the number of entries.

pub fn set_threshold_fn(&mut self, threshold_fn: fn(_: usize) -> F)[src]

Set the threshold function for matching entries.

  • threshold_fn Called when checking whether a color matches an existing entry. The parameter is the palette table size. Returns the maximum Channel-wise difference to match.

pub fn as_u8_slice(&self) -> &[u8][src]

Get view of Palette as a u8 slice.

pub fn entry(&self, i: usize) -> Option<F>[src]

Get a Palette entry.

  • i Index of entry.

pub fn set_entry(&mut self, clr: F) -> Option<usize>[src]

Set a Palette entry.

The table is searched for the best matching color within the threshold. If none found, a new entry is added.

  • clr Color to lookup or add.

Returns

Index of best matching or added entry if successful. Otherwise, when no matches are found and the table is full, None is returned.

pub fn replace_entry(&mut self, i: usize, clr: F) -> Option<F>[src]

Replace a Palette entry.

  • i Index of entry.
  • clr Color to replace entry with.

Returns

Previous entry, or None if index is larger than table size.

pub fn histogram<T>(&self, ent: &[T]) -> Option<Vec<usize>> where
    T: Copy,
    usize: From<T>, 
[src]

Create a histogram of Palette entries.

  • ent Slice of entry indices (pixel values).

Trait Implementations

impl<F: Clone> Clone for Palette<F> where
    F: Format<Chan = Ch8>, 
[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<F> Sync for Palette<F> where
    F: Sync

impl<F> Unpin for Palette<F> where
    F: Unpin

impl<F> Send for Palette<F> where
    F: Send

impl<F> UnwindSafe for Palette<F> where
    F: UnwindSafe

impl<F> RefUnwindSafe for Palette<F> where
    F: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]