1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +00:00

GraphicsBitmap: Add set_pixel(x, y, Color)

This only works for RGB32 and RGBA32 formats.
This commit is contained in:
Andreas Kling 2019-06-14 19:10:59 +02:00
parent ae598116f4
commit 1ec5172ce1

View file

@ -65,6 +65,32 @@ public:
}
}
Color get_pixel(const Point& position) const
{
return get_pixel(position.x(), position.y());
}
void set_pixel(int x, int y, Color color)
{
switch (m_format) {
case Format::RGB32:
scanline(y)[x] = color.value();
break;
case Format::RGBA32:
scanline(y)[x] = color.value();
break;
case Format::Indexed8:
ASSERT_NOT_REACHED();
default:
ASSERT_NOT_REACHED();
}
}
void set_pixel(const Point& position, Color color)
{
set_pixel(position.x(), position.y(), color);
}
private:
GraphicsBitmap(Format, const Size&);
GraphicsBitmap(Format, const Size&, RGBA32*);