diff options
author | Steven Schmoll <steven.schmoll@gmail.com> | 2022-02-12 20:40:43 +1100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-14 12:49:19 +0100 |
commit | d345a3689f7d73e76b5b010d5d96d872a13501e0 (patch) | |
tree | e371653be7631dc1005b71d6f38551af2d986566 /Userland | |
parent | 75a3be852d43742babff74c6b84a7cda6bcb6242 (diff) | |
download | serenity-d345a3689f7d73e76b5b010d5d96d872a13501e0.zip |
LibGfx: Support color blending in Painter::draw_bitmap
This method is commonly used by bitmap text rendering. Adding support
for color blending enables support in the browser for text opacity using
their color property.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGfx/Painter.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index 3576d32f5b..b7b13af879 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -655,7 +655,7 @@ void Painter::draw_bitmap(IntPoint const& p, GlyphBitmap const& bitmap, Color co for (int row = first_row; row <= last_row; ++row) { for (int j = 0; j <= (last_column - first_column); ++j) { if (bitmap.bit_at(j + first_column, row)) - dst[j] = color.value(); + dst[j] = Color::from_rgba(dst[j]).blend(color).value(); } dst += dst_skip; } @@ -664,8 +664,10 @@ void Painter::draw_bitmap(IntPoint const& p, GlyphBitmap const& bitmap, Color co for (int j = 0; j <= (last_column - first_column); ++j) { if (bitmap.bit_at((j + first_column), row)) { for (int iy = 0; iy < scale; ++iy) - for (int ix = 0; ix < scale; ++ix) - dst[j * scale + ix + iy * dst_skip] = color.value(); + for (int ix = 0; ix < scale; ++ix) { + auto pixel_index = j * scale + ix + iy * dst_skip; + dst[pixel_index] = Color::from_rgba(dst[pixel_index]).blend(color).value(); + } } } dst += dst_skip * scale; |