| Crates.io | embedded-graphics-colorcast |
| lib.rs | embedded-graphics-colorcast |
| version | 0.1.1 |
| created_at | 2025-12-12 16:55:06.643232+00 |
| updated_at | 2025-12-29 12:05:12.059619+00 |
| description | Color casting for embedded-graphics binary images |
| homepage | |
| repository | https://github.com/kpcyrd/embedded-graphics-colorcast |
| max_upload_size | |
| id | 1981869 |
| size | 23,412 |
Color casting for embedded-graphics images.
This crate provides an Image struct that wraps around an
ImageRaw<BinaryColor> and allows rendering it to any draw target by mapping
the binary colors to the target's color type.
It was originally developed for use with [https://github.com/kpcyrd/embedded-mono-img].
use embedded_graphics::{
image::{ImageRaw, ImageRawBE},
pixelcolor::{BinaryColor, Rgb565},
prelude::*,
};
use embedded_graphics_colorcast::Image;
let mut display: Display<Rgb565> = Display::default();
// Raw big endian image data for demonstration purposes. A real image would likely be much
// larger.
let data = [
0x00, 0x00, 0xF8, 0x00, 0x07, 0xE0, 0xFF, 0xE0, //
0x00, 0x1F, 0x07, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, //
];
// Create a raw image instance. Other image formats will require different code to load them.
// All code after loading is the same for any image format.
let raw: ImageRawBE<BinaryColor> = ImageRaw::new(&data, 4);
// Create an `Image` object to position the image at `Point::zero()`.
let image = Image::new(&raw, Point::zero(), Rgb565::WHITE);
// Draw the image to the display.
image.draw(&mut display)?;
This repository contains trait implementations and documentation copied over
from the embedded-graphics project (with very minor modifications).
MIT OR Apache-2.0