https://github.com/stestagg/escpos-embed-image
Companion crate to escpos-embedded that provides the embed_image!() macro
https://github.com/stestagg/escpos-embed-image
Last synced: 11 months ago
JSON representation
Companion crate to escpos-embedded that provides the embed_image!() macro
- Host: GitHub
- URL: https://github.com/stestagg/escpos-embed-image
- Owner: stestagg
- License: mit
- Created: 2025-07-25T23:51:56.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-08-18T01:21:54.000Z (11 months ago)
- Last Synced: 2025-08-18T03:14:04.476Z (11 months ago)
- Language: Rust
- Size: 41 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# escpos-embed-image
A procedural macro for embedding monochrome, dithered images into ESC/POS printer drivers at compile time.
Designed as a companion to `escpos-embedded`, this crate processes Images at compile time and generates a static `Image<&'static [u8]>` compatible with the `no_std`, allocation-free printer interface.
## Features
- Compile-time image loading and conversion
- Converts image file to 1-bit dithered format (Bi-level Floyd-Steinberg)
- Outputs `Image<&'static [u8]>` struct ready for printing
- No runtime dependencies
## Example
```rust
use escpos_embedded::Image;
use escpos_embed_image::{embed_image, embed_images};
static LOGO: Image<&'static [u8]> = embed_image!("assets/logo.png");
embed_images!(
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
enum Assets {
#[pattern("assets/*.png")]
}
);
// Generated enum `Assets` with variants for each matched file
// Assets::Logo.get_image() -> &'static Image<&'static [u8]>
```
## How it works
- At compile time, the macro loads the image file (any supported format)
- As required: Converts it to grayscale, then applies dithering
- Packs the result into 1-bit-per-pixel (row-major) format
- Emits a static `Image` instance with dimensions and data
## Requirements
- Input must be a valid image file path
- The output image must be small enough to fit in flash/ROM (no heap)
## Crate Structure
This is a separate crate from `escpos-embedded` because it uses `proc-macro` and requires `std`. It is intended for use on the host during build/compile time only.