1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:27:35 +00:00

LibGfx: Replace Bitmap::invert() with Bitmap::inverted()

The new function return a new bitmap instead of mutating the current
one in place.
This commit is contained in:
Andreas Kling 2023-02-19 22:43:49 +01:00
parent 1f907a834f
commit 4b3e229157
3 changed files with 9 additions and 10 deletions

View file

@ -476,12 +476,14 @@ ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::to_bitmap_backed_by_anonymous_buffer() co
return bitmap;
}
void Bitmap::invert()
ErrorOr<NonnullRefPtr<Gfx::Bitmap>> Bitmap::inverted() const
{
auto inverted_bitmap = TRY(clone());
for (auto y = 0; y < height(); y++) {
for (auto x = 0; x < width(); x++)
set_pixel(x, y, get_pixel(x, y).inverted());
inverted_bitmap->set_pixel(x, y, get_pixel(x, y).inverted());
}
return inverted_bitmap;
}
Bitmap::~Bitmap()