Struct embedded_graphics::image::ImageBmp

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

BMP format image

ImageBmp is available with the bmp feature turned on

§Examples

§Load a 16 bit per pixel image from a raw byte slice and draw it to a display

Note that images must be passed to Display#draw by reference, or by explicitly calling .into_iter() on them, unlike other embedded_graphics objects.

use embedded_graphics::prelude::*;
use embedded_graphics::image::ImageBmp;

// Load `patch_16bpp.bmp`, a 16BPP 4x4px image
let image = ImageBmp::new(include_bytes!("../../../assets/patch_16bpp.bmp")).unwrap();

// Equivalent behaviour
display.draw(&image);
display.draw(image.into_iter());

Fields§

§offset: Coord

Top left corner offset from display origin (0,0)

Trait Implementations§

source§

impl<'a, C: Clone + PixelColor> Clone for ImageBmp<'a, C>

source§

fn clone(&self) -> ImageBmp<'a, C>

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<'a, C: Debug + PixelColor> Debug for ImageBmp<'a, C>

source§

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

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

impl<'a, C> Dimensions for ImageBmp<'a, C>
where C: PixelColor,

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> ImageFile<'a> for ImageBmp<'a, C>
where C: PixelColor,

source§

fn new(image_data: &'a [u8]) -> Result<Self, ()>

Create a new BMP from a byte slice

source§

fn width(&self) -> u32

Get the width in pixels of an image
source§

fn height(&self) -> u32

Get the height in pixels of an image
source§

impl<'a, C> IntoIterator for &'a ImageBmp<'a, C>
where C: PixelColor + From<u8> + From<u16>,

§

type Item = Pixel<C>

The type of the elements being iterated over.
§

type IntoIter = ImageBmpIterator<'a, C>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, C> Transform for ImageBmp<'a, C>
where C: PixelColor,

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 ImageBmp. For a mutating transform, see translate_mut.

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.

source§

impl<'a, C> Drawable for ImageBmp<'a, C>
where C: PixelColor,

Auto Trait Implementations§

§

impl<'a, C> Freeze for ImageBmp<'a, C>

§

impl<'a, C> RefUnwindSafe for ImageBmp<'a, C>
where C: RefUnwindSafe,

§

impl<'a, C> Send for ImageBmp<'a, C>
where C: Send,

§

impl<'a, C> Sync for ImageBmp<'a, C>
where C: Sync,

§

impl<'a, C> Unpin for ImageBmp<'a, C>
where C: Unpin,

§

impl<'a, C> UnwindSafe for ImageBmp<'a, C>
where C: 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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

§

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

§

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.