LibGfx: Add apply_alpha option to Painter::blit_filtered()
This commit is contained in:
parent
0ef0ad04e1
commit
3e6ca1085c
Notes:
sideshowbarker
2024-07-17 07:09:53 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/3e6ca1085c Pull-request: https://github.com/SerenityOS/serenity/pull/20254
2 changed files with 4 additions and 4 deletions
|
@ -934,7 +934,7 @@ void Painter::blit_with_opacity(IntPoint position, Gfx::Bitmap const& source, In
|
|||
}
|
||||
}
|
||||
|
||||
void Painter::blit_filtered(IntPoint position, Gfx::Bitmap const& source, IntRect const& src_rect, Function<Color(Color)> const& filter)
|
||||
void Painter::blit_filtered(IntPoint position, Gfx::Bitmap const& source, IntRect const& src_rect, Function<Color(Color)> const& filter, bool apply_alpha)
|
||||
{
|
||||
VERIFY((source.scale() == 1 || source.scale() == scale()) && "blit_filtered only supports integer upsampling");
|
||||
|
||||
|
@ -969,7 +969,7 @@ void Painter::blit_filtered(IntPoint position, Gfx::Bitmap const& source, IntRec
|
|||
if (source_color.alpha() == 0)
|
||||
continue;
|
||||
auto filtered_color = filter(source_color);
|
||||
if (filtered_color.alpha() == 0xff)
|
||||
if (!apply_alpha || filtered_color.alpha() == 0xff)
|
||||
dst[x] = filtered_color.value();
|
||||
else
|
||||
dst[x] = color_for_format(dst_format, dst[x]).blend(filtered_color).value();
|
||||
|
@ -985,7 +985,7 @@ void Painter::blit_filtered(IntPoint position, Gfx::Bitmap const& source, IntRec
|
|||
if (source_color.alpha() == 0)
|
||||
continue;
|
||||
auto filtered_color = filter(source_color);
|
||||
if (filtered_color.alpha() == 0xff)
|
||||
if (!apply_alpha || filtered_color.alpha() == 0xff)
|
||||
dst[x] = filtered_color.value();
|
||||
else
|
||||
dst[x] = color_for_format(dst_format, dst[x]).blend(filtered_color).value();
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
void blit(IntPoint, Gfx::Bitmap const&, IntRect const& src_rect, float opacity = 1.0f, bool apply_alpha = true);
|
||||
void blit_dimmed(IntPoint, Gfx::Bitmap const&, IntRect const& src_rect);
|
||||
void blit_brightened(IntPoint, Gfx::Bitmap const&, IntRect const& src_rect);
|
||||
void blit_filtered(IntPoint, Gfx::Bitmap const&, IntRect const& src_rect, Function<Color(Color)> const&);
|
||||
void blit_filtered(IntPoint, Gfx::Bitmap const&, IntRect const& src_rect, Function<Color(Color)> const&, bool apply_alpha = true);
|
||||
void draw_tiled_bitmap(IntRect const& dst_rect, Gfx::Bitmap const&);
|
||||
void blit_offset(IntPoint, Gfx::Bitmap const&, IntRect const& src_rect, IntPoint);
|
||||
void blit_disabled(IntPoint, Gfx::Bitmap const&, IntRect const&, Palette const&);
|
||||
|
|
Loading…
Add table
Reference in a new issue