mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:47:37 +00:00
LibGfx: Support the RGBA8888 storage format in Bitmap::set_pixel()
This commit is contained in:
parent
3f3326f1dc
commit
ca3c45cc1f
1 changed files with 12 additions and 0 deletions
|
@ -325,6 +325,15 @@ inline void Bitmap::set_pixel<StorageFormat::BGRA8888>(int x, int y, Color color
|
||||||
VERIFY(x >= 0 && x < physical_width());
|
VERIFY(x >= 0 && x < physical_width());
|
||||||
scanline(y)[x] = color.value(); // drop alpha
|
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)
|
inline void Bitmap::set_pixel(int x, int y, Color color)
|
||||||
{
|
{
|
||||||
switch (determine_storage_format(m_format)) {
|
switch (determine_storage_format(m_format)) {
|
||||||
|
@ -334,6 +343,9 @@ inline void Bitmap::set_pixel(int x, int y, Color color)
|
||||||
case StorageFormat::BGRA8888:
|
case StorageFormat::BGRA8888:
|
||||||
set_pixel<StorageFormat::BGRA8888>(x, y, color);
|
set_pixel<StorageFormat::BGRA8888>(x, y, color);
|
||||||
break;
|
break;
|
||||||
|
case StorageFormat::RGBA8888:
|
||||||
|
set_pixel<StorageFormat::RGBA8888>(x, y, color);
|
||||||
|
break;
|
||||||
case StorageFormat::Indexed8:
|
case StorageFormat::Indexed8:
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue