One-shot GIF support


Is there a way to stop the looping behaviour of a GIF widget? I’ve converted a file to a RAW buffer using the online image converter and the GIF is showed correctly, however I would like it to stop on the last frame after the first loop. Is there a way to achieve this?

What MCU/Processor/Board and compiler are you using?

Custom board with a STM32H753

What LVGL version are you using?

Latest v8.3 branch revision

I solved it by exporting the GIF with looping disabled using FFMPEG (with the -loop -1 option)

Hi @larena ,

You can also use the following hack to force the same result if you can not rework the gif image for any reason:

static void img_cb( lv_event_t *e ) {

    lv_gif_t * gif = (lv_gif_t *)e->target;


void example() {
    lv_obj_t * img;

    img = lv_gif_create(lv_scr_act());
    lv_gif_set_src(img, &img_bulb_gif);
    lv_obj_align(img, LV_ALIGN_LEFT_MID, 20, 0);
    lv_gif_t * gif = (lv_gif_t *)img;
    gif->gif->loop_count = 1;
    lv_obj_add_event_cb( img, img_cb, LV_EVENT_READY, NULL );

Kind Regards,


Great! I’m thinking about integrating something like this in the main codebase; do you this it would be useful?

Hi @larena ,

I don’t really know if this would be useful to be honest, personally I haven’t used animated GIFs to date. Maybe @kisvegabor or anyone else can comment here… :slight_smile:

Kind Regards,


animated PNG support would be something worth while… supports 32 bit color smaller file size. better than GIF in almost every way.

1 Like

Do you know a good C APNG decoder?

I do not. But I can tell you the standard is super easy. It’s a bunch of PNG’s stacked into a single file one right after the other. No reason why you cannot add onto the current PNG decoder. I wrote a decoder for use in Python. I know it won’t do you much good for the code. but I can help out with explaining how it works.