logo
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

Image drawable.

Pixel iterator over Image objects

An image constructed from a slice of raw pixel data.

Traits

A trait to get the dimensions of an image.

Conversion into an iterator over the pixels of the image.

Type Definitions

Image with big endian data.

Image with little endian data.