GIF (lv_gif)
Plays animated GIF images using LVGL's built-in decoder.
Overview
The GIF widget plays animated GIF images using LVGL's built-in AnimatedGIF decoder. The source can be an embedded array or a file.
Learn more in the LVGL Open documentation.
/**
* @file lv_example_gif.c
*/
#include "../lv_examples.h"
/**
* @title GIF
* @brief An animated GIF, embedded as a raw C array.
*
* `src` names an image from `globals.xml`, registered there with
* `color_format="raw"`, so the export embeds the GIF file itself instead of
* converting it. `loop_count` sets how many times it repeats; leave it unset to
* use the count stored in the GIF.
*/
void lv_example_gif(void)
{
LV_IMAGE_DECLARE(img_bulb);
lv_obj_t * screen = lv_screen_active();
lv_obj_t * lv_gif_0 = lv_gif_create(screen);
lv_gif_set_src(lv_gif_0, &img_bulb);
lv_gif_set_loop_count(lv_gif_0, 10);
lv_obj_set_align(lv_gif_0, LV_ALIGN_CENTER);
}
<!--
@title GIF
@brief An animated GIF, embedded as a raw C array.
`src` names an image from `globals.xml`, registered there with
`color_format="raw"`, so the export embeds the GIF file itself instead of
converting it. `loop_count` sets how many times it repeats; leave it unset to
use the count stored in the GIF.
-->
<screen>
<view>
<lv_gif src="img_bulb" loop_count="10" align="center"/>
</view>
</screen>
Enumerations
lv_color_format — Color format of the buffer the gif is decoded to
| Value | Description |
|---|---|
rgb565 | 16 bit RGB |
rgb565_swapped | 16 bit RGB with swapped bytes |
rgb888 | 24 bit RGB |
xrgb8888 | 32 bit RGB, the alpha byte is unused |
argb8888 | 32 bit RGB with alpha |
Properties
Parts
Style parts of the widget with local style (e.g. style_bg_color-knob="0xff0000") or with style sheets (e.g. <style name="style_knob" selector="knob">). See Styles to learn more.
| Part | Description |
|---|---|
main | Style the GIF: image_recolor, image_recolor_opa and image_opa. Background, border, etc can be added too. |
Properties below are the widget's XML <api>; see API for how properties, parameters and elements work.
| Property | Type | Description |
|---|---|---|
src | image | The source for the gif (raw data or a file) |
loop_count | int | Number of repeats. If not set the information form the gif will be used |
color_format | enum:lv_color_format | Color format to decode the gif to. Set it before src to decode only once |
auto_pause_invisible | bool | Pause the gif while it is not visible |
Last updated on