1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

fix croping of last column/row if an image is zoomed

Fixes #1742
This commit is contained in:
Gabor Kiss-Vamosi 2020-08-24 06:39:57 +02:00
parent 7e4769e319
commit ba94b9cc94
4 changed files with 24 additions and 17 deletions

View File

@ -13,6 +13,7 @@
### Bugfixes
- Fix color bleeding on border drawing
- Fix using 'LV_SCROLLBAR_UNHIDE' after 'LV_SCROLLBAR_ON'
- Fix croping of last column/row if an image is zoomed
## v7.3.1 (18.08.2020)

View File

@ -481,7 +481,20 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t
res->x2 = w - 1;
res->y2 = h - 1;
return;
}
res->x1 = (((-pivot->x) * zoom) >> 8) - 1;
res->y1 = (((-pivot->y) * zoom) >> 8) - 1;
res->x2 = (((w - pivot->x) * zoom) >> 8) + 2;
res->y2 = (((h - pivot->y) * zoom) >> 8) + 2;
if(angle == 0) {
res->x1 += pivot->x;
res->y1 += pivot->y;
res->x2 += pivot->x;
res->y2 += pivot->y;
return;
}
int32_t angle_low = angle / 10;
@ -509,29 +522,23 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t
lv_coord_t xt;
lv_coord_t yt;
lv_area_t a;
a.x1 = ((-pivot->x) * zoom) >> 8;
a.y1 = ((-pivot->y) * zoom) >> 8;
a.x2 = ((w - pivot->x) * zoom) >> 8;
a.y2 = ((h - pivot->y) * zoom) >> 8;
xt = a.x1;
yt = a.y1;
xt = res->x1;
yt = res->y1;
lt.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x;
lt.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y;
xt = a.x2;
yt = a.y1;
xt = res->x2;
yt = res->y1;
rt.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x;
rt.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y;
xt = a.x1;
yt = a.y2;
xt = res->x1;
yt = res->y2;
lb.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x;
lb.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y;
xt = a.x2;
yt = a.y2;
xt = res->x2;
yt = res->y2;
rb.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x;
rb.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y;

View File

@ -174,7 +174,7 @@ typedef struct {
uint8_t has_alpha : 1;
uint8_t native_color : 1;
uint16_t zoom_inv;
uint32_t zoom_inv;
/*Runtime data*/
lv_coord_t xs;

View File

@ -567,7 +567,6 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
if(mode == LV_DESIGN_COVER_CHK) {
if(lv_obj_get_style_clip_corner(img, LV_IMG_PART_MAIN)) return LV_DESIGN_RES_MASKED;
if(ext->src_type == LV_IMG_SRC_UNKNOWN || ext->src_type == LV_IMG_SRC_SYMBOL) return LV_DESIGN_RES_NOT_COVER;
@ -583,7 +582,7 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area
int32_t zoom_final = lv_obj_get_style_transform_zoom(img, LV_IMG_PART_MAIN);
zoom_final = (zoom_final * ext->zoom) >> 8;
if(zoom_final != LV_IMG_ZOOM_NONE) {
if(zoom_final == LV_IMG_ZOOM_NONE) {
if(_lv_area_is_in(clip_area, &img->coords, 0) == false) return LV_DESIGN_RES_NOT_COVER;
}
else {