text-image
A Rust macro crate for converting text and images to various image formats, primarily for use with embedded graphics systems.
Features
- Convert text to grayscale images with customizable options
- Convert color images to monochrome (1-bit) images
- Convert color images to 4-color (2-bit) images
- Convert images to grayscale with adjustable bit depth (1, 2, 4, or 8-bit)
Usage
Add this to your Cargo.toml:
[]
= "0.1.0"
Text to Image
Convert text to a grayscale image:
use text_image;
use ;
Image to Monochrome
Convert a color image to a 1-bit monochrome image:
use monochrome_image;
let = monochrome_image!;
Image to 4-color
Convert a color image to a 2-bit 4-color image:
use quadcolor_image;
let = quadcolor_image!;
Image to Grayscale
Convert an image to grayscale with specified bit depth:
use gray_image;
let = gray_image!;
Options
text: The text to convert (required fortext_image!)font: Path to the font file (required fortext_image!)font_size: Font size in pixels (default: 16.0)inverse: Invert the colors (optional)line_spacing: Additional space between lines (optional)Gray2,Gray4,Gray8: Specify the bit depth for grayscale output
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.