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 more