[−][src]Struct pix::Palette
Color table for use with indexed Raster
s.
Methods
impl<F> Palette<F> where
F: Format<Chan = Ch8>,
[src]
F: Format<Chan = Ch8>,
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 maximumChannel
-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]
T: Copy,
usize: From<T>,
Create a histogram of Palette
entries.
ent
Slice of entry indices (pixel values).
Trait Implementations
Auto Trait Implementations
impl<F> Sync for Palette<F> where
F: Sync,
F: Sync,
impl<F> Unpin for Palette<F> where
F: Unpin,
F: Unpin,
impl<F> Send for Palette<F> where
F: Send,
F: Send,
impl<F> UnwindSafe for Palette<F> where
F: UnwindSafe,
F: UnwindSafe,
impl<F> RefUnwindSafe for Palette<F> where
F: RefUnwindSafe,
F: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,