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

LibGfx: Support the RGBA8888 storage format in Bitmap::set_pixel()

This commit is contained in:
Linus Groh 2022-03-04 19:03:55 +01:00 committed by Andreas Kling
parent 3f3326f1dc
commit ca3c45cc1f

View file

@ -325,6 +325,15 @@ inline void Bitmap::set_pixel<StorageFormat::BGRA8888>(int x, int y, Color color
VERIFY(x >= 0 && x < physical_width());
scanline(y)[x] = color.value(); // drop alpha
}
template<>
inline void Bitmap::set_pixel<StorageFormat::RGBA8888>(int x, int y, Color color)
{
VERIFY(x >= 0 && x < physical_width());
// FIXME: There's a lot of inaccurately named functions in the Color class right now (RGBA vs BGRA),
// clear those up and then make this more convenient.
auto rgba = (color.alpha() << 24) | (color.blue() << 16) | (color.green() << 8) | color.red();
scanline(y)[x] = rgba;
}
inline void Bitmap::set_pixel(int x, int y, Color color)
{
switch (determine_storage_format(m_format)) {
@ -334,6 +343,9 @@ inline void Bitmap::set_pixel(int x, int y, Color color)
case StorageFormat::BGRA8888:
set_pixel<StorageFormat::BGRA8888>(x, y, color);
break;
case StorageFormat::RGBA8888:
set_pixel<StorageFormat::RGBA8888>(x, y, color);
break;
case StorageFormat::Indexed8:
VERIFY_NOT_REACHED();
default: