Images are a core part of every embedded UI. This guide covers how anyui-LIVE handles, optimizes, and uses images across the design, code generation, and target runtime stages.
Overview
anyui-LIVE treats images as first-class resources. An image imported into the project is available to every screen and component, and it is automatically converted and embedded into the generated firmware at build time.
The image pipeline consists of three stages:
- Import - add an image from a local file into the resources this project reads.
- Reference - assign the image to a component property.
- Generation - emit the converted asset into the generated code.
Refer to codegen guide to see how the generated image code is produced.
Importing images
Import images in the Resource view. PNG, JPG and BMP are accepted.
- PNG keeps transparency and crisp edges, so it remains the usual choice for interface artwork.
- JPG is the smallest file for a photograph or a gradient, but it holds no transparency, so the picture arrives as a solid rectangle.
- BMP is uncompressed and therefore the largest of the three. A compressed BMP, or one in a bit depth the target generation cannot read - 9.x takes only 16, 24 and 32 - is refused as a file source, so keep it compiled into the project as an asset.
After import, the image becomes available in the resource picker and can be assigned to any image component property.
Warning
You are responsible for ensuring that you have the necessary rights and permissions for every image you import and use.
Image source types
A picture on a widget is one source pointer, and LVGL reads that pointer in four different ways. Every image row therefore opens with a Source Type switch: state the reading first, and the row below it edits the value in that reading.
| Source Type | What the widget displays | The row below it |
|---|---|---|
| Image asset | A picture from the project's resource library, converted to a C array and compiled into the firmware. | An image picker over the imported pictures. |
| File path | A file the firmware opens at run time through a drive letter, such as S:images/logo.png. | The same picker, with the pick stored as a path under the project's file folder. |
| Symbol | One of LVGL's built-in symbol glyphs, drawn with the font set on the widget. | A list of the built-in glyphs. |
| Text | Text drawn by the image widget itself, the way a label draws it. | A text field. |
- Image asset is the reading that compiles the picture into the binary; the other three keep it out of the firmware. Choose a file path when the artwork should stay a file on the device, and a symbol or a text run when the widget should draw type rather than a bitmap.
- Symbol and Text are drawn through the label pipeline, so the widget's text styles apply while either is selected - font, color, alignment, and letter spacing.
Where the switch appears
| Image slot | Readings it offers |
|---|---|
| Image widget | All four. |
| Image Button | One reading for the whole widget: image asset or file path. |
| Anim Image | One reading for the whole frame strip: image asset or file path. |
| List entry icons, Meter and Scale needle images, image cells in the record and repeated list editors, and image style properties such as a background image | Image asset or file path, chosen per slot. |
| A slot whose type you have never touched | The project-wide Default Image Source, which a newly created image widget also starts on. |
That default, and the folder file paths are composed under, are both set in the settings dialog. Duplicating or pasting a widget keeps the source type the original states.
File-path sources
A file path names a picture the device reads at run time instead of bytes compiled into the firmware. The path always starts with the drive letter the exported project registers, S:, followed by a folder and the file name:
S:images/logo.png
- The folder is the project's External File Prefix, set in the settings dialog. With the prefix
images, a picked picture is stored asS:images/<file name>; an empty prefix puts files at the drive root. The prefix is a plain folder name - no drive letter, and no slash at either end. - Picking stays inside the resource library. The file path row opens the same browser as the asset row, so every pick is a picture the project already holds - and the library holds PNG, JPG and BMP pictures. Only the stored value differs.
- The preview reads it by file name. The live rendering mounts the
S:drive and draws the picture once the project's resources hold a file of that name. A path on a drive the preview does not mount shows nothing on canvas and says so in Problems. - The export carries the file. Exporting writes the picture next to the generated sources, at the path without the drive letter:
S:images/logo.pnglands atimages/logo.pngin the export folder, and a web-app ZIP includes it the same way. A file already in that folder is never overwritten - the export completion lists what it left alone. - The firmware is configured for it. The exported
lv_conf.hregisters the file drive and the decoders these files need, and a header you already own is corrected in place rather than replaced. A first export that adds these settings needs a full build afterwards, because an incremental build has no reason to look at a header it has already compiled. - A picture the device cannot decode is not a file source. A progressive JPEG, a CMYK JPEG, or a BMP that is compressed or in a bit depth the target generation cannot read is decoded on the host when the image is an asset, but the firmware has no decoder that handles it, so the row refuses the pick and says which format to export instead.
Warning
An older desktop app build cannot write these files safely, because it would overwrite a picture already in your export folder. There the image files are withheld and the export, the build log, and the toolbar all tell you to update the app and export again.
When an image shows nothing
LVGL answers a source it cannot honour by drawing nothing, and the preview agrees with the device on that blank, so the Problems tab is where the difference surfaces. Open it from the compliance badge - each row names the widget or the path it belongs to, and says how to fix it.
| Report | What to do |
|---|---|
| File path has no drive letter | Start the path with S:, the drive the exported project registers. |
| File path drive letter is invalid | Write the drive letter in capitals. |
| File path uses another drive | One project registers one file drive, so rewrite every path onto it. |
| Ambiguous image source | A value whose first character sits outside the printable ASCII range is read as a symbol glyph; if you meant a file, name the drive or use an asset with an extension. |
| Font has no glyph for the source | Assign a font library that covers the characters - this applies to a symbol and a text run alike. |
| Not rendered in the preview | The path names a drive the preview does not mount; use S:, or check the picture in the exported project. |
| The export could not ship a file | No library picture matches that path's file name; import it, or point the source at a file the project already holds. The row names the path rather than a widget, because one file can serve several widgets. |
Image components
An image placed on a screen references an image this project can read, either one of its own uploads or the shared pool's: see Resource scope. The component exposes the following key properties:
| Property | Description |
|---|---|
| Source Type | How LVGL reads the source: image asset, file path, symbol, or text. |
| Source / File Path / Symbol / Text | The value itself, edited through whichever row the selected source type shows. |
| X / Y | Position of the image on the screen. |
| Width / Height | Display size. When fixed, the source is not scaled. |
| Opacity | 0 (fully transparent) to 255 (fully opaque). |
| Rotation | Rotation angle in degrees. |
| Blend mode | Blending mode used when compositing over the background. |
Optimization
Optimization reduces ROM size and memory footprint on the target device.
Format conversion
At generation time, anyui-LIVE converts the source image into a C source array optimized for LVGL. Configure the output format in the resource settings:
- C array - the image is emitted as a C source array and compiled into the binary.
Images whose source type is a file path, a symbol, or text are not converted into a C array; see Image source types.
Memory considerations
Decoded images are held in RAM while displayed. If the target device runs low on memory, increase LV_MEM_SIZE in lv_conf.h:
#define LV_MEM_SIZE (8 * 1024U * 1024U) /*[bytes]*/
Related guides
- Resource management - import the images used by image components.
- Font library - manage typography alongside image assets.
- Overview - assign and edit image properties on the canvas.
- Inspector - the property rows an image widget offers.
- Settings - the default source type and the external file folder.
- Preview - preview image rendering before generation.
- Statusbar - the Problems tab that reports an image that cannot draw.
- Codegen - how image assets become generated code.