SVG

Report on GitHub

LVGL's built-in SVG parser and renderer for scalable vector graphics. Enable with LV_USE_SVG in lv_conf.h.

SVG from inline markup

Render an SVG circle described by a literal string as an image source.

A static lv_image_dsc_t is populated with LV_IMAGE_HEADER_MAGIC, a 450x150 display size, and a pointer to the literal SVG markup drawing a red circle with a blue stroke. The descriptor is handed to lv_image_set_src on an image widget placed on the active screen so the SVG decoder renders the markup on demand.

SVG from filesystem

Load an SVG file through the LVGL filesystem and use it as an image source.

An image widget is created on the active screen and its source is set to A:lvgl/examples/assets/circle.svg, so the SVG decoder reads the file through the filesystem driver registered under drive letter A.

Draw SVG in a draw event

Paint SVG markup directly into the screen's draw layer on LV_EVENT_DRAW_MAIN.

lv_obj_add_event_cb subscribes a handler to the active screen's LV_EVENT_DRAW_MAIN. The handler parses an inline SVG string with lv_svg_load_data, calls lv_draw_svg against the layer returned by lv_event_get_layer, and then releases the node with lv_svg_node_delete.

How is this guide?

Last updated on

On this page