Struct IndexedImage

Source
pub struct IndexedImage { /* private fields */ }

Implementations§

Source§

impl IndexedImage

Source

pub fn new( width: u8, height: u8, palette: Vec<Color>, pixels: Vec<u8>, ) -> Result<IndexedImage, IndexedImageError>

Source

pub fn blank(width: u8, height: u8, palette: Vec<Color>) -> IndexedImage

Source§

impl IndexedImage

Source

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

Source

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

Source

pub fn set_palette_replace_color<C>(&mut self, palette: &[Color], color: C)
where C: Into<Color> + Copy,

Replace palette for image, any color indexes outside the palette will be expanded with color

Source

pub fn size(&self) -> (u8, u8)

Source

pub fn set_pixel( &mut self, pixel_idx: usize, color_idx: u8, ) -> Result<(), IndexedImageError>

Source

pub unsafe fn set_pixel_unchecked(&mut self, pixel_idx: usize, color_idx: u8)

§Safety

Out of bounds may occur

Source

pub fn get_pixels(&self) -> &[u8]

Source

pub fn get_pixel(&self, pixel_idx: usize) -> Result<u8, IndexedImageError>

Source

pub unsafe fn get_pixel_unchecked(&self, pixel_idx: usize) -> u8

§Safety

Out of bounds may occur

Source

pub fn get_pixel_index(&self, x: u8, y: u8) -> Result<usize, IndexedImageError>

Source

pub unsafe fn get_pixel_index_unchecked(&self, x: u8, y: u8) -> usize

§Safety

Out of bounds may occur

Source

pub fn get_color(&self, idx: u8) -> Result<Color, IndexedImageError>

Source

pub unsafe fn get_color_unchecked(&self, idx: u8) -> Color

§Safety

Out of bounds may occur

Source

pub fn set_color( &mut self, idx: u8, color: Color, ) -> Result<(), IndexedImageError>

Source

pub fn set_color_unchecked(&mut self, idx: u8, color: Color)

§Safety

Out of bounds may occur

Source

pub fn get_palette(&self) -> &[Color]

Source

pub fn min_palette_size_supported(&self) -> u8

Source

pub fn width(&self) -> u8

Source

pub fn height(&self) -> u8

Source

pub fn rotate_cw(&self) -> IndexedImage

Source

pub unsafe fn rotate_cw_unchecked(&self) -> IndexedImage

§Safety

Out of bounds may occur

Source

pub fn rotate_ccw(&self) -> IndexedImage

Source

pub unsafe fn rotate_ccw_unchecked(&self) -> IndexedImage

§Safety

Out of bounds may occur

Source

pub fn flip_vertical(&self) -> Result<IndexedImage, IndexedImageError>

Source

pub unsafe fn flip_vertical_unchecked(&self) -> IndexedImage

§Safety

Out of bounds may occur

Source

pub fn flip_horizontal(&self) -> Result<IndexedImage, IndexedImageError>

Source

pub unsafe fn flip_horizontal_unchecked(&self) -> IndexedImage

§Safety

Out of bounds may occur

Source

pub fn scale(&self, algo: Scaling) -> Result<IndexedImage, IndexedImageError>

Source

pub unsafe fn scale_unchecked(&self, algo: Scaling) -> IndexedImage

§Safety

Out of bounds may occur

Source

pub fn tint_palette_add( &self, color_diff: &[(isize, isize, isize, isize)], ) -> IndexedImage

Source

pub fn tint_palette_mut( &self, color_diff: &[(f32, f32, f32, f32)], ) -> IndexedImage

Source

pub fn tint_add( &self, color_diff: &(isize, isize, isize, isize), ) -> IndexedImage

Source

pub fn tint_mul(&self, color_diff: &(f32, f32, f32, f32)) -> IndexedImage

Source§

impl IndexedImage

Source

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

Source

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

Source§

fn with_saturate(&self, amount: f32) -> IndexedImage

De/saturate color by percentage Negative amount increases saturation So -0.1 is 10% more saturated
Source§

fn with_brightness(&self, amount: f32) -> IndexedImage

Change brightness to amount So 1.1 is 10% brighter
Source§

fn saturate(&self) -> Self
where Self: Sized,

Increase saturation by 10%
Source§

fn desaturate(&self) -> Self
where Self: Sized,

Decrease saturation by 10%
Source§

fn lighten(&self) -> Self
where Self: Sized,

Source§

fn darken(&self) -> Self
where Self: Sized,

Source§

impl Clone for IndexedImage

Source§

fn clone(&self) -> IndexedImage

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IndexedImage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for IndexedImage

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<IndexedImage, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<IndexedImage> for IndexedWrapper

Source§

fn from(value: IndexedImage) -> IndexedWrapper

Converts to this type from the input type.
Source§

impl PartialEq for IndexedImage

Source§

fn eq(&self, other: &IndexedImage) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Renderable<IndexedImage> for RenderableIndexedImage

Source§

fn render(&self, graphics: &mut Graphics<'_>)

Source§

impl Serialize for IndexedImage

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for IndexedImage

Source§

impl StructuralPartialEq for IndexedImage

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyToAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,