[][src]Struct embedded_graphics::image::Image16BPP

pub struct Image16BPP<'a, C: PixelColor> {
    pub offset: Coord,
    // some fields omitted
}

16 bits per pixel images

Every two bytes define the color for each pixel.

You can convert an image to 16BPP for inclusion with include_bytes!() doing the following

convert image.png -flip -flop -type truecolor -define bmp:subtype=RGB565 -resize '64x64!' -depth 16 -strip image.bmp

then

tail -c $bytes image.bmp > image.raw // where $bytes is w * h * 2

This will remove the BMP header leaving the raw pixel data E.g 64x64 image will have 64 * 64 * 2 bytes of raw data.

Fields

offset: Coord

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

Trait Implementations

impl<'a, C> Drawable for Image16BPP<'a, C> where
    C: PixelColor
[src]

impl<'a, C> Dimensions for Image16BPP<'a, C> where
    C: PixelColor
[src]

impl<'a, C> Image<'a> for Image16BPP<'a, C> where
    C: PixelColor
[src]

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

Create a new 16BPP image with given data, width and height. Data length must equal width * height * 2

impl<'a, C> Transform for Image16BPP<'a, C> where
    C: PixelColor
[src]

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

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


// 1px x 1px test image
let image: Image16BPP<PixelColorU8> = Image16BPP::new(&[ 0xff ], 1, 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));

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

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


// 1px x 1px test image
let mut image: Image16BPP<PixelColorU8> = Image16BPP::new(&[ 0xff ], 1, 1);
image.translate_mut(Coord::new(25, 30));

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

impl<'a, C: Debug + PixelColor> Debug for Image16BPP<'a, C>[src]

impl<'a, C> IntoIterator for &'a Image16BPP<'a, C> where
    C: PixelColor + From<u16>, 
[src]

type Item = Pixel<C>

The type of the elements being iterated over.

type IntoIter = Image16BPPIterator<'a, C>

Which kind of iterator are we turning this into?

Auto Trait Implementations

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

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

Blanket Implementations

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]