pub struct IndexedImage { /* private fields */ }
Implementations§
Source§impl IndexedImage
impl IndexedImage
Source§impl IndexedImage
impl IndexedImage
Sourcepub fn set_palette(
&mut self,
palette: &[Color],
) -> Result<(), IndexedImageError>
pub fn set_palette( &mut self, palette: &[Color], ) -> Result<(), IndexedImageError>
Replace palette for image Will only return an error if the new palette has less colors than the image needs
Sourcepub fn set_palette_replace_id(
&mut self,
palette: &[Color],
id: u8,
) -> Result<(), IndexedImageError>
pub fn set_palette_replace_id( &mut self, palette: &[Color], id: u8, ) -> Result<(), IndexedImageError>
Replace palette for image, any pixels outside the new palette will be replaced with id
Will only return an error if id is outside the new palette
Sourcepub fn set_palette_replace_color<C>(&mut self, palette: &[Color], color: C)
pub fn set_palette_replace_color<C>(&mut self, palette: &[Color], color: C)
Replace palette for image, any color indexes outside the palette will be expanded with color
pub fn size(&self) -> (u8, u8)
pub fn set_pixel( &mut self, pixel_idx: usize, color_idx: u8, ) -> Result<(), IndexedImageError>
Sourcepub unsafe fn set_pixel_unchecked(&mut self, pixel_idx: usize, color_idx: u8)
pub unsafe fn set_pixel_unchecked(&mut self, pixel_idx: usize, color_idx: u8)
§Safety
Out of bounds may occur
pub fn get_pixels(&self) -> &[u8] ⓘ
pub fn get_pixel(&self, pixel_idx: usize) -> Result<u8, IndexedImageError>
Sourcepub unsafe fn get_pixel_unchecked(&self, pixel_idx: usize) -> u8
pub unsafe fn get_pixel_unchecked(&self, pixel_idx: usize) -> u8
§Safety
Out of bounds may occur
pub fn get_pixel_index(&self, x: u8, y: u8) -> Result<usize, IndexedImageError>
Sourcepub unsafe fn get_pixel_index_unchecked(&self, x: u8, y: u8) -> usize
pub unsafe fn get_pixel_index_unchecked(&self, x: u8, y: u8) -> usize
§Safety
Out of bounds may occur
pub fn get_color(&self, idx: u8) -> Result<Color, IndexedImageError>
Sourcepub unsafe fn get_color_unchecked(&self, idx: u8) -> Color
pub unsafe fn get_color_unchecked(&self, idx: u8) -> Color
§Safety
Out of bounds may occur
pub fn set_color( &mut self, idx: u8, color: Color, ) -> Result<(), IndexedImageError>
Sourcepub fn set_color_unchecked(&mut self, idx: u8, color: Color)
pub fn set_color_unchecked(&mut self, idx: u8, color: Color)
§Safety
Out of bounds may occur
pub fn get_palette(&self) -> &[Color]
pub fn min_palette_size_supported(&self) -> u8
pub fn width(&self) -> u8
pub fn height(&self) -> u8
pub fn rotate_cw(&self) -> IndexedImage
Sourcepub unsafe fn rotate_cw_unchecked(&self) -> IndexedImage
pub unsafe fn rotate_cw_unchecked(&self) -> IndexedImage
§Safety
Out of bounds may occur
pub fn rotate_ccw(&self) -> IndexedImage
Sourcepub unsafe fn rotate_ccw_unchecked(&self) -> IndexedImage
pub unsafe fn rotate_ccw_unchecked(&self) -> IndexedImage
§Safety
Out of bounds may occur
pub fn flip_vertical(&self) -> Result<IndexedImage, IndexedImageError>
Sourcepub unsafe fn flip_vertical_unchecked(&self) -> IndexedImage
pub unsafe fn flip_vertical_unchecked(&self) -> IndexedImage
§Safety
Out of bounds may occur
pub fn flip_horizontal(&self) -> Result<IndexedImage, IndexedImageError>
Sourcepub unsafe fn flip_horizontal_unchecked(&self) -> IndexedImage
pub unsafe fn flip_horizontal_unchecked(&self) -> IndexedImage
§Safety
Out of bounds may occur
pub fn scale(&self, algo: Scaling) -> Result<IndexedImage, IndexedImageError>
Sourcepub unsafe fn scale_unchecked(&self, algo: Scaling) -> IndexedImage
pub unsafe fn scale_unchecked(&self, algo: Scaling) -> IndexedImage
§Safety
Out of bounds may occur
pub fn tint_palette_add( &self, color_diff: &[(isize, isize, isize, isize)], ) -> IndexedImage
pub fn tint_palette_mut( &self, color_diff: &[(f32, f32, f32, f32)], ) -> IndexedImage
pub fn tint_add( &self, color_diff: &(isize, isize, isize, isize), ) -> IndexedImage
pub fn tint_mul(&self, color_diff: &(f32, f32, f32, f32)) -> IndexedImage
Source§impl IndexedImage
impl IndexedImage
Sourcepub fn to_file_contents(
&self,
palette: &FilePalette,
) -> Result<Vec<u8>, IndexedImageError>
pub fn to_file_contents( &self, palette: &FilePalette, ) -> Result<Vec<u8>, IndexedImageError>
Errors will only be returned if you FilePalette::Name and the len is invalid
Sourcepub fn from_file_contents(
bytes: &[u8],
) -> Result<(IndexedImage, FilePalette), IndexedImageError>
pub fn from_file_contents( bytes: &[u8], ) -> Result<(IndexedImage, FilePalette), IndexedImageError>
Create an IndexedImage, image palette will be filled with transparency unless file contains colors
use image.set_palette*
to replace the palette
Trait Implementations§
Source§impl ChangeColors for IndexedImage
impl ChangeColors for IndexedImage
Source§fn with_saturate(&self, amount: f32) -> IndexedImage
fn with_saturate(&self, amount: f32) -> IndexedImage
-0.1
is 10% more saturatedSource§fn with_brightness(&self, amount: f32) -> IndexedImage
fn with_brightness(&self, amount: f32) -> IndexedImage
amount
So 1.1
is 10% brighterSource§fn desaturate(&self) -> Selfwhere
Self: Sized,
fn desaturate(&self) -> Selfwhere
Self: Sized,
fn lighten(&self) -> Selfwhere
Self: Sized,
fn darken(&self) -> Selfwhere
Self: Sized,
Source§impl Clone for IndexedImage
impl Clone for IndexedImage
Source§fn clone(&self) -> IndexedImage
fn clone(&self) -> IndexedImage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for IndexedImage
impl Debug for IndexedImage
Source§impl<'de> Deserialize<'de> for IndexedImage
impl<'de> Deserialize<'de> for IndexedImage
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<IndexedImage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<IndexedImage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<IndexedImage> for IndexedWrapper
impl From<IndexedImage> for IndexedWrapper
Source§fn from(value: IndexedImage) -> IndexedWrapper
fn from(value: IndexedImage) -> IndexedWrapper
Source§impl PartialEq for IndexedImage
impl PartialEq for IndexedImage
Source§impl Serialize for IndexedImage
impl Serialize for IndexedImage
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for IndexedImage
impl StructuralPartialEq for IndexedImage
Auto Trait Implementations§
impl Freeze for IndexedImage
impl RefUnwindSafe for IndexedImage
impl Send for IndexedImage
impl Sync for IndexedImage
impl Unpin for IndexedImage
impl UnwindSafe for IndexedImage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.