Animation Image (lv_animimg)

Overview

The animation image is similar to the normal 'Image' Widget. The only difference is that instead of one source image, you set an array of multiple source images that supply "frames" in an animation.

You can specify a duration and repeat count.

Parts and Styles

  • LV_PART_MAIN A background rectangle that uses the typical background style properties and the image itself using the image style properties.

Usage

Image sources

To set the image animation images sources, use lv_animimg_set_src(animimg, dsc[], num).

Using the inner animation

For more advanced use cases, the animation used internally by the image can be retrieved using lv_animimg_get_anim(animimg). Using this, you can use the Animation functions, for example, to override the animation values using the lv_anim_set_values(anim, start, end) or to set a callback on the animation completed event.

Events

No special events are sent by Animation-Image Widgets.

Further Reading

Learn more about Base-Widget Events emitted by all Widgets.

Learn more about Events.

Keys

No Keys are processed by Animation-Image Widgets.

Further Reading

Learn more about Keys.

Example

Simple Animation Image

A simple example to demonstrate the use of an animation image.
#include "../../lv_examples.h"
#if LV_USE_ANIMIMG && LV_BUILD_EXAMPLES
LV_IMAGE_DECLARE(animimg001);
LV_IMAGE_DECLARE(animimg002);
LV_IMAGE_DECLARE(animimg003);

static const lv_image_dsc_t * anim_imgs[3] = {
    &animimg001,
    & animimg002,
    & animimg003,
};

void lv_example_animimg_1(void)
{
    lv_obj_t * animimg0 = lv_animimg_create(lv_screen_active());
    lv_obj_center(animimg0);
    lv_animimg_set_src(animimg0, (const void **) anim_imgs, 3);
    lv_animimg_set_duration(animimg0, 1000);
    lv_animimg_set_repeat_count(animimg0, LV_ANIM_REPEAT_INFINITE);
    lv_animimg_start(animimg0);
}

#endif

API

lv_animimage.h

lv_types.h