📦 Asset Packer
The Asset Packer is a high-performance utility that prepares your creative assets for the constraints of embedded hardware. It ensures that images and fonts occupy the smallest possible footprint while maintaining maximum visual fidelity.
🛠 Why Use a Packer?
Microcontrollers (MCUs) typically lack the RAM and CPU power to decode a .png or .jpg file in real-time. The Asset Packer solves this by:
- Pre-decoding: Converting images into raw pixel maps (RGB565, ARGB8888).
- Compression: Applying RLE (Run-Length Encoding) to reduce binary size.
- Indexing: Creating a lookup table so the Lua VM can reference assets by a simple ID.
🖼 Image Optimization
When you drop an image into the Studio, the Packer evaluates the best storage strategy based on your Bit Depth (BPP) settings:
| Format | Best For... | Memory Usage |
|---|---|---|
| True Color | Photos and complex gradients. | High |
| Indexed (Palette) | Icons and simple UI elements. | Low |
| Alpha Only | Masks and single-color "tintable" icons. | Very Low |
🔡 Font Transcoding
The Asset Packer converts TrueType (.ttf) and OpenType (.otf) fonts into bitmap fonts.
- Anti-aliasing: Smooths the edges of characters for small screens.
- Glyph Subsetting: Only includes the characters you actually use (e.g., just numbers 0-9), saving massive amounts of Flash memory.
- Range Support: Supports Latin, Cyrillic, CJK, and Symbol ranges.
🚀 The Build Process
When you click Export in Artok Studio, the following happens:
- Scanning: The tool identifies every image and font used in your project.
- Conversion: Assets are transcoded into the selected
LV_COLOR_DEPTH. - Bundling: All data is packed into an
assets.binfile or aCsource file for direct compilation. - Header Generation: A
resource.hfile is created, mapping names to memory offsets.
⚡ Runtime Access (Lua)
Once packed, accessing an asset is instantaneous because it is already in a format the GPU or CPU understands.
-- Setting an image from the packed library
img_logo:set_src("LOGO_HUGE_PNG")
-- Dynamically changing a font
lbl_status:set_style_text_font("ROBOTO_MEDIUM_18")
If your binary size is too large for your MCU, check the Asset Packer Log. It will highlight which images are taking up the most space, allowing you to lower their bit-depth or resize them.
🚀 Next Steps
- Bit Depth (BPP) — Learn how to choose the right color format for your hardware.
- Custom Fonts — How to import and manage typography.
- Firmware Integration — How to load the
assets.bininto your C project.