mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
LibGfx: Painter::blit_filtered should take into account alpha value
If either the destination or calculated source pixel color contains an alpha value, we should blend them together.
This commit is contained in:
parent
dd0833107f
commit
130d48fa13
1 changed files with 14 additions and 6 deletions
|
@ -590,9 +590,13 @@ void Painter::blit_filtered(const IntPoint& position, const Gfx::Bitmap& source,
|
|||
for (int row = first_row; row <= last_row; ++row) {
|
||||
for (int x = 0; x <= (last_column - first_column); ++x) {
|
||||
u8 alpha = Color::from_rgba(src[x]).alpha();
|
||||
if (alpha == 0xff)
|
||||
dst[x] = filter(Color::from_rgba(src[x])).value();
|
||||
else if (!alpha)
|
||||
if (alpha == 0xff) {
|
||||
auto color = filter(Color::from_rgba(src[x]));
|
||||
if (color.alpha() == 0xff)
|
||||
dst[x] = color.value();
|
||||
else
|
||||
dst[x] = Color::from_rgba(dst[x]).blend(color).value();
|
||||
} else if (!alpha)
|
||||
continue;
|
||||
else
|
||||
dst[x] = Color::from_rgba(dst[x]).blend(filter(Color::from_rgba(src[x]))).value();
|
||||
|
@ -605,9 +609,13 @@ void Painter::blit_filtered(const IntPoint& position, const Gfx::Bitmap& source,
|
|||
const RGBA32* src = source.scanline(safe_src_rect.top() + row / s) + safe_src_rect.left() + first_column / s;
|
||||
for (int x = 0; x <= (last_column - first_column); ++x) {
|
||||
u8 alpha = Color::from_rgba(src[x / s]).alpha();
|
||||
if (alpha == 0xff)
|
||||
dst[x] = filter(Color::from_rgba(src[x / s])).value();
|
||||
else if (!alpha)
|
||||
if (alpha == 0xff) {
|
||||
auto color = filter(Color::from_rgba(src[x / s]));
|
||||
if (color.alpha() == 0xff)
|
||||
dst[x] = color.value();
|
||||
else
|
||||
dst[x] = Color::from_rgba(dst[x]).blend(color).value();
|
||||
} else if (!alpha)
|
||||
continue;
|
||||
else
|
||||
dst[x] = Color::from_rgba(dst[x]).blend(filter(Color::from_rgba(src[x / s]))).value();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue