pub struct Sprite { /* private fields */ }Expand description
A Sprite corresponds to a set of bytes encoded to the right CPC pixel format for a given palette. TODO Check why mode nad palette are optionnals. Force them if it is not mandatory to have htem optionnal
Implementations
sourceimpl Sprite
impl Sprite
sourcepub fn to_color_matrix(&self) -> Option<ColorMatrix>
pub fn to_color_matrix(&self) -> Option<ColorMatrix>
TODO Use TryFrom once in standard rust The conversion can only work if a palette and a mode is provided
sourcepub fn to_linear_vec(&self) -> Vec<u8> ⓘ
pub fn to_linear_vec(&self) -> Vec<u8> ⓘ
Produce a linearized version of the sprite.
pub fn set_palette(&mut self, palette: Palette)
pub fn bytes(&self) -> &Vec<Vec<u8>> ⓘ
sourcepub fn mode(&self) -> Option<Mode>
pub fn mode(&self) -> Option<Mode>
Get hte sprite Mode Cannot manage multimode sprites of course
sourcepub fn byte_width(&self) -> u32
pub fn byte_width(&self) -> u32
Get the width (in bytes) of the image TODO Use a trait for that
sourcepub fn pixel_width(&self) -> u32
pub fn pixel_width(&self) -> u32
Get the width in pixels of the image. The mode must be specified
sourcepub fn get_byte(&self, x: usize, y: usize) -> u8
pub fn get_byte(&self, x: usize, y: usize) -> u8
Returns the byte at the right position and crash if it does not exists
sourcepub fn get_byte_safe(&self, x: usize, y: usize) -> Option<u8>
pub fn get_byte_safe(&self, x: usize, y: usize) -> Option<u8>
Returns the byte at the right position if exists
sourcepub fn convert(
img: &ImageBuffer<Rgb<u8>, Vec<u8>>,
mode: Mode,
conversion: ConversionRule,
palette: Option<Palette>
) -> Sprite
pub fn convert(
img: &ImageBuffer<Rgb<u8>, Vec<u8>>,
mode: Mode,
conversion: ConversionRule,
palette: Option<Palette>
) -> Sprite
Convert an RGB image to a sprite that code the pixels XXX Since 2018-06-16, most of code is delagated to ColorMatrix => maybe some bugs has been added
pub fn convert_from_fname(
fname: &str,
mode: Mode,
conversion: ConversionRule,
palette: Option<Palette>
) -> Result<Sprite, ImageError>
Auto Trait Implementations
impl RefUnwindSafe for Sprite
impl Send for Sprite
impl Sync for Sprite
impl Unpin for Sprite
impl UnwindSafe for Sprite
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> Pointable for T
impl<T> Pointable for T
impl<T> SetParameter for T
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Resultwhere
T: Parameter<Self>,
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Resultwhere
T: Parameter<Self>,
value as a parameter of self.