Animation Image (lv_animimg)

Overview

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

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 in a state, use the lv_animimg_set_src(imgbtn, dsc[], num).

Events

No special events are sent by image objects.

See the events of the Base object too.

Learn more about Events.

Keys

No Keys are processed by the object type.

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
anim_images = [None]*3
# Create an image from the png file
try:
    with open('../../assets/animimg001.png','rb') as f:
        anim001_data = f.read()
except:
    print("Could not find animimg001.png")
    sys.exit()

anim_images[0] = lv.image_dsc_t({
  'data_size': len(anim001_data),
  'data': anim001_data
})

try:
    with open('../../assets/animimg002.png','rb') as f:
        anim002_data = f.read()
except:
    print("Could not find animimg002.png")
    sys.exit()

anim_images[1] = lv.image_dsc_t({
  'data_size': len(anim002_data),
  'data': anim002_data
})

try:
    with open('../../assets/animimg003.png','rb') as f:
        anim003_data = f.read()
except:
    print("Could not find animimg003.png")
    sys.exit()

anim_images[2] = lv.image_dsc_t({
  'data_size': len(anim003_data),
  'data': anim003_data
})

animimage0 = lv.animimg(lv.screen_active())
animimage0.center()
animimage0.set_src(anim_images, 3)
animimage0.set_duration(1000)
animimage0.set_repeat_count(lv.ANIM_REPEAT_INFINITE)
animimage0.start()




API

lv_animimg .. Autogenerated

lv_animimage.h