mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-15 23:09:05 +00:00
LibGfx: Add Bitmap::invert()
Helper function to invert a bitmap in-place
This commit is contained in:
parent
59598ded15
commit
48d3db3c3d
Notes:
sideshowbarker
2024-07-17 10:39:11 +09:00
Author: https://github.com/MacDue
Commit: 48d3db3c3d
Pull-request: https://github.com/SerenityOS/serenity/pull/13989
Issue: https://github.com/SerenityOS/serenity/issues/13978
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/linusg
2 changed files with 10 additions and 0 deletions
|
@ -469,6 +469,14 @@ ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::to_bitmap_backed_by_anonymous_buffer() co
|
||||||
return bitmap;
|
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()
|
Bitmap::~Bitmap()
|
||||||
{
|
{
|
||||||
if (m_needs_munmap) {
|
if (m_needs_munmap) {
|
||||||
|
|
|
@ -121,6 +121,8 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] ShareableBitmap to_shareable_bitmap() const;
|
[[nodiscard]] ShareableBitmap to_shareable_bitmap() const;
|
||||||
|
|
||||||
|
void invert();
|
||||||
|
|
||||||
~Bitmap();
|
~Bitmap();
|
||||||
|
|
||||||
[[nodiscard]] u8* scanline_u8(int physical_y);
|
[[nodiscard]] u8* scanline_u8(int physical_y);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue