png2lvgl-0.2.3 is not a library.
png2lvgl
Convert PNG images to LVGL C arrays with support for multiple color formats.
Features
- 🎨 Multiple color format support (True Color, Indexed, Alpha)
- 🚀 Fast and efficient Rust implementation
- 📦 Zero runtime dependencies in generated C code
- 🔧 Automatic format detection
- 💾 Safe file handling (no accidental overwrites)
Installation
Cargo (Recommended)
Homebrew (macOS)
# Add the tap
# Install png2lvgl
Pre-built Binaries
Download the latest release for your platform from GitHub Releases.
From Source
Usage
# Basic usage (auto-detects format, defaults to LVGL 9.0)
# Target LVGL 8.x
# Specify output file
# Use 4-bit indexed grayscale (16 colors)
# Overwrite existing file
LVGL Version Compatibility
png2lvgl supports both LVGL 8.x and 9.x APIs:
| Flag | LVGL Version | Format Constants |
|---|---|---|
--lvgl-v9 (default) |
LVGL 9.x | LV_COLOR_FORMAT_RGB565, LV_COLOR_FORMAT_I4, LV_COLOR_FORMAT_A8 |
--lvgl-v8 |
LVGL 8.x | LV_IMG_CF_TRUE_COLOR, LV_IMG_CF_INDEXED_4BIT, LV_IMG_CF_ALPHA_8BIT |
Default: LVGL 9.x format constants are used if no flag is specified.
Example:
# For LVGL 9.x projects (default)
# For LVGL 8.x projects
Supported Formats
| Format | Description | Use Case |
|---|---|---|
true-color |
RGB565 | Full color images |
true-color-alpha |
RGB565 + Alpha | Images with transparency |
true-color-chroma |
RGB565 + Chroma key | Transparent color key |
indexed1/2/4/8 |
Palette (2/4/16/256 colors) | Small images, icons |
alpha1/2/4/8 |
Alpha only (1/2/4/8 bit) | Masks, monochrome icons |
Output Format
Generated C files are compatible with LVGL and include:
- Proper header guards
- Memory alignment attributes
- Color palette (for indexed formats)
- Image descriptor structure
Example output:
const lv_img_dsc_t my_image = ;
Building from Source
License
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.