fix(canvas): fix clipéping on transformation

fixes: #3545
This commit is contained in:
Gabor Kiss-Vamosi
2022-08-07 21:09:43 +02:00
parent 4a7ddf9f19
commit 4519a874d7
3 changed files with 12 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES && LV_USE_SLIDER && LV_USE_CHART && LV_USE_BTN
#if LV_BUILD_EXAMPLES && LV_USE_SLIDER && LV_USE_CHART && LV_USE_BTN && LV_USE_GRID
/**
* the example show the use of cubic-bezier3 in animation.

View File

@@ -139,11 +139,15 @@ static inline uint8_t lv_obj_get_style_flex_grow(const lv_obj_t * obj, uint32_t
return (uint8_t)v.num;
}
/**********************
* MACROS
**********************/
#define LV_STYLE_CONST_FLEX_FLOW(val) \
{ \
.prop_ptr = &LV_STYLE_FLEX_FLOW, .value = { .num = (lv_flex_flow_t)val } \
}
#endif /*LV_USE_FLEX*/
#ifdef __cplusplus

View File

@@ -180,10 +180,10 @@ void lv_canvas_transform(lv_obj_t * obj, lv_img_dsc_t * src_img, int16_t angle,
draw_dsc.antialias = antialias;
lv_area_t dest_area;
dest_area.x1 = 0;
dest_area.x2 = dest_img->header.w - 1;
dest_area.y1 = 0;
dest_area.y2 = 0;
dest_area.x1 = -offset_x;
dest_area.x2 = dest_area.x1 + dest_img->header.w - 1;
dest_area.y1 = -offset_y;
dest_area.y2 = -offset_y;
lv_color_t * cbuf = lv_malloc(dest_img->header.w * sizeof(lv_color_t));
lv_opa_t * abuf = lv_malloc(dest_img->header.w * sizeof(lv_opa_t));
@@ -193,15 +193,12 @@ void lv_canvas_transform(lv_obj_t * obj, lv_img_dsc_t * src_img, int16_t angle,
&draw_dsc, canvas->dsc.header.cf, cbuf, abuf);
for(x = 0; x < dest_img->header.w; x++) {
if(x + offset_x < 0) continue;
if(x + offset_x >= dest_img->header.w) break;
if(abuf[x]) {
lv_img_buf_set_px_color(dest_img, x + offset_x, y + offset_y, cbuf[x]);
lv_img_buf_set_px_alpha(dest_img, x + offset_x, y + offset_y, abuf[x]);
lv_img_buf_set_px_color(dest_img, x, y, cbuf[x]);
lv_img_buf_set_px_alpha(dest_img, x, y, abuf[x]);
}
}
if(y + offset_y >= dest_img->header.h) break;
dest_area.y1++;
dest_area.y2++;
}