mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:07:45 +00:00
LibGfx: Add apply_alpha option to Painter::blit_filtered()
This commit is contained in:
parent
0ef0ad04e1
commit
3e6ca1085c
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");
|
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)
|
if (source_color.alpha() == 0)
|
||||||
continue;
|
continue;
|
||||||
auto filtered_color = filter(source_color);
|
auto filtered_color = filter(source_color);
|
||||||
if (filtered_color.alpha() == 0xff)
|
if (!apply_alpha || filtered_color.alpha() == 0xff)
|
||||||
dst[x] = filtered_color.value();
|
dst[x] = filtered_color.value();
|
||||||
else
|
else
|
||||||
dst[x] = color_for_format(dst_format, dst[x]).blend(filtered_color).value();
|
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)
|
if (source_color.alpha() == 0)
|
||||||
continue;
|
continue;
|
||||||
auto filtered_color = filter(source_color);
|
auto filtered_color = filter(source_color);
|
||||||
if (filtered_color.alpha() == 0xff)
|
if (!apply_alpha || filtered_color.alpha() == 0xff)
|
||||||
dst[x] = filtered_color.value();
|
dst[x] = filtered_color.value();
|
||||||
else
|
else
|
||||||
dst[x] = color_for_format(dst_format, dst[x]).blend(filtered_color).value();
|
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(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_dimmed(IntPoint, Gfx::Bitmap const&, IntRect const& src_rect);
|
||||||
void blit_brightened(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 draw_tiled_bitmap(IntRect const& dst_rect, Gfx::Bitmap const&);
|
||||||
void blit_offset(IntPoint, Gfx::Bitmap const&, IntRect const& src_rect, IntPoint);
|
void blit_offset(IntPoint, Gfx::Bitmap const&, IntRect const& src_rect, IntPoint);
|
||||||
void blit_disabled(IntPoint, Gfx::Bitmap const&, IntRect const&, Palette const&);
|
void blit_disabled(IntPoint, Gfx::Bitmap const&, IntRect const&, Palette const&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue