BigW Consortium Gitlab

Commit dd6bad1b by Gabor Kiss-Vamosi

fix of 16 bit image draw with alpha byte

parent 0d938168
...@@ -102,8 +102,6 @@ void lv_group_remove_obj(lv_obj_t * obj) ...@@ -102,8 +102,6 @@ void lv_group_remove_obj(lv_obj_t * obj)
obj->group_p = NULL; obj->group_p = NULL;
} }
} }
} }
/** /**
......
...@@ -384,31 +384,43 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p, ...@@ -384,31 +384,43 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
for(row = masked_a.y1; row <= masked_a.y2; row++) { for(row = masked_a.y1; row <= masked_a.y2; row++) {
for(col = 0; col < map_useful_w; col++) { for(col = 0; col < map_useful_w; col++) {
lv_opa_t opa_result = opa; lv_opa_t opa_result = opa;
lv_color_t * px_color = (lv_color_t *) &map_p[(uint32_t)col * px_size_byte]; uint8_t * px_color_p = (uint8_t *) &map_p[(uint32_t)col * px_size_byte];
lv_color_t px_color;
/*Handle chroma key*/
if(chroma_key && px_color->full == chroma_key_color.full) continue;
/*Calculate with the pixel level alpha*/ /*Calculate with the pixel level alpha*/
if(alpha_byte) { if(alpha_byte) {
lv_opa_t px_opa = (*(((uint8_t *) px_color) + LV_IMG_PX_SIZE_ALPHA_BYTE - 1)); #if LV_COLOR_DEPTH == 8
px_color.full = px_color_p[0];
#elif LV_COLOR_DEPTH == 16
/*Because of Alpha byte 16 bit color can start on odd address which can cause crash*/
px_color.full = px_color_p[0] + (px_color_p[1] << 8);
#elif LV_COLOR_DEPTH == 24
px_color = *((lv_color_t*)px_color_p);
#endif
lv_opa_t px_opa = *(px_color_p + LV_IMG_PX_SIZE_ALPHA_BYTE - 1);
if(px_opa == LV_OPA_TRANSP) continue; if(px_opa == LV_OPA_TRANSP) continue;
else if(px_opa != LV_OPA_COVER) opa_result = (uint32_t)((uint32_t)px_opa * opa_result) >> 8; else if(px_opa != LV_OPA_COVER) opa_result = (uint32_t)((uint32_t)px_opa * opa_result) >> 8;
} }
else {
px_color = *((lv_color_t*)px_color_p);
}
/*Handle chroma key*/
if(chroma_key && px_color.full == chroma_key_color.full) continue;
/*Re-color the pixel if required*/ /*Re-color the pixel if required*/
if(recolor_opa != LV_OPA_TRANSP) { if(recolor_opa != LV_OPA_TRANSP) {
if(last_img_px.full != px_color->full) { /*Minor acceleration: calculate only for new colors (save the last)*/ if(last_img_px.full != px_color.full) { /*Minor acceleration: calculate only for new colors (save the last)*/
last_img_px = *px_color; last_img_px = px_color;
recolored_px = lv_color_mix(recolor, last_img_px, recolor_opa); recolored_px = lv_color_mix(recolor, last_img_px, recolor_opa);
} }
if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col].full = recolored_px.full; if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col].full = recolored_px.full;
else vdb_buf_tmp[col] = lv_color_mix(recolored_px, vdb_buf_tmp[col], opa_result); else vdb_buf_tmp[col] = lv_color_mix(recolored_px, vdb_buf_tmp[col], opa_result);
} else { } else {
if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col].full = px_color->full; if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col] = px_color;
else vdb_buf_tmp[col] = lv_color_mix(*px_color, vdb_buf_tmp[col], opa_result); else vdb_buf_tmp[col] = lv_color_mix(px_color, vdb_buf_tmp[col], opa_result);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment