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

LibGfx: Add Bitmap::invert()

Helper function to invert a bitmap in-place
This commit is contained in:
MacDue 2022-05-09 00:00:13 +01:00 committed by Linus Groh
parent 59598ded15
commit 48d3db3c3d
2 changed files with 10 additions and 0 deletions

View file

@ -469,6 +469,14 @@ ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::to_bitmap_backed_by_anonymous_buffer() co
return bitmap;
}
void Bitmap::invert()
{
for (auto y = 0; y < height(); y++) {
for (auto x = 0; x < width(); x++)
set_pixel(x, y, get_pixel(x, y).inverted());
}
}
Bitmap::~Bitmap()
{
if (m_needs_munmap) {