Struct buffer_graphics_lib::prelude::IndexedImage
source · 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§fn eq(&self, other: &IndexedImage) -> bool
fn eq(&self, other: &IndexedImage) -> bool
self
and other
values to be equal, and is used
by ==
.