1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:57:35 +00:00

Revert "LibGfx: Slightly simplify Color::blend()"

This was producing incorrect results.

This reverts commit a1bafafd78.
This commit is contained in:
MacDue 2024-01-21 23:29:01 +00:00 committed by Andreas Kling
parent 1d43bfc598
commit 9f710b0fb6
2 changed files with 5 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 400 B

After

Width:  |  Height:  |  Size: 407 B

Before After
Before After

View file

@ -210,10 +210,11 @@ public:
if (source.alpha() == 0) if (source.alpha() == 0)
return *this; return *this;
u8 a = 255 - ((255 - alpha()) * (255 - source.alpha()) / 255); int const d = 255 * (alpha() + source.alpha()) - alpha() * source.alpha();
u8 r = (red() * (255 - source.alpha()) + source.red() * source.alpha()) / 255; u8 r = (red() * alpha() * (255 - source.alpha()) + source.red() * 255 * source.alpha()) / d;
u8 g = (green() * (255 - source.alpha()) + source.green() * source.alpha()) / 255; u8 g = (green() * alpha() * (255 - source.alpha()) + source.green() * 255 * source.alpha()) / d;
u8 b = (blue() * (255 - source.alpha()) + source.blue() * source.alpha()) / 255; u8 b = (blue() * alpha() * (255 - source.alpha()) + source.blue() * 255 * source.alpha()) / d;
u8 a = d / 255;
return Color(r, g, b, a); return Color(r, g, b, a);
} }