Skip to content

Media and Application Data

ESP-GSP keeps authored structure immutable while allowing product data to change through state updates, runtime resources, Canvas producers, and recycled collections.

raw (also called store) keeps native pixels in the bundle. With mmap_direct, the renderer reads them directly; their Flash size is not a decoded-cache charge. Compressed images save Flash, while whole-image decoding needs pixel memory. For RGB565, a 240×240 image needs 115,200 bytes; a separate A8 plane adds 57,600 bytes. Row alignment and JPEG decode alignment can increase these values.

When the image cache is enabled, each static compressed raster must fit the declared cache budget. Several images can share the cache through LRU eviction; their combined size may exceed the budget. Frequent eviction can increase decode work. Reserve preload for resources that need to remain resident.

On memory-constrained targets, region decoding handles supported lossless images without retaining every whole image. Select it with image_cache_enabled: false in the profile or --default-disable-image-cache for bundle compilation. JPEG uses the whole-image cache. With codec: "auto" or no codec override, compilation selects native pixels when fit/rotation requires them in region mode; compressed transformed images require the cache. When loading binaries directly, use the same cache mode in the runtime configuration. Bundle API headers apply the selected mode in their config helper.

gsp_add_bundle(... IMAGE_CACHE_BYTES 262144) sets an explicit runtime cache budget and the compiler’s matching budget, including with an explicit PROFILE. The CLI equivalent is --image-cache-bytes 262144. Setting only the Profile’s image_cache_budget_bytes constrains compilation; the runtime still derives its budget automatically. Pass IMAGE_CACHE_BYTES when both budgets must match. Automatic sizing also depends on available heap and its largest free block. Check firmware size separately from decoded-image memory.

The runtime value applies to each scene’s cache and also sets the aggregate scene-retention target. Current and incoming scenes are exempt from eviction while the incoming scene is prepared, so their combined pixels can temporarily exceed that target. Reducing the budget can lower retained memory and increase repeat decoding without reducing the scene-switch peak by the same amount. Display buffers, task stacks and decoder workspace are separate costs.

RGB/DSI examples expose CONFIG_EXAMPLE_LCD_FRAME_BUFFERS (2 or 3, default 3). The helper pairs two driver buffers with DOUBLE_PARTIAL; three keeps AUTO. Two saves one width * height * native-color-bytes buffer but can increase buffer waits. Validate the workload before selecting it. SPI/QSPI panel GRAM is unaffected, and these buffers are outside IMAGE_CACHE_BYTES.

With image caching enabled, the runtime synchronously prepares the scene’s currently visible compiled compressed images before its first frame, then uses remaining cache space to prefetch hidden images. An incomplete hidden-image prefetch is normal and only appears in debug diagnostics. If the visible decoded working set exceeds the budget, the warning reports the budget, resident bytes and skipped count; skipped visible images can show the scene background placeholder on the first frame. A single image larger than the budget reports its required decoded bytes. Increase IMAGE_CACHE_BYTES only with heap headroom, or reduce decoded dimensions/use raw or region decoding where appropriate.

Linked bundles share encoded assets. Each scene registers its own compiled image resources, including hidden controls and templates. Images used exclusively by other scenes do not enter its startup preparation or cache sizing. Recompile existing bundles to apply per-scene resource registration.

The manifest and execution report separate registered resources, scene draw references and initial visibility:

  • largest_static_decode_bytes: largest static decode among the scene’s draw references.
  • largest_registered_static_decode_bytes: largest static decode in the scene’s registered resource set.
  • initial_visible_static_decode_bytes_estimate: total for unique static images intersecting the screen and viewports in the default state, before application updates.

Draw references include all pages and templates. The initial estimate follows selected pages, closed drawers and hidden groups. Budget preloaded and retained images, application-created instances, runtime images and animation/vector buffers separately. Use esp_gsp_media_stats() to inspect runtime cache usage and peaks. runtime_peak_bytes is reserved for runtime measurements and is null in compiler-only reports.

Prefer the portable codec names auto, speed, size, raw, lossless, and jpeg. With a separately installed GSPC, check that gspc compatibility lists the requested modes in compiler_features.image_policy_modes. The source-tree compiler supports these modes. codec: "auto" (or an omitted codec) uses the Profile’s image_codec policy; per-image speed and size override that policy. With Profile image_codec: auto, GSPC selects STORE, QOI/RLE, or hardware JPEG using target capability, cache budget and compression gain. speed weighs runtime work: STORE for small images, QOI/RLE when compression is strong, and hardware JPEG/JPEG+A8 when eligible. size compares actual encoded bytes and can use software JPEG. JPEG quality defaults to 85; set quality (1–100) to change it. For exact pixels after resizing and conversion to the target pixel format, use lossless or set image_auto_allow_lossy: false in the Profile. RGB565 quantization still applies.

Set "dither": true on an image or compiled animation to reduce banding introduced by RGB565 quantization. The default is off. Profile image_dither: true enables it in bulk; per-image dither: false opts out. The 4×4 ordered pattern applies only to smooth, opaque regions; flat fills, sharp edges, transparent pixels and native RGB565 colors receive no added noise. RGB888/ARGB8888 bypass this processing.

The final encoding determines where processing occurs, regardless of whether the source is PNG or JPEG. Native pixels, lossless codecs and compiled animations are processed offline after resizing. Opaque static JPEGs are dithered after decoding and target-size processing, before RGB565 quantization. Decoded-cache hits reuse the result without repeating this work every frame.

Use "codec": "size" to compare actual encoded sizes. When cache and target capabilities allow it, JPEG can stay compressed and be dithered during decoding. auto and speed conservatively retain offline processing to avoid automatically adding decode work. Explicit "codec": "jpeg" with dither: true also supports opaque static images. Check dither_stage, final resource bytes and decode memory in the execution report. Offline dithering can enlarge compressed assets; decode dithering adds time and temporary memory on initial decoding and after cache eviction. RAW size stays unchanged, and the offline path adds no device dithering computation. Reported decode memory excludes some backend scratch buffers; the actual peak also depends on the target and cache configuration.

GIF/APNG/WebP and imported video frames are composed and resized before offline processing. A fixed smooth-region mask and dither coordinates apply to the whole clip, so equal input pixels at the same position stay equal when their neighbors change. Frame differences are computed afterward. Positions that become partially transparent retain their original pixels throughout the clip to avoid switching the pattern during fades. Timing, loop count, alpha, animation compression and memory budgets retain their existing semantics.

JPEG decode dithering uses GRB 1.9 and requires ESP-GSP/simulator 1.9.0; older runtimes reject these resources. compiler_features.image_dither >= 3 in gspc compatibility indicates compiler support. Alpha images use offline processing. Do not explicitly combine dithering with JPEG+A8, JPEG animation frames or store_scale < 1. The Profile switch skips these combinations and vectors; explicit per-image requests receive a diagnostic. External image and animation asset manifests also accept dither. Dithering cannot restore colors already lost in the source; alpha blending, runtime scaling and the panel can still affect visible banding.

For opaque RGB565 static images already encoded as QOI, GSPC tries native-equivalent palette colors and keeps only a smaller stream. This adds compilation work while preserving decoded pixels and decoder workspace.

Hardware JPEG needs both dimensions to be at least 64 pixels. For RGB888 alpha, auto and speed also require 16-pixel alignment before choosing JPEG+A8. size and explicit jpeg accept unaligned dimensions but may need MCU scratch storage at decode time. size includes that scratch estimate with the decoded image when checking its candidate budget; other allocations still affect the actual memory peak. JPEG+A8 has lossy colour and lossless alpha. PNG is an opt-in candidate for compiled auto and size images under the target’s decoded-image cache budget. Enable it with IMAGE_PNG (--image-png). When the policy permits lossy encoding, IMAGE_PNG8 (--image-png8) uses the quantized PNG candidate. Compare builds with IMAGE_PNG and IMAGE_PNG8 for your assets. Smooth gradients can encode smaller with IMAGE_PNG. DEFLATE_ZOPFLI (--deflate-zopfli) can shrink automatically selected PNG payloads, while explicit codec: "png" uses the standard encoder. For size with store_scale < 1, an eligible JPEG smaller than QOI is selected before PNG is evaluated. The decoder inflates the whole PNG image, so check encoded size, first decode time and peak decode memory. The compiler and diagnostics also accept the existing names store (raw), qoi (lossless), default (auto), and explicit rle16 (opaque RGB565), rle16_a8 (alpha RGB565), and rle32 (RGB888). An incompatible explicit RLE request is a compile error. The ARGB8888 overlay profile stores native pixels only; other explicit codecs and store_scale are diagnosed at compile time. cache_policy also applies to auto, speed, and size. mmap_direct is valid only for STORE; requesting it for a compressed result is a compile error. Existing scenes may specify preload or decode_lru for STORE, but STORE still uses direct mapping and does not enter the decoded-image cache. New scenes can omit those settings for STORE. hardware_jpeg retains its compatibility behavior: JPEG with a hardware decoder, lossless encoding otherwise. It is not an alias for explicit jpeg.

Select caching and input ownership by workload

Section titled “Select caching and input ownership by workload”

cache_key reuses decoded pixels. With image caching disabled, QOI/RLE still region-decode during rendering; a zero whole-frame decode counter does not mean no decoding work. COPY copies each encoded input even on a decoded-cache hit. For immutable data that remains valid throughout its use, such as linked Flash constants, BORROW with its required on_release avoids that copy. A temporary receive buffer cannot simply be changed to BORROW.

A C3 low-memory bundle commonly disables image caching. Frequent tint updates or a small reused image set can benefit from an explicit override after the generated configuration helper. Size its budget using decoded dimensions, simultaneous in-flight images and the largest free block. This 48 KiB example was measured for a workload with 96x96 vectors and 80x60 images; it is not a default for every C3 app:

esp_gsp_config_t config = gsp_bundle_config();
ESP_ERROR_CHECK(esp_gsp_config_set(&config, ESP_GSP_FIELD_ENABLE_IMAGE_CACHE, 1)
== ESP_GSP_CONFIG_SET_OK ? ESP_OK : ESP_ERR_INVALID_ARG);
config.image_cache_bytes = 48U * 1024U;

Caching can add a decode task and cache-entry metadata as well as retained pixels. Tracked image payload is not the total RAM increase. One-off new images can be slower because of queueing, publication and full-frame allocation. After reducing a budget, check first requests, P95, P99/maxima, re-decodes, page visibility changes, full repaint and release after stop. Hot-loop P95 alone can hide new misses. Compiled placeholders can be shared by several controls; replacing one dynamic target must leave their eviction to the cache budget and scene lifecycle.

The compiler process separately caches encoded images: up to 128 request keys and 32 MiB of unique retained payload by default. Use the global --encoding-cache-bytes flag or GSPC_IMAGE_CACHE_BYTES for a different host budget; zero disables retention while compilation still succeeds. The daemon’s cache/imageStats and cache/configureImages expose usage and immediate budget changes. These settings affect compiler reuse, while the target Profile’s image_cache_budget_bytes controls device decoded-image memory. A host budget below the working set can increase repeated encoding. These controls require compiler_features.image_encoding_cache: 1 in the compiler’s compatibility or doctor report; older tools can compile without them.

The current *.execution.json contract is schema version 3. It adds optional animation.spatial_compaction metadata to the resource reachability and nullable decode-size fields. Consumers should select the schema by schema_version rather than by the GSPC product version: use config/schemas/resource-execution-plan.schema.json for version 3 and the preserved resource-execution-plan-v2.schema.json in the same directory for older version 2 reports. Update strict report readers before using GSPC 0.11.0; the report change does not alter compiled binary resource formats.

The strict schema accepts all four Profile policies: default, auto, speed and size, plus the animation_speed_hardware_jpeg flag. Resource rows and source variants carry uses with nullable authored object indices/names, requested codecs and initial visibility. Unknown procedural selection is counted by image_usage.initial_visibility_unknown_images. Span animations report persistent_span_decode, cache-disabled images report region_decode, and animation scratch_bytes, when present, is workspace in addition to the persistent frame_bytes. These are capability and budget descriptions; device measurements are required before making performance claims.

Each *.execution.json includes a resource_budget summary. resource_blob_bytes counts this scene’s resource blobs, including their headers; image_payload_bytes and font_blob_bytes identify the image payload and font portions. These are not firmware Flash totals: scene GSB, bundle tables/alignment and runtime code are separate, and shared blobs must not be summed across scene reports.

resources[].source_path identifies the input behind a compiled resource. inclusion distinguishes an initial draw, a draw/template reference, and a scene-addressable resource. These labels describe compiled reachability, not actual preparation or residency. source_variants groups multiple encoded variants of one source; their sizes and codecs help identify expensive authored uses, but different variants are not necessarily redundant.

initial_static_set_exceeds_cache_budget is advisory: it compares the initial static decode estimate against an explicit enabled cache budget. It is null for an automatic or disabled cache. An excess can cause eviction; it is not a measured RAM peak or proof of allocation failure. Review esp_gsp_media_stats() before increasing memory. requested_codec: "generated" means per-resource authoring provenance is unavailable; the profile’s encoding policy is reported separately.

Start with the vector image example.

Use .svg in an Image’s image field. GSPC stores these images as compiled curves for runtime rendering. The compiler records the required binary format versions in the output; use the compatibility contract when pairing tools.

Carousel, Flip Card and effect image sets rasterize accepted SVG inputs during compilation. Their resulting bitmap assets follow bitmap sizing and cache rules. Choose a named Image for runtime curve scaling, tinting or morphing.

SVG paths retain their curves and are rasterized at the requested size. Use a decoded-image cache budget large enough for the visible working set when reusing large vectors: an untinted cached surface uses four bytes per pixel, and a tinted mask uses one. Vector surfaces share the scene’s image-cache budget with decoded images and in-flight decodes; bitmap decodes reclaim vector surfaces first. If the budget or allocator cannot accommodate a surface, rendering continues with bounded scratch tiles.

The directory holds up to eight cached vector variants across independent resources, with at most four variants of one source. If its allocation fails, it retries four entries, then uses bounded scratch tiles. The larger directory adds four metadata entries (256 bytes on 32-bit targets) when first allocated. More pixel surfaces can remain resident within the same configured byte budget; actual RAM use can therefore increase while repeated rasterization decreases.

Use a named image with fit, rotation, and scalable as for raster images. For runtime box resizing, author w and h as bounded dynamic fields with semantic properties such as width and height; GSPC generates typed setters. Box resizing changes the drawing area; scale zooms inside that area and is clipped to it. Declared bounds must fit the scene’s coordinate range. Width/height use the framework’s existing 0..100 bounded-property interpolation; wide ranges therefore quantize pixel sizes. Keep bounds close to the intended sizes, or use the Q16.16 scale setter for fine uniform zoom inside the box.

An optional tint color turns a scene image into a monochrome silhouette and generates a set_tint() setter. Without tint, source colors and transparency remain. For a scene Image, image_opacity is a direct 0..255 image-only opacity. Declare "image_opacity": {"default": 255, "min": 0, "max": 255} to generate set_image_opacity(). Literal values below 255 also create this control. The existing literal object opacity multiplies it; background and border styling keep their existing semantics. Alpha scales the completed image once, including overlapping paints, and changing it reuses the same vector cache surface. Whole-vector opacity requires the matching compiler/runtime with GSB 2.22; unchanged opaque vectors retain GSB 2.8. Template vectors still require combined opacity 255 and use static colors and dimensions.

The vector importer supports paths, basic shapes, solid fills, fill rules, static transforms and strokes expanded at compile time. Dash arrays, offsets, caps and joins expand into outlines at build time; denser dashes consume more outline points and retain the same complexity limits. symbol/use and markers that normalize to ordinary paths are expanded at build time. Markers needing effective clipping remain unsupported; expand them to paths in the editor. Non-scaling strokes are diagnosed in attributes, inline styles and stylesheets. Prepare artwork as follows:

  • Convert text and non-scaling strokes to paths in the source editor.
  • Keep painted bounds, including strokes and inherited transforms, inside the SVG viewport. The import diagnostic identifies the element and any overflow.
  • For static gradients, clips, masks, patterns, group opacity or supported filters, explicitly choose svg_mode: "raster" as described below, or export PNG.
  • Export embedded images and external references as PNG; convert text to paths.

Editor metadata, foreign-namespace content and unused gradient definitions are accepted. Single-paint group opacity is folded into paint alpha. A rectangular clip that contains all group paint is redundant and can be removed during import. Other unsupported drawing semantics produce a diagnostic, so select a compatible svg_element or supply the prepared bitmap.

Raster codec, store_scale and cache_policy options apply to bitmap inputs. For vectors, edit source geometry and use the Image size, rotation and scale properties.

The Image field svg_mode defaults to "vector". For fixed artwork that uses static effects not supported by runtime curve rendering, set "svg_mode": "raster" to rasterize the self-contained SVG canvas at the Image’s fixed w/h during compilation. Static linear/radial gradients, clips, masks, patterns, multi-paint group opacity and supported static resvg filters are baked on the host, along with fit and position_x/y.

{"type":"image", "name":"decoration", "w":96, "h":96,
"image":"decoration.svg", "svg_mode":"raster", "codec":"store"}

Use svg_element to bake a named part with inherited transforms, opacity, clips, masks and filters. Its content bounds are cropped within the source canvas. Selection isolates that part from sibling drawing; select the containing group when its effects need several parts together.

In RGB565/RGB888 scenes, the baked image supports bitmap rotation, including bounded dynamic rotation, with the same alpha and decoded-cache requirements as PNG. Rotation uses the image-box center and clips to that box; preserve enough space for the artwork. Use a bounded rotation declaration to expose its runtime rotation control. See the SVG bitmap example.

Raster mode requires fixed baking dimensions, scale 1 and store_scale: 1. Use vector mode for morphing, tint, svg_layout, bounded runtime w/h or image_opacity, and runtime scaling. Vector mode also rejects store_scale overrides; choose the baked w/h or edit the source geometry to change storage size. Text, embedded images, scripts, animation and external resources remain unsupported.

Limit Value
Source SVG size 2 MiB
Output RGBA/native/encoded resource 4 MiB each
Normalized nodes / path points 4,096 nodes / 131,072 points
Nesting depth / filter primitives 32 group levels / 64 primitives
Estimated layer/filter work 64 MiB
Generated XML for svg_element isolation and stylesheet expansion 64 MiB

The layer-work estimate and generated-XML limit bound separate build stages; neither is a compiler peak-memory limit. Existing bitmap cache budgets also apply.

codec: "store" avoids a decoded-image cache buffer at the cost of Flash size; compressed output uses the profile’s decoded-image cache. auto, speed, and size keep baked SVG lossless unless codec: "jpeg" is specified explicitly.

Use svg_element to select a source element/group ID without splitting the asset into separate files. Inherited transforms are preserved and the result is cropped to its painted bounds. Scene x/y/w/h place and size this cropped image, not the original SVG viewport. Give each independently controlled part its own named Image and reuse position, rotation, visibility and color APIs. Duplicate IDs, empty IDs and selections without painted geometry are errors.

For composite artwork, use svg_layout: "canvas" and give all parts the same authored x/y/w/h canvas rectangle. GSPC derives placement and emits tightly bounded curves with subpixel alignment preserved; it does not retain a full canvas pixel cache per part. X/Y move that part’s canvas position; image rotation and in-box scaling operate on the selected part. Canvas layout clips rotation/zoom to the image box. It requires svg_element, static W/H and the default fit: "stretch". Authored style/hit bounds remain the canvas rectangle; define interactive regions on parent controls explicitly. Use content layout for template images. Omitting the field, or choosing content, retains cropped-image placement.

Run gspc svg-info artwork.svg, optionally with --element iris, to inspect canvas size, element IDs, stroke-inclusive normalized bounds, path/point counts, cache estimates and compatibility reasons. The JSON supported field indicates whether the source geometry can be compiled. The default element list is capped at 256 entries; elements_truncated reports truncation and --element can inspect a specific ID. This checks the source, not a scene’s authoring options, a morph pair or the final target budget; build the actual scene too. A viewport-overflow reason identifies the source file and element (or unnamed selection), then reports the viewport, selected bounds, actual painted bounds and excess on each side. Where a revised viewBox passes the ordinary vector compiler, the diagnostic also gives that value. Changing the viewBox changes the canvas mapping; check the intended placement after recompiling. A selected compatible part can be imported without rendering unrelated decoration groups that need unsupported effects.

morph_to supplies an end-state SVG; morph is the initial 0..100 percent progress, defaulting to zero. Generated set_morph(), animate_morph() and animate_morph_to() use the existing property/animation APIs. See the vector motion example. The runtime interpolates curve points without XML parsing or full-frame bitmap sequences. Both states must have identical viewport dimensions, paint order/colors, contour structure and segment types. Preserve path start points and directions. To align curve degrees, convert the corresponding segments in the editor and inspect both states. Duplicate the source and edit node positions to keep corresponding points aligned; the compiler checks structural compatibility. Selected elements use a shared union of both endpoint bounds, so morphing does not recrop or shift the image. Use morphing on named scene Images; template images use static geometry.

Vector Image input supports up to 2 MiB, 128 fill/stroke draws and 8192 outline points. Vector images support RGB565/RGB888 scenes. Rendering cost and memory use grow with image dimensions and complexity; measure continuous scaling, rotation and morphing on the target device. See memory configuration.

Use the execution plan’s vector summary to inspect asset complexity and memory estimates. These estimates do not include total application memory. Keep SVGs self-contained and drive animation through GSP properties. Compare imported artwork with a reference image.

Vector applications require additional Flash and RAM. The render-task stack is automatically raised when needed (at least 32 KiB with the supplied build); larger application settings remain effective. Include this in memory planning. Source builds without dynamic font support link only the outline rasterizer; enabling dynamic fonts, including in prebuilt packages, retains the full font engine. Compare firmware sizes using the same build mode and font features.

Reference assets relative to the scene file:

{
"type": "image",
"parent": -1,
"x": 24,
"y": 24,
"w": 64,
"h": 64,
"image": "assets/status.png",
"codec": "auto"
}

Set font and default_font_size on the scene or override them on a text element. The build tracks referenced assets and rebuilds the bundle when they change.

For runtime text with a known vocabulary, set font_charset_file on the scene or text object to a UTF-8 corpus such as assets/ui-words.txt. Paths are relative to the scene; an object path overrides the scene path. GSPC merges its characters with font_charset and authored text, removes duplicate characters, and ignores an initial BOM and CR/LF line separators. Editing the corpus rebuilds the bundle. The generated set_text() helpers use these baked glyphs without FreeType.

The optional scene-level font_max_bytes sets a positive byte limit for the sum of generated GFB resources across all fonts and sizes, before external linking. An over-budget build reports the required bytes; it does not remove characters or change rendering quality. This budget excludes dynamic font files, glyph-run storage and runtime caches. Existing resource reports list each font’s size, glyph count and character set; compiler diagnostics identify missing codepoints.

Compiled fonts contain the glyphs reachable from authored text. If runtime text may contain glyphs that are unknown during the build, add a dynamic TTF/OTF font:

gsp_add_bundle(${COMPONENT_LIB}
SCENES "../scenes/chat.json"
PIXEL_FORMAT rgb565
DYNAMIC_FONT "../scenes/assets/NotoSansSC-Regular.otf")

Dynamic fonts are an optional link feature, including in prebuilt components. DYNAMIC_FONT enables it automatically; applications supplying a font blob at runtime must call gsp_enable_freetype() in CMake. AOT-only applications do not link the full font engine. The outline rasterizer used by vectors remains available independently.

With dynamic font fallback, each static GFB can contain up to 32768 glyphs. UI startup rejects larger packs in this combination. Static-only GFB packs can contain up to 65535 glyphs.

Dynamic fonts use additional code, heap, and task stack. The glyph cache reserves entries × max_px² bytes of pixel storage, plus metadata, using the effective per-instance capacities. Their defaults come from CONFIG_ESP_GSP_FREETYPE_CACHE_GLYPHS and CONFIG_ESP_GSP_FREETYPE_GLYPH_MAX_PX; instance overrides also affect this cost. Glyphs larger than the cache slot use one reusable heap workspace and are rasterized again on repeated use; the cache dimension is not a maximum renderable font size. FreeType working memory and this workspace are additional to the cache. Size these from the actual character set and workload. See fonts on SD for streaming fonts with bounded caches, CFF support and the font-file lifetime.

Give the element a stable name, rebuild, and use its generated helper:

ESP_ERROR_CHECK(gsp_status_temperature_set_text(ui, "24.5 C"));
ESP_ERROR_CHECK(gsp_status_battery_set_value(ui, 82));

The exact helper depends on the element type and dynamic property. Inspect the generated header after every scene-interface change. When several scalar properties must become visible atomically, use the public component batch API instead of depending on the order of separate asynchronous setters. See right-to-left text for runtime BiDi.

For repeatedly drawn transparent assets, compare direct STORE reads with a lossless codec such as "codec": "qoi" and "cache_policy": "decode_lru". The decoded surface can reside in PSRAM and be reused, but the first decode, decoded pixel budget and eviction/redecode costs must be included. STORE is drawn directly from its source; setting preload on STORE does not copy it into the decoded cache. Changing only the cache budget will not move STORE assets. Use preload only for a measured hot working set that fits alongside other images: these entries are excluded from normal LRU eviction. For example, a 320 × 240 ARGB8888 surface needs 307,200 bytes of pixel storage regardless of its compressed size. This tradeoff needs measurement on the target; it is not a reason to preload all assets or change the default codec globally.

On devices with PSRAM, default decoded image surfaces, resize staging, PNG scratch and copied encoded inputs use PSRAM without spilling into internal RAM on allocation failure. Devices without PSRAM continue to use internal RAM. TAKE/BORROW placement remains the caller’s choice. Hardware JPEG scratch is released before growth, on allocation pressure, when image caches are released on pause, and on application destruction. After one idle second it is reclaimed only when the next hardware decode does not need it. A sufficiently sized surface still needed by the next job is reused. There is no background expiry timer. Scratch is recreated lazily when needed.

P4/S31 hardware JPEG decoding preserves JFIF’s full-range YCbCr. Eligible 4:2:0 streams decode into packed YUV420 scratch (1.5 bytes per padded pixel), then PPA converts with the full-range matrix into the aligned PSRAM RGB target. PPA rounding and RGB565 quantization can differ from the software decoder. Other sampling, unaligned/internal targets and unavailable PPA use YUV444 scratch (3 bytes per padded pixel) plus CPU conversion; RGB888 can reuse a suitable target in place. Encrypted-PSRAM exemption builds keep the CPU conversion path. Hardware failures retain software fallback. Include shared YUV scratch and conversion time when measuring memory and performance; hardware JPEG decode counters include conversion.

Resize staging includes MCU height and cache alignment padding while preserving logical dimensions and packed source rows. Image allocations align pixels and their private prefix to at least 64 bytes and the allocated heap’s cache line. Images needing MCU width padding keep the existing path, including its scaler. Reservation can reclaim idle hardware scratch without waiting for an active JPEG job. It does not clear the full staging buffer under the cache lock or fall back to SRAM. Cancellation and decode completion release the staging allocation; no new setting or persistent frame buffer is required. Other JPEG paths can still require scratch, and hardware failures retain the software fallback. The hardware JPEG wait now includes tick rounding and phase allowance for its 40 ms budget: the driver receives 50 ms at a 100 Hz FreeRTOS tick rate, or 41 ms at 1,000 Hz. This prevents an early timeout caused by tick quantization; it does not guarantee completion under arbitrary contention. A stalled job can wait longer by the tick allowance before falling back to software.

Region rendering of QOI/RLE images can retain eight decoder checkpoints per scene after first use, avoiding repeated stream-prefix scans across stripes. Text scenes may also allocate a 1 KiB metrics cache, reused across stripes and cleared at frame start. These optional metadata allocations use PSRAM exclusively when present; without PSRAM they use internal RAM. Allocation failure keeps the uncached path. They are retained until scene-context destruction and excluded from image payload statistics and image_cache_bytes.

Demanded images take priority over queued prefetch. Prefetch is best effort: insufficient destination or workspace memory drops it without evicting resident images or poisoning a later demand request. JPEG cache layouts may include MCU padding so hardware can write directly; logical image dimensions stay unchanged and software fallback preserves the wider stride.

esp_gsp_image_memory_stats() in esp_gsp_debug.h reports current and peak tracked payload bytes for default decoded surfaces, COPY/TAKE inputs, staging, and PNG/JPEG scratch, split by internal RAM, PSRAM and other memory. This is a coherent process-wide snapshot across all instances. total.peak_bytes is a simultaneous high-water mark, not a sum of category peaks. Borrowed inputs, custom cache allocators, decoder-library private memory, animation frames, region decode buffers, display buffers, stacks and allocator overhead are excluded. It is not a whole-application memory measurement. The existing esp_gsp_media_stats() reports cache_peak_bytes as the sum of the lifetime peaks of live scene caches. That sum is a conservative bound, not a simultaneous process-wide high-water mark.

esp_gsp_image_memory_stats_t memory;
if (esp_gsp_image_memory_stats(&memory, sizeof(memory))) {
printf("image payload current=%zu peak=%zu psram=%zu internal=%zu\n",
memory.total.current_bytes, memory.total.peak_bytes,
memory.total.psram_bytes, memory.total.internal_bytes);
}

Hardware-capable JPEG targets retain full-decode priority. On workspace shortage, the cache reclaims eligible unpinned, non-preload entries before attempting the software low-memory resize path. Software-only targets can select that path directly. Rows reduce temporary storage; the complete destination still belongs to the image cache. Disabling the cache does not enable JPEG region rendering.

On PSRAM targets, the ESP software path uses the JPEG library’s public block decoder, then applies the same GSP bilinear filter as full native surfaces. GSP reserves at most 16 source rows plus one boundary row. These pixel buffers use PSRAM exclusively when present, or internal RAM on no-PSRAM targets. Vendor scale is disabled, so its extra internal resize workspace is avoided. The library still needs its base decoder state, and this is not a hard internal RAM reserve for other tasks.

No-PSRAM targets retain vendor scaling first, avoiding the extra internal row storage and decode time for small images. If workspace reservation or native scaling fails with NO_MEM, GSP releases the old resize workspace and tries the supported row path at most once. Bad data and unsupported formats do not trigger this retry. Failure keeps the previous image; strategies never alternate in a loop. Row pixels also occupy internal RAM on these targets, so PSRAM-board decoder overhead measurements are not a no-PSRAM total-memory budget.

Block decoding requires source dimensions divisible by eight. Sources no taller than 16 rows retain the full path to avoid reserving more rows than the image. The target must have at most half as many pixels; output dimensions need no eight-pixel alignment and are not limited to vendor scale’s 1/8 reduction. Other source layouts, alpha JPEG and ineligible resizes automatically keep full decoding. Host libjpeg retains its IDCT scaling path; its timings and pixels do not substitute for ESP block-decoder validation.

The entire JPEG is still processed, so block decoding can be slower than vendor scaling. This path bounds pixel workspace and avoids the additional SRAM peak; it is not a universal speed optimization. Both full and block software decoding map JPEG memory shortage to LIMIT_EXCEEDED, insufficient input to TRUNCATED, unsupported format/standard to UNSUPPORTED, and corrupt data to a format error.

Before decoding, the default cache reserves resize staging / JPEG rows, PNG inflate pixels, multi-IDAT concatenation storage when needed, and ESP PNG inflate state. Reservation failure can reclaim eligible cached pixels and retry, protecting pinned old images and preload resources. The allocated destination is retained across these retries. Persistent shortage ends the request before decoding. Reservations are released on cancellation, failure and success; ordinary decode completion releases temporary buffers before publishing the new image. PNG/QOI resize jobs reserve a full-source-size intermediate surface.

image_cache_bytes still limits cached pixels, not total temporary memory. Reservations exclude decoder-library private allocations and shared hardware JPEG scratch; other heap users can still allocate, so this is not a guarantee that every later allocation succeeds. Reservation shortages increment cache_allocation_failures; format validation and decoder failures increment cache_decode_failures. Failed replacements keep the previous image visible.

Give the image a name, a bind, and bind_target: "resource", then use its generated set_image() helper for occasional PNG, JPEG, QOI, or other supported encoded input. The generic public API offers three ownership models:

API family Ownership
esp_gsp_set_image() Copies encoded bytes before returning
esp_gsp_set_image_borrowed() Borrows bytes until the release callback
esp_gsp_set_image_owned() Takes malloc-compatible storage after successful submission
esp_gsp_set_image_ex() Selects COPY, BORROW, or TAKE explicitly

The explicit bind_target keeps the binding on the image resource when the object also has a background color. An image without a background color or text can omit it.

A successful borrowed or TAKE submission can retain the encoded payload while that image remains current, because decoded pixels may be evicted and decoded again. If submission returns an error immediately, ownership remains with the caller and no later release callback runs.

The currently displayed image remains visible while its replacement decodes. If replacement decoding fails, the previous image stays visible.

Completion and release callbacks may submit another image, but must not wait for its completion. The runtime commits or detaches the previous request before invoking application code and completes each accepted request once. A superseded request’s cancellation is reported after its replacement is installed; a request submitted by that callback remains newer.

The authored placeholder, not the replacement, fixes the decoded pixel format. An opaque PNG or JPEG may replace a transparent placeholder (alpha becomes 255). JPEG has no alpha samples; use JPEG+A8 when the replacement carries a separate lossless alpha plane. RGBA and RGB+tRNS PNGs replace an opaque placeholder only when every pixel is opaque. Author a transparent placeholder when the replacement needs transparency. Runtime PNG supports non-interlaced 8-bit grayscale, indexed, RGB, grayscale with alpha, and RGBA. Color keys are compared before native color quantization and produce alpha 0 or 255. Indexed PNG can carry per-entry alpha. Replacement images follow the placeholder’s opacity rules. GSPC can convert supported source files with other bit depths or interlacing.

In GSP native buffers, RGB888 pixels use B, G, R byte order; RGB565 uses native packed 16-bit values. Use this layout for borrowed frames and Direct Draw.

Use Canvas when an external producer owns continuously changing pixels, such as a camera preview, video frame, or live raster plot.

Declare the producer on a named scene Image:

{
"type": "image", "w": 200, "h": 100,
"image": "assets/placeholder.png", "codec": "raw",
"bind": "preview", "canvas": "draw"
}

canvas: "draw" checks direct-draw compatibility; canvas: "push" checks the placeholder for borrowed frame submission and allows supported image transforms and blit opacity. Both reserve an independent mutable resource view, while identical immutable image data stays shared. Ordinary Images keep their existing deduplication. The declaration does not register a producer, allocate frame buffers, or change runtime APIs. It requires a compiler that exposes canvas_resource_views in gspc schema --authoring; compilers without this capability reject the new field.

Use a resource bind (bind_target omitted or "resource") and a static opaque raster placeholder in an RGB565/RGB888 scene. Draw mode additionally requires fixed opacity 255, fit: "stretch"/"fill", scale/store_scale 1, scalable false, and omitted or fixed rotation: 0. Draw mode does not generate a runtime rotation setter; use push mode for runtime rotation. Push mode preserves the existing transform/cache requirements; frames must match the compiled placeholder’s native dimensions, which can differ from the authored box when fit/scaling is enabled. Transparent, SVG and animated placeholders, ARGB8888 scenes, and list/template instances are rejected. esp_gsp_canvas_check() checks direct-draw compatibility, so it can reject a transformed push target. Existing scenes without canvas keep their behavior and still rely on runtime admission checks.

Independent views still consume the configured Canvas slot pool. The current default is 2 active producers; size ESP_GSP_CANVAS_SLOTS or the per-instance ESP_GSP_FIELD_CANVAS_SLOTS override for the maximum simultaneous producers (currently 1–8). Merely declaring a target does not occupy a slot; installing a callback or submitting a frame does. Queue acceptance remains distinct from Canvas admission; observe the Canvas result/release callbacks.

The frame-push API accepts complete or dirty frame updates and borrows each buffer until its release callback. Do not reuse or free a submitted frame before release.

When the producer can draw a requested region directly, register a direct-draw callback:

ESP_ERROR_CHECK(esp_gsp_canvas_set_draw_cb(
ui, GSP_BIND_SCOPE, draw_scope, state));
ESP_ERROR_CHECK(esp_gsp_canvas_invalidate_dirty(
ui, GSP_BIND_SCOPE, dirty));

The callback receives a temporary native RGB565 or RGB888 surface. It runs inside rendering, must fill every supplied region, must return promptly, and must not retain the surface pointer. Stop and synchronize before releasing its context:

ESP_ERROR_CHECK(esp_gsp_canvas_stop(ui, GSP_BIND_SCOPE));
ESP_ERROR_CHECK(esp_gsp_flush(ui, 250));

Direct drawing requires an unscaled opaque image target. Use frame submission when scaling, alpha, or producer ownership makes direct drawing unsuitable.

Lists and Wheels keep a bounded number of visible row instances. The application binds a logical collection once, publishes content for requested items, and refreshes when backing data changes.

static const char *s_contacts[] = {"Ada", "Linus", "Margaret"};
static gsp_err_t bind_contact(esp_gsp_handle_t ui, esp_gsp_row_t row,
uint32_t item, void *user_ctx)
{
(void)user_ctx;
return esp_gsp_row_text(ui, row, s_contacts[item]);
}
esp_gsp_list_t contacts = gsp_home_contacts_bind(
ui, bind_contact, NULL);
if (contacts != ESP_GSP_LIST_NONE) {
ESP_ERROR_CHECK(gsp_home_contacts_set_total(
ui, contacts, sizeof(s_contacts) / sizeof(s_contacts[0])));
}

Bind each logical collection once for the UI lifetime. Rows are recycled while scrolling; the row handle is valid only during the binder call. Use the row token supplied by the framework so an asynchronous result cannot be published into a row that now represents another item.

For composite row templates, use esp_gsp_row_set_text(), esp_gsp_row_set_value(), esp_gsp_row_set_color(), or esp_gsp_row_set_image() with generated template slot constants. After replacing backing data, call the generated gsp_<scene>_<list>_refresh().

Declare an image inside a row template with "dynamic_image": true. The Grid binder publishes content only for visible and retained spare cells, so the runtime does not allocate one image target per item in the dataset.

Use a stable nonzero cache_key with esp_gsp_grid_cell_set_image_ex() when immutable encoded content is reused across recycled cells. Change the key whenever the encoded bytes change. A zero key preserves per-submission cache behavior.

Size ESP_GSP_FIELD_DEFAULT_DYNAMIC_IMAGE_SLOTS for simultaneously active targets—normally visible cells plus overscan—not the total gallery size.

Use message_list for chat-like data whose visible rows can have variable content and extent. Keep the message store in the application. Notify the framework when data is appended, prepended, replaced, or refreshed rather than rebuilding the scene structure.

After binding a visible list, esp_gsp_list_fling() can be called immediately; the command activates the list before starting motion. To preserve visible history when prepending messages, keep their IDs stable and pass the inserted count to esp_gsp_message_list_changed(). The framework rebinds recycled rows to the corresponding messages as it adjusts the scroll anchor.

As with Lists and Grids, row publication runs in framework callback context. Publish already available data and defer storage, networking, or slow decoding to application tasks.

Initialize esp_gsp_message_source_t to zero and set struct_size to its size. The default flags = 0 retains text-hash validation, including detection of text changes whose revision was not updated. Legacy source structs without the flags field retain that behavior.

Data sources that maintain reliable revisions may set flags = ESP_GSP_MESSAGE_SOURCE_TRUST_REVISION. An unchanged id/revision pair then allows the framework to reuse text measurements without scanning the text. IDs identify messages rather than array indices; preserve them across insertion and reordering, and change the revision for text or decoration changes. Reusing a pair for different content can leave stale pixels. This still reads each message’s metadata; it is not a range-update API.

Keep one coherent source during reconciliation. Publish changes on the render task or retain an immutable snapshot for readers; the revision flag does not synchronize background producers. Returned text must remain valid until the next get() call. Append/prepend notifications and failure retries retain the existing esp_gsp_message_list_changed() behavior.

  • ESP_GSP_FIELD_CONTEXT_DEFAULT_INSTANCES covers simultaneously live template instances and recycled rows.
  • ESP_GSP_FIELD_DEFAULT_DYNAMIC_IMAGE_SLOTS covers simultaneously active runtime image targets.
  • List slot and per-row text capacities are configured limits and are checked during scene generation where possible.
  • image_cache_bytes bounds decoded image retention, not the encoded source payload owned by the application.
  • Disabling the image cache changes which runtime image paths are available; review Configuration before using it on a no-PSRAM target. For no-cache runtime QOI updates, use a fixed-size fit: "stretch" placeholder and encode replacements at its native dimensions. Fitting/scaling an encoded runtime replacement requires decoded pixels in the image cache. A successful setter only confirms submission; use esp_gsp_set_image_ex() completion to confirm publication and diagnose rejected replacements.

For exact callback and shutdown behavior, see Application lifecycle.

Local MP4, AVI, MOV, WebM and MKV files can be imported through the same image field. GSPC uses optional host tools ffmpeg and ffprobe; install FFmpeg or set GSPC_FFMPEG and GSPC_FFPROBE to their executable paths. Ordinary images and GIF/APNG/WebP animations do not need either tool. FFmpeg 4.4 or newer, including 8.x, is supported; actual container/codec support depends on that FFmpeg build. Check compiler_features.video_import: 1 in gspc compatibility when using a separately installed compiler.

{"type":"image","name":"intro","x":0,"y":0,"w":240,"h":240,
"image":"assets/intro.mp4","video_start_ms":1000,"video_duration_ms":3000}

Videos are decoded at build time to ordinary GSP animation resources. Audio, subtitles and cover art are excluded. Device playback uses the existing frame codec and player; the device does not need FFmpeg or an MP4/AVI decoder. Source video compression is not retained, so a small MP4 can produce a large bundle. The existing codec, animation_codec, quality and target Profile policies still select the compiled representation; video input does not force JPEG. dither: true uses the existing lossless-animation RGB565 processing; an explicit JPEG-frame request with dithering produces a compile-time diagnostic.

Field Video behavior
max_fps Omitted: normalize to at most 30 fps without raising the nominal source rate. Positive: use that cap. Explicit 0: keep source presentation timestamps, including VFR.
video_start_ms / video_duration_ms Start at 0 by default; omitted duration imports to the end. An empty/out-of-range clip fails.
video_fit contain (default, opaque black padding), cover (center crop), or stretch. Inherits an explicitly authored Image fit unless overridden. Baked at the authored width/height, before runtime transforms.
video_loop_count 1 by default; 0 repeats forever. Existing animated-image loop defaults are unchanged.
video_max_decoded_bytes Retained host RGBA pixels, default 268435456 bytes (256 MiB).
video_max_frames Decoded frames before identical-frame merging, default 4096; maximum 65535.

Rotation metadata and sample aspect ratio are applied before fitting. Cumulative timestamps are rounded to milliseconds, preserving fractional-rate timing without rounding every frame period separately. HDR (PQ/HLG) must first be converted to SDR explicitly; unsupported/corrupt inputs fail with FFmpeg diagnostics.

Known durations are checked against the import budget before decoding; actual output is checked as it streams. Limits and the 120-second timeout per tool fail with suggestions instead of silently truncating the clip. The RGBA budget is not a total process-memory limit: decoder buffers, RGB565 normalization and encoded candidates add memory. Device frame/decoder/display memory remains separate and must fit the target Profile and runtime configuration.

The same fields work in external asset manifests. Videos and resolved tool executables are included in build dependencies. Reconfigure CMake after changing tool selection through environment variables or PATH. Measure target playback separately; an import frame rate is not a device FPS promise. These options apply only to video inputs.

Uniform-color and row-uniform animation frames

Section titled “Uniform-color and row-uniform animation frames”

With codec: "size", a decorative Image with fixed stretch geometry can store an animation as 1×1 frames when every compiled frame has one uniform RGBA color. When colors vary only between rows, it can instead store one RGBA sample per row as 1×H frames. All frames must meet the same condition. The authored display rectangle, frame durations and loop count stay the same. Compaction uses lossless encoding; RGB565 dithering runs before eligibility is checked, so a spatial dither pattern is never discarded to make a row uniform.

The execution report’s animation.spatial_compaction record explains the representation, source/stored dimensions and canvas bytes before/after. Here source_dimensions means the compiled frame after resizing and dithering, before compaction; it does not report the original file’s dimensions. Canvas savings do not include context, allocator or decoder overhead, and they do not predict device FPS. The renderer reuses native row fills and alpha blending; unsupported transforms, formats and overlapping buffers retain their normal sampling paths.

For opaque frames, a full-size native blit can be faster than stretching a column. Compaction can replace a hardware copy with a fill, scale or CPU draw, depending on the chip, geometry and configured acceleration thresholds. size prioritizes the smaller canvas; use auto to retain the original representation, and measure both decode and render time on the target.

This optimization is limited to GIF/APNG/WebP images without a name, binding, callback, dynamic geometry/opacity or runtime transform. Default/auto policies, named/swappable images, templates, external asset exports, video imports and explicit animation_codec requests keep their original geometry. Existing binary formats and runtime interfaces are used.

Animated images and imported videos accept these animation_codec policies:

Value Compilation behavior
lossless Force QOI delta patches; the default profile retains this behavior
jpeg Full JPEG frames, even when larger than QOI
hardware_jpeg JPEG when the target profile declares hardware_jpeg: true, otherwise QOI
{"type":"image","name":"motion","x":0,"y":0,"w":256,"h":256,
"image":"assets/motion.png","animation_codec":"hardware_jpeg","quality":85}

Opaque animations use JPEG. If any frame has transparency, the entire animation uses JPEG+A8: lossy color and lossless alpha, with no silent transparency removal. GIF/APNG frames are composited onto complete canvases before encoding; frame durations and loop counts are preserved. max_fps still caps the imported frame rate. Explicit codec: "jpeg" also works for animations; animation_codec takes precedence when both are present. With animation_codec, omitted quality uses the profile’s jpeg_quality.

Holds longer than 65,535 ms are split into compatible frame entries that share compressed patch bytes. Merging unchanged frames and max_fps decimation preserve their accumulated duration. Compilation rejects sequences exceeding the container’s 65,535 frame entries, 65,535 finite loops or 32-bit payload offsets instead of truncating them. Reports count patch work for each replayed hold entry.

Rebuild external asset packages together with generated headers when long holds add entries.

JPEG mode decodes and redraws complete frames. It trades resource space for hardware decoding, while sparse UI animations may benefit more from QOI patches. animation_frame_budget_bytes limits compiled animation canvases and workspaces, including the second JPEG canvas and the embedded EAF4 decode and pixel repacking workspace. Resource reports list encoded Flash size and distinguish anim_qoi, anim_jpeg, anim_jpeg_a8, and anim_spans.

animation_max_players is a separate per-scene Profile limit for independent compiled animation resources. It defaults to 4 and can be raised in the YAML Profile passed through --profile or gsp_add_backend(... PROFILE ...). On devices, CONFIG_ESP_GSP_MAX_ASSET_ANIMS=0 derives the runtime capacity from Bundle requirements; explicit project or instance limits must still cover those resources. Hidden animations can pause, but their compiled resources still count toward the player limit.

Without animation_codec, auto, speed and size first compare QOI with native-pixel patches (GRB 1.6). Native patches preserve RGB565/RGB888 and full A8, copy directly into the existing canvas without an extra frame buffer, and are selected when an animation saves at least 2 KiB (including patch headers and tables) and meets image_auto_min_savings_percent for auto/speed.

For embedded opaque RGB565 animations, these automatic policies also consider precompiled spans (GRB 1.8). The compiler preserves the selected frame timing and damage regions, uses a shared palette where suitable, and plans pixel reuse before playback. The player applies that plan to its existing canvas without a second frame buffer or per-frame allocations. Selection compares the final deduplicated resources retained by each scene, including enabled compression. auto/speed require each replacement to save at least max(10%, image_auto_min_savings_percent); size requires a smaller payload. The aligned resources must together save at least 8 KiB for the shared decoder in that scene. This is a per-scene selection allowance, not a linker size measurement or a reserve pooled across scenes. Planning adds compiler work and transient memory; measure compile cost as well as device playback. Explicit animation_codec, the default QOI policy, alpha animations, RGB888 and external streaming retain their existing resource encodings. Resource reports identify the selected span representation as anim_spans.

With codec: "size", GSPC retains the lossless alternative until grouped compression and span selection finish, then compares it with JPEG. Core-player encodings remain available when spans cannot cover the shared decoder reserve. This can add compilation work and temporary memory; auto, speed, and explicit animation encodings keep their selection policy.

For smaller embedded animations, enable CONFIG_ESP_GSP_ENABLE_ANIM_DEFLATE=y and select Profile image_codec: size or Image codec: "size". GSPC then groups up to four frames into zlib streams: ordinary patches allow at most 32 KiB of decoded group data (GRB 1.7), while spans allow at most 64 KiB (GRB 1.8) when savings reach at least 8 KiB and 10% within the scene’s animation budget. Standalone GSPC also accepts --animation-deflate or Profile animation_deflate: true.

This option defaults to off and leaves explicit animation_codec, JPEG, and external streaming resources unchanged. Execution reports expose each animation’s scratch_bytes; the player allocates this workspace once and reuses it across groups. With PSRAM present, AUTO requires that workspace in PSRAM without internal-RAM fallback; without PSRAM, include it in the SRAM budget. Compression adds decoding work, especially at group boundaries; measure frame times with the matching runtime. If a frame exceeds its representation’s group limit, the compiler retains the uncompressed representation and reports GSPC-ANIMATION-DEFLATE-SKIPPED. Increasing the animation memory budget alone does not change these format limits.

Before span selection and optional group compression, size compares the QOI/native lossless result with JPEG/JPEG+A8. Only a retained lossless result can be replaced by spans. Set Profile image_auto_allow_lossy: false when lossless color is required. auto and speed consider hardware JPEG only when the Profile sets animation_speed_hardware_jpeg: true, lossless patch work after the first frame reaches at least 70% of the corresponding full-frame work, frames are opaque, and each dimension is at least 128 pixels and 16-pixel aligned. auto also requires at least 20% encoded-size savings; speed permits up to 10% growth. The board setting defaults to false and should follow a measurement of its display path. Set hardware_jpeg: true and animation_speed_hardware_jpeg: true in a measured board Profile to enable this choice. auto and speed retain lossless patches for transparent animations. With lossy encoding allowed and JPEG+A8 available, size can choose a smaller JPEG+A8 result. An explicit animation_codec always takes precedence. Animations use a separate frame buffer; cache_policy and store_scale are static-image options and are rejected on animations.

Lossless compiled animations keep one native pixel canvas. The first frame is fully decoded before publication. Before each later frame’s first update, the runtime checks the frame’s patch or span data without writing pixels. Invalid content freezes playback on the last valid frame; its pixels, frame index and timeline remain unchanged. Playback visits frames in order, so an in-player validation progress marker reuses the results on later loops without allocating a heap cache or second pixel canvas. Keep borrowed animation bytes immutable until the player is closed. The first traversal includes frame validation; include this first-use cost when measuring playback latency.

QOI region selection also considers bounded row-span candidates for thin or irregular changes. The default retains the original candidate unless stored bytes, pixel work and the existing per-region call-cost proxy do not increase. The existing speed image policy may allow up to 10% growth per frame, including patch-table bytes, when extra regions save enough pixels. This remains the same QOI animation format. More regions can increase display-window overhead; measure the target’s decode, rendering and presentation together.

JPEG color conversion can differ between hardware and software decoders. Use lossless for icons, brand colors and other UI assets that need consistent color; JPEG+A8 preserves alpha, not exact RGB values.

Omitted quality uses the Profile’s jpeg_quality, for embedded and filesystem images alike. An explicit value also applies to automatic JPEG selection. hardware_jpeg falls back to lossless encoding when the Profile lacks hardware JPEG.

For codec selection, compile with lossless and jpeg and compare the generated *.execution.json: resources[].encoded_bytes reports the complete encoded sequence size, animation.frame_bytes the persistent pixel canvas, and animation.patch_ratio the pixel-write work relative to full-frame decoding. Copying and then replacing pixels can make this ratio exceed 1. Animation flash_savings_bytes and flash_savings_percent are null because a single canvas is not a full-sequence Flash baseline. Compare the actual encoded sizes between builds. These reports do not include SD throughput or total playback time; validate on the target board.

The JPEG decoder chooses hardware or software according to platform, dimensions and layout. Small images may use software; non-MCU-aligned dimensions may need scratch storage. Measure frame reads, alpha processing and display submission as well as decode time. Update GSPC and the runtime together before enabling JPEG animations: older runtimes reject the new frame format. Default QOI animations retain their existing format.

See external assets for preprocessed SD/NAND images and frame streaming.

For SD fonts, use the font-file API with an explicit size limit and lifetime.

Transparent rasters, previews and resource budgets

Section titled “Transparent rasters, previews and resource budgets”

In RGB565/RGB888 scenes, RGB565+A8 and ARGB8888 image resources support fit, rotation and bounded dynamic rotation, including template images. The image box clips transformed content and source alpha participates in blending. Object opacity must still be 255. For a fixed, unbound static raster, a literal image_opacity can instead be baked into source alpha when codec is omitted, auto, or store, and store_scale is 1; the result uses STORE. This does not create a runtime opacity control for the raster. Transparent transforms use software sampling. codec: raw needs no decode cache, while compressed resources require sufficient decoded-image cache space. Encoded Flash size is not the runtime pixel-memory budget.

For camera/decoder frames, author an opaque Image placeholder with a bind, then use esp_gsp_canvas_push() or esp_gsp_canvas_try_push(). Frames must match its dimensions and the target RGB565/RGB888 format. Use at least two producer buffers and reuse frames only after the release callback. Use Image setters for occasional replacements; see external assets for filesystem resources.

Prefer codec: auto across chips; use speed or size for a specific resource goal. Explicit jpeg is a strict requirement; incompatible targets diagnose the alternative. Without JPEG, use QOI/RLE lossless encoding and explicit store_scale where reduced detail is acceptable. Smaller stored images need a scaling-capable container codec and enough decoded cache. Budget the decoded surface alongside the Flash saving. Compare the image/font/bundle byte report with the application partition budget; the compiler never silently reduces resolution. Font diagnostics list all missing codepoints and identify authored text-use paths. Custom fonts without a question mark receive a visible replacement box instead of aliasing the first icon.

store_scale < 1 automatically selects fitting into the authored image box; it does not require the additional scalable flag. With reduced storage, auto and speed use QOI, while size compares scaled QOI with eligible JPEG. Explicit raw is unsupported for this option and diagnoses the object path and alternative encoding at compile time. Ordinary and template images share option parsing. Compressed thumbnails still require a decoded-image cache.

Prefer original PNG and TTF/OTF sources when migrating. For LVGL C arrays or private binary assets, establish the LVGL version, pixel format, channel order, stride, alpha convention and compression before converting to supported input resources. A 32-bit pixel width alone does not determine channel order; private .bin files are not a single standard format.

JPEG decoding is enabled by default for compiled resources, runtime images and external assets, including hardware-to-software fallback. If the application never uses JPEG, omit its decoder code from the firmware with:

CONFIG_ESP_GSP_ENABLE_JPEG=n

For an existing project, clear Link the JPEG decoder under ESP-GSP in idf.py menuconfig. New projects can place the setting in sdkconfig.defaults. The option works with source and prebuilt components and takes effect at link time. Keep the component’s build files and archive from the same release.

gsp_add_bundle() and gsp_add_assets() pass --disable-jpeg to GSPC. Explicit PROFILE settings remain supported: JPEG is excluded while other capabilities and custom budgets are preserved. A profile allowing only JPEG produces a configuration error; declare the required non-JPEG codecs or keep JPEG enabled. Standalone builds should pass the same flag. CMake checks compiler support during configuration and explains how to update an incompatible compiler.

  • For still images, codec: auto can use the remaining supported encodings. IMAGE_PNG8 still follows the profile’s image_auto_allow_lossy policy. An explicit codec: "jpeg" produces GSPC-RS-CAPABILITY; this also covers its derived jpeg_a8 output for transparent images.
  • For animations, use animation_codec: "lossless". An explicit animation_codec: "jpeg" produces the same diagnostic; changing codec alone does not override it. animation_codec: "hardware_jpeg" selects lossless frames when JPEG is disabled.

PNG, native pixels, supported lossless rasters, compiled SVG and QOI animations remain available. Container probing can still identify JPEG. Decoder selection is explicit, so an application with no bundled JPEG can retain support for JPEG images supplied later at runtime.

An accepted runtime-image request containing JPEG completes with GSP_ERR_UNSUPPORTED before a decode surface is reserved. Use the completion callback to observe the result; buffer ownership and release rules are unchanged. Externally compiled bundles and asset packages are checked when their JPEG resources are used. Compiled JPEG animations fail when opened, and external JPEG frame streams fail before allocating a frame canvas.

The software decoder dependency remains part of component resolution. JPEG code can still be linked if another component uses it. Host and WASM/WASI simulators retain their codec support; successful preview alone does not establish that a device built with JPEG disabled can display the same external JPEG data.

ESP-IDF builds can use the esp_new_jpeg software decoder on targets such as ESP32-S3. gsp_add_bundle/gsp_add_assets detect that dependency independently of the hardware JPEG engine and require a usable decoded-image cache for static JPEG resources. Standalone platform compilation can declare --software-jpeg. This enables explicit codec: "jpeg"; software availability alone does not make auto choose lossy JPEG. A finite declared cache budget must fit the decoded JPEG surface, including its alignment/alpha storage. JPEG saves Flash, not that pixel memory. Animation frame buffers have a separate budget.

Use animate_scale_q16 and animate_scale_q16_to to animate named scalable Images. 65536 is 1× and 131072 is 2×. Call these helpers in the image’s scene and choose values within its declared scale range.

Add a resource bind to a scene image, for example name: "cover", bind: "cover_image", to generate its replacement API. For template images, set dynamic_image: true. Size ESP_GSP_FIELD_DEFAULT_DYNAMIC_IMAGE_SLOTS for the number of simultaneously active image targets in application-created templates.

Build precompiled asset packages with gsp_add_assets() and display them with the bound image’s generated set_asset() helper. Use the generated asset references to select images; they carry the package information required by the API.

For a static RGB565 or RGB888 image, set warp_grid: {"preset":"turn_x","strength":10,"tilt":2} and drive morph from −100 to 100. Zero is the original image. Other presets include turn_y, bend_x and breathe. For a custom bidirectional grid, use {"points":[[0,0],[4,0],[0,0],[6,1]]}. Points are row-major offsets in source pixels. Existing four- and nine-point arrays keep the 0..100 range unless a negative default, a negative absolute keyframe, or a rig morph constraint selects signed motion.

Choose nearest, edge_aa, or bilinear for rotation_filter. Bilinear sampling is suited to fine lines and facial details. Edge filtering preserves crisp opaque interiors. An image-local alpha_mask always samples continuous coverage.

Use a generated set_progress(ui, percent) helper to map a gesture or an audio envelope to the entire clip. A looping blink can set loop_delay_ms: [2200, 4500] or use a fixed duration in milliseconds. Declaring ik_chains generates named reach and release helpers. A rig with aim or look-at constraints also gets rig_look_at. For a two-link arm, give the forearm a nonzero offset from its parent and set end to the wrist relative to the forearm pivot. Motion example

Static EAF transcoding and size optimization

Section titled “Static EAF transcoding and size optimization”

Compile existing Classic EAF/AAF (v1–v3) or EAF4 source assets into native ESP-GSP animations when packaging them in a Bundle.

  • Reference .eaf / .aaf files directly in scene.json (image) or assets.json; gspc decodes them at build time and emits native anim_spans / anim_qoi / anim_deflate / anim_jpeg, allowing firmware to set CONFIG_ESP_GSP_ENABLE_EAF=n.
  • Use gspc eaf-convert for standalone conversion, size audits, or lossless PNG frame export:
Terminal window
gspc eaf-convert emote.eaf --policy size --pixel-format rgb565 -o emote_native.gspb
gspc eaf-convert emote.eaf --export-frames frames_out/

EAF4 source import checks declared frame sizes before inflating and retains up to 256 MiB of decoded RGBA frames per file. Split longer clips or reduce their dimensions if they exceed the limit.

For animations packaged in a Bundle, enable ANIMATION_EAF4 (--animation-eaf4) with the size policy to include EAF4 in the comparison of encoded sizes. Check decoder Flash, playback time and working memory on the target board.

Use standalone files to update animation assets independently of the Bundle or to keep the full compressed file out of RAM. Playback still needs a frame canvas, decoder workspace and storage reads. Validate the exported file before copying it to the device.

For clips already in RAM or mapped Flash, use esp_gsp_play(). Keep the borrowed data valid until the UI processes replacement playback or shuts down.

Terminal window
gspc eaf4-export intro.gif -o intro.eaf4 --pixel-format rgb565
gspc asset-info intro.eaf4 --validate

Match the scene’s RGB565 or RGB888 profile. Use the logical placeholder size and opacity printed by the exporter. asset-info reports the stored dimensions, which may include padding. Use --width and --height to resize the animation before encoding.

Mount the filesystem, keep CONFIG_ESP_GSP_ENABLE_EAF enabled, and call esp_gsp_play_file(ui, "/sdcard/intro.eaf4", true) to play into the current scene’s first image placeholder. If you specialize the runtime with an explicit dynamic feature list, include eaf in gsp_specialize_runtime(DYNAMIC_FEATURES ...).

Start playback after the intended scene becomes current, for example after the scene-changed event. ESP_GSP_OK confirms that the request was queued. The render task opens the file and decodes the first frame. Keep the file and mount valid until single playback completes or the UI finishes processing the scene switch, replacement, or shutdown. Single playback keeps the last frame after closing the file. Use matching GSP 1.12.0 and GSPC 0.13.0 for bundles that contain EAF4 or the new PNG color types.