fix(color): color mix rounding error

fixes: #3362
This commit is contained in:
Gabor Kiss-Vamosi
2022-05-18 07:56:46 +02:00
parent a7cfc0b901
commit 523062b9ee
3 changed files with 3 additions and 3 deletions

View File

@@ -36,7 +36,7 @@
/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently.
* 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */
#define LV_COLOR_MIX_ROUND_OFS (LV_COLOR_DEPTH == 32 ? 0: 128)
#define LV_COLOR_MIX_ROUND_OFS 0
/*Images pixels with this color will not be drawn if they are chroma keyed)*/
#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/

View File

@@ -96,7 +96,7 @@
#ifdef CONFIG_LV_COLOR_MIX_ROUND_OFS
#define LV_COLOR_MIX_ROUND_OFS CONFIG_LV_COLOR_MIX_ROUND_OFS
#else
#define LV_COLOR_MIX_ROUND_OFS (LV_COLOR_DEPTH == 32 ? 0: 128)
#define LV_COLOR_MIX_ROUND_OFS 0
#endif
#endif

View File

@@ -440,7 +440,7 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_color_t lv_color_mix(lv_color_t c1, lv_co
{
lv_color_t ret;
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP == 0
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP == 0 && LV_COLOR_MIX_ROUND_OFS == 0
/*Source: https://stackoverflow.com/a/50012418/1999969*/
mix = (mix + 4) >> 3;
uint32_t bg = (uint32_t)((uint32_t)c2.full | ((uint32_t)c2.full << 16)) &