#convert #raw #embedded-graphics #binary #firmware

app embedded-mono-img

Convert .png images to raw binary for embedded_graphics

2 unstable releases

Uses new Rust 2024

new 0.2.0 Mar 22, 2025
0.1.0 Mar 20, 2025

#1053 in Command line utilities

Download history 78/week @ 2025-03-14

78 downloads per month

MIT/Apache

13KB
199 lines

embedded-mono-img

This program is for use with embedded_graphics to convert a .png into the data needed/used for ImageRaw::<BinaryColor> during embedded firmware development with Rust.

Usage

embedded-mono-img -o img.raw img.png
const IMAGE: ImageRaw<BinaryColor> = ImageRaw::new(include_bytes!("../img.raw"), 24);

The file is recommended to be in 8-bit Grayscale.

Alternative solutions

In the past I used imagemagick like this:

convert frame1.png -monochrome -negate frame1.pbm
# use a hex editor, search for start of null bytes
tail -c +11 frame1.pbm > frame1.raw

However the exact offset for the tail command varied depending on the presence of metadata (like e.g. a comment). This problem has inspired development of embedded-mono-img so I don't need to worry about this anymore.

License

MIT OR Apache-2.0

Dependencies

~4.5MB
~86K SLoC