Skip to main content
Version: v2.4.0 (Current)

📦 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:

FormatBest For...Memory Usage
True ColorPhotos and complex gradients.High
Indexed (Palette)Icons and simple UI elements.Low
Alpha OnlyMasks and single-color "tintable" icons.Very Low

🔡 Font Transcoding

The Asset Packer converts TrueType (.ttf) and OpenType (.otf) fonts into bitmap fonts.

  1. Anti-aliasing: Smooths the edges of characters for small screens.
  2. Glyph Subsetting: Only includes the characters you actually use (e.g., just numbers 0-9), saving massive amounts of Flash memory.
  3. Range Support: Supports Latin, Cyrillic, CJK, and Symbol ranges.

🚀 The Build Process

When you click Export in Artok Studio, the following happens:

  1. Scanning: The tool identifies every image and font used in your project.
  2. Conversion: Assets are transcoded into the selected LV_COLOR_DEPTH.
  3. Bundling: All data is packed into an assets.bin file or a C source file for direct compilation.
  4. Header Generation: A resource.h file 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")

FLASH SAVING

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