[−][src]Struct pix::Palette
Color table for use with indexed Raster
s.
Methods
impl Palette
[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 is_empty(&self) -> bool
[src]
Check if the palette is empty.
pub fn set_threshold_fn(&mut self, threshold_fn: fn(_: usize) -> SRgb8)
[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 colors(&self) -> &[SRgb8]
[src]
Get a slice of all colors.
pub fn entry(&self, i: usize) -> Option<SRgb8>
[src]
Get a Palette
entry.
i
Index of entry.
pub fn set_entry(&mut self, clr: SRgb8) -> 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: SRgb8) -> Option<SRgb8>
[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 RefUnwindSafe for Palette
impl Send for Palette
impl Sync for Palette
impl Unpin for Palette
impl UnwindSafe for Palette
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> From<T> for T
[src]
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, 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>,