mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
GraphicsBitmap: Add a fill(Color) helper.
This only works for RGB32 and RGBA32 bitmaps at the moment, since it's not obvious what should happen in an Indexed8 bitmap.
This commit is contained in:
parent
d599544890
commit
6aa4cb6740
2 changed files with 11 additions and 0 deletions
|
@ -91,3 +91,12 @@ void GraphicsBitmap::set_mmap_name(const StringView& name)
|
|||
ASSERT(m_needs_munmap);
|
||||
::set_mmap_name(m_data, size_in_bytes(), name.characters());
|
||||
}
|
||||
|
||||
void GraphicsBitmap::fill(Color color)
|
||||
{
|
||||
ASSERT(m_format == GraphicsBitmap::Format::RGB32 || m_format == GraphicsBitmap::Format::RGBA32);
|
||||
for (int y = 0; y < height(); ++y) {
|
||||
auto* scanline = this->scanline(y);
|
||||
fast_dword_fill(scanline, color.value(), width());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,8 @@ public:
|
|||
size_t pitch() const { return m_pitch; }
|
||||
int shared_buffer_id() const { return m_shared_buffer ? m_shared_buffer->shared_buffer_id() : -1; }
|
||||
|
||||
void fill(Color);
|
||||
|
||||
bool has_alpha_channel() const { return m_format == Format::RGBA32; }
|
||||
Format format() const { return m_format; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue