mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:37:44 +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:
parent
6e0fc5e221
commit
d70ddc8961
2 changed files with 11 additions and 0 deletions
|
@ -546,6 +546,14 @@ Bitmap::~Bitmap()
|
||||||
delete[] m_palette;
|
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)
|
void Bitmap::set_mmap_name([[maybe_unused]] DeprecatedString const& name)
|
||||||
{
|
{
|
||||||
VERIFY(m_needs_munmap);
|
VERIFY(m_needs_munmap);
|
||||||
|
|
|
@ -212,6 +212,9 @@ public:
|
||||||
[[nodiscard]] bool has_alpha_channel() const { return m_format == BitmapFormat::BGRA8888 || m_format == BitmapFormat::RGBA8888; }
|
[[nodiscard]] bool has_alpha_channel() const { return m_format == BitmapFormat::BGRA8888 || m_format == BitmapFormat::RGBA8888; }
|
||||||
[[nodiscard]] BitmapFormat format() const { return m_format; }
|
[[nodiscard]] BitmapFormat format() const { return m_format; }
|
||||||
|
|
||||||
|
// Call only for BGRx8888 and BGRA8888 bitmaps.
|
||||||
|
void strip_alpha_channel();
|
||||||
|
|
||||||
void set_mmap_name(DeprecatedString const&);
|
void set_mmap_name(DeprecatedString const&);
|
||||||
|
|
||||||
[[nodiscard]] static constexpr size_t size_in_bytes(size_t pitch, int physical_height) { return pitch * physical_height; }
|
[[nodiscard]] static constexpr size_t size_in_bytes(size_t pitch, int physical_height) { return pitch * physical_height; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue