embedded_graphics

Module image

Source
Expand description

Image support for embedded-graphics

Adding embedded-graphics support to an image format requires the implementation of the ImageDimensions and IntoPixelIter traits. These provide a common interface to image metadata and an iterator over individual pixel values respectively.

The Image struct is a wrapper around items that implement both ImageDimensions and IntoPixelIter and allows them to be drawn to a DrawTarget, reading pixel values from the implementation of IntoPixelIter.

§Examples

§Load a TGA image and draw it to a display

This example loads a TGA-formatted image using the tinytga crate and draws it to the display using the Image wrapper. The image is positioned at the top left corner of the display.

use embedded_graphics::{image::Image, pixelcolor::Rgb565, prelude::*};
use tinytga::Tga;

let mut display: Display<Rgb565> = Display::default();

let tga =
    Tga::from_slice(include_bytes!("../../../simulator/examples/assets/rust-pride.tga")).unwrap();

let image: Image<Tga, Rgb565> = Image::new(&tga, Point::zero());

image.draw(&mut display);

Structs§

Traits§

Type Aliases§