1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-02-04 07:13:00 +08:00

fix(image): backport lv_image_set_inner_align() behaviour with LV_IMAGE_ALIGN_… (#6864) (#6946)

Co-authored-by: rdegliesposti <riccardo.degliesposti@powersoft.com>
This commit is contained in:
Lorenzo Arena 2024-09-27 12:59:43 +02:00 committed by GitHub
parent d316710b3f
commit fa69216d4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -435,6 +435,11 @@ void lv_image_set_inner_align(lv_obj_t * obj, lv_image_align_t align)
lv_image_t * img = (lv_image_t *)obj;
if(align == img->align) return;
/*If we're removing STRETCH, reset the scale*/
if(img->align == LV_IMAGE_ALIGN_STRETCH) {
lv_image_set_scale(obj, LV_SCALE_NONE);
}
img->align = align;
update_align(obj);
@ -849,9 +854,11 @@ static void update_align(lv_obj_t * obj)
if(img->align == LV_IMAGE_ALIGN_STRETCH) {
lv_image_set_rotation(obj, 0);
lv_image_set_pivot(obj, 0, 0);
int32_t scale_x = lv_obj_get_width(obj) * LV_SCALE_NONE / img->w;
int32_t scale_y = lv_obj_get_height(obj) * LV_SCALE_NONE / img->h;
scale_update(obj, scale_x, scale_y);
if(img->w != 0 && img->h != 0) {
int32_t scale_x = lv_obj_get_width(obj) * LV_SCALE_NONE / img->w;
int32_t scale_y = lv_obj_get_height(obj) * LV_SCALE_NONE / img->h;
scale_update(obj, scale_x, scale_y);
}
}
else if(img->align == LV_IMAGE_ALIGN_TILE) {
lv_image_set_rotation(obj, 0);