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

LibGfx: Add Bitmap::strip_alpha_channel()

Sets all alpha values to 0xff and sets the bitmap's format to BGRx8888.

Currently only implemented for BGRA8888 and BGRx8888.
This commit is contained in:
Nico Weber 2023-06-13 19:23:38 -04:00 committed by Andreas Kling
parent 6e0fc5e221
commit d70ddc8961
2 changed files with 11 additions and 0 deletions

View file

@ -546,6 +546,14 @@ Bitmap::~Bitmap()
delete[] m_palette;
}
void Bitmap::strip_alpha_channel()
{
VERIFY(m_format == BitmapFormat::BGRA8888 || m_format == BitmapFormat::BGRx8888);
for (ARGB32& pixel : *this)
pixel = 0xff000000 | (pixel & 0xffffff);
m_format = BitmapFormat::BGRx8888;
}
void Bitmap::set_mmap_name([[maybe_unused]] DeprecatedString const& name)
{
VERIFY(m_needs_munmap);