From 078bba2fb941600aebe6d04f04fac8fe09abc004 Mon Sep 17 00:00:00 2001 From: Gabriel Ozouf Date: Wed, 19 Aug 2020 15:51:44 +0200 Subject: [PATCH] [kandinsky/color] Fix blend method When computing the barycenter between two colors, the some of the two factors a and (1-a) was equal to 255/256 instead of 1. Change-Id: Ia9a779d43470ef42d9430ad730e842da0f007140 --- kandinsky/src/color.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/kandinsky/src/color.cpp b/kandinsky/src/color.cpp index 57256d820..55bf9e8aa 100644 --- a/kandinsky/src/color.cpp +++ b/kandinsky/src/color.cpp @@ -19,14 +19,9 @@ KDColor KDColor::blend(KDColor first, KDColor second, uint8_t alpha) { // First is RRRRR GGGGGG BBBBB // Second is same - uint8_t oneMinusAlpha = 0xFF-alpha; + uint16_t oneMinusAlpha = 0x100-alpha; uint16_t red = first.red()*alpha + second.red()*oneMinusAlpha; uint16_t green = first.green()*alpha + second.green()*oneMinusAlpha; uint16_t blue = first.blue()*alpha + second.blue()*oneMinusAlpha; return RGB888(red>>8, green>>8, blue>>8); - - /* The formula used to blend colors produces some unwanted results : - * blend white + black, alpha = OxFF (should be white) - * white.red() * OxFF = OxF708, while we would like 0xF800 - * Escaping early solves this issue. */ }