From 1ad21a6b50bb6e45f6eafd4a460bd3b455a180dd Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 28 Apr 2020 20:17:32 +0200 Subject: Fix blending function error for non-premultiplied surfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- README | 2 +- apply-glyph.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README b/README index 19fcc4d..8ab597f 100644 --- a/README +++ b/README @@ -83,4 +83,4 @@ Out of scope: Underline, overline, strike-thought, ... - Superscript, subscript, ... + Superscript and subscript. diff --git a/apply-glyph.h b/apply-glyph.h index 09cb9aa..a179a1b 100644 --- a/apply-glyph.h +++ b/apply-glyph.h @@ -86,9 +86,9 @@ do { bl = RMAP(*B) * RMAP(*A) * (1 - opacity * gly[c + bi]) + gly[c + bi] * blue; al = RMAP(*A) * (1 - opacity * high) + high * alpha; if (fpclassify(al) != FP_ZERO) { - *R = MAP(re); - *G = MAP(gr); - *B = MAP(bl); + *R = MAP(re / al); + *G = MAP(gr / al); + *B = MAP(bl / al); *A = MAP(al); } else { *R = *G = *B = *A = 0; @@ -104,9 +104,9 @@ do { bl = RMAP(*B) * RMAP(*A) * transparency + gly[c + ri] * blue; al = RMAP(*A) * transparency + gly[c + ri] * alpha; if (fpclassify(al) != FP_ZERO) { - *R = MAP(re); - *G = MAP(gr); - *B = MAP(bl); + *R = MAP(re / al); + *G = MAP(gr / al); + *B = MAP(bl / al); *A = MAP(al); } else { *R = *G = *B = *A = 0; -- cgit v1.2.3-70-g09d2