mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:47:44 +00:00
GraphicsBitmap: Provide templated versions of get_pixel() and set_pixel().
If we already know the bitmap format used, we can use these functions to bypass the format checks and go straight to pixel manipulation.
This commit is contained in:
parent
150b3cf378
commit
dcbddb4f8c
2 changed files with 73 additions and 25 deletions
|
@ -16,14 +16,16 @@ BucketTool::~BucketTool()
|
|||
|
||||
static void flood_fill(GraphicsBitmap& bitmap, const Point& start_position, Color target_color, Color fill_color)
|
||||
{
|
||||
ASSERT(bitmap.format() == GraphicsBitmap::Format::RGB32);
|
||||
|
||||
Queue<Point> queue;
|
||||
queue.enqueue(Point(start_position));
|
||||
while (!queue.is_empty()) {
|
||||
auto position = queue.dequeue();
|
||||
|
||||
if (bitmap.get_pixel(position) != target_color)
|
||||
if (bitmap.get_pixel<GraphicsBitmap::Format::RGB32>(position.x(), position.y()) != target_color)
|
||||
continue;
|
||||
bitmap.set_pixel(position, fill_color);
|
||||
bitmap.set_pixel<GraphicsBitmap::Format::RGB32>(position.x(), position.y(), fill_color);
|
||||
|
||||
if (position.x() != 0)
|
||||
queue.enqueue(position.translated(-1, 0));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue