Lv_example_img_3 display error

lv_example_img_3 display error

Description

if remove the statement lv_anim_set_playback_time(&a, 3000);
When the image show from zoom value 256 to 128, the image that has zoom value 256 still on the screen, not be cleared.

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

Visual Studio 2019 simulator

What LVGL version are you using?

LVGL V8.3

What do you want to achieve?

Clear the previous image shown from the screen

What have you tried so far?

Code to reproduce

#include "../../lv_examples.h"
#if LV_USE_IMG && LV_BUILD_EXAMPLES

static void set_angle(void* img, int32_t v)
{
    lv_img_set_angle(img, v);
}

static void set_zoom(void* img, int32_t v)
{
    lv_img_set_zoom(img, v);
}


/**
 * Show transformations (zoom and rotation) using a pivot point.
 */
void lv_example_img_3(void)
{
    LV_IMG_DECLARE(img_cogwheel_argb);

    /*Now create the actual image*/
    lv_obj_t* img = lv_img_create(lv_scr_act());
    lv_img_set_src(img, &img_cogwheel_argb);
    lv_obj_align(img, LV_ALIGN_CENTER, 50, 50);
    lv_img_set_pivot(img, 0, 0);    /*Rotate around the top left corner*/

    lv_anim_t a;
    lv_anim_init(&a);
    lv_anim_set_var(&a, img);
    lv_anim_set_exec_cb(&a, set_angle);
    lv_anim_set_values(&a, 0, 3600);
    lv_anim_set_time(&a, 5000);
    lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
    lv_anim_start(&a);

    lv_anim_set_exec_cb(&a, set_zoom);
    lv_anim_set_values(&a, 128, 256);
    //lv_anim_set_playback_time(&a, 3000);
    lv_anim_start(&a);
}

#endif

Screenshot and/or video

image

So, why you remove lv_anim_set_playback_time(&a, 3000) ?

It’s not a must-have statement. So I try to remove this statement for curious.

It only happened in LVGL Visual Studio 2019 simulator.

For zoom animation, lv_anim_set_playback_time() is very necessary. Because zoom will affect the size of the obj, if zoom out too fast, the invalidate() will miss some area, and make these “image sticking”.
For example, your image size is 100x100, zoom in to 200x200 in 3 seconds.
Now invalidate() will refresh 200x200 area.
But if you zoom out to 100x100 in 1ms, invalidate() only refresh the 100*100 area, the extra 3 100x100 area will be invalid image.

1 Like