Struct embedded_graphics::image::Image

source ·
pub struct Image<'a, C, T>
where C: PixelColor, T: ImageType,
{ pub offset: Coord, /* private fields */ }
Expand description

An image constructed from a slice

Fields§

§offset: Coord

Image offset in pixels from screen origin (0,0)

Implementations§

source§

impl<'a, C, T> Image<'a, C, T>
where C: PixelColor, T: ImageType,

source

pub fn new(imagedata: &'a [u8], width: u32, height: u32) -> Self

Create a new image with given pixel data, width and height

Trait Implementations§

source§

impl<'a, C, T> Debug for Image<'a, C, T>
where C: PixelColor + Debug, T: ImageType + Debug,

source§

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

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

impl<'a, C, T> Dimensions for Image<'a, C, T>
where C: PixelColor, T: ImageType,

source§

fn top_left(&self) -> Coord

Get the top left corner of the bounding box for an object
source§

fn bottom_right(&self) -> Coord

Get the bottom right corner of the bounding box for an object
source§

fn size(&self) -> UnsignedCoord

Get the width and height for an object
source§

impl<'a, C, T> Transform for Image<'a, C, T>
where C: PixelColor, T: ImageType,

source§

fn translate(&self, by: Coord) -> Self

Translate the image from its current position to a new position by (x, y) pixels, returning a new Image. For a mutating transform, see translate_mut.

// 8px x 1px test image
let image: Image1BPP<u8> = Image1BPP::new(&[ 0xff ], 8, 1);
let moved = image.translate(Coord::new(25, 30));

assert_eq!(image.offset, Coord::new(0, 0));
assert_eq!(moved.offset, Coord::new(25, 30));
source§

fn translate_mut(&mut self, by: Coord) -> &mut Self

Translate the image from its current position to a new position by (x, y) pixels.

let mut image: Image1BPP<u8> = Image1BPP::new(&[ 0xff ], 8, 1);
image.translate_mut(Coord::new(25, 30));

assert_eq!(image.offset, Coord::new(25, 30));
source§

impl<'a, C, T> Drawable for Image<'a, C, T>
where C: PixelColor, T: ImageType,

Auto Trait Implementations§

§

impl<'a, C, T> Freeze for Image<'a, C, T>

§

impl<'a, C, T> RefUnwindSafe for Image<'a, C, T>

§

impl<'a, C, T> Send for Image<'a, C, T>
where C: Send, T: Send,

§

impl<'a, C, T> Sync for Image<'a, C, T>
where C: Sync, T: Sync,

§

impl<'a, C, T> Unpin for Image<'a, C, T>
where C: Unpin, T: Unpin,

§

impl<'a, C, T> UnwindSafe for Image<'a, C, T>
where C: UnwindSafe, T: UnwindSafe,

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> 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> 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> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

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

§

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>,

§

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.