diff options
author | Nico Weber <thakis@chromium.org> | 2023-04-03 14:29:11 -0400 |
---|---|---|
committer | Jelle Raaijmakers <jelle@gmta.nl> | 2023-04-05 13:24:00 +0200 |
commit | c24e4acd19406ac2ff302b173ee1310b112441ba (patch) | |
tree | d35103525ce0627f59bd5c796cea15e3bd158c4c /Userland | |
parent | 830fd0d5b2327868094251c5fc7c52b90d4b8ed2 (diff) | |
download | serenity-c24e4acd19406ac2ff302b173ee1310b112441ba.zip |
LibGfx: Add Bitmap::begin() / Bitmap::end()
Useful for accessing a bitmap like a linear container.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGfx/Bitmap.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/Bitmap.h b/Userland/Libraries/LibGfx/Bitmap.h index 7d71839554..786af81287 100644 --- a/Userland/Libraries/LibGfx/Bitmap.h +++ b/Userland/Libraries/LibGfx/Bitmap.h @@ -135,6 +135,9 @@ public: [[nodiscard]] ARGB32* scanline(int physical_y); [[nodiscard]] ARGB32 const* scanline(int physical_y) const; + [[nodiscard]] ARGB32* begin(); + [[nodiscard]] ARGB32* end(); + [[nodiscard]] IntRect rect() const { return { {}, m_size }; } [[nodiscard]] IntSize size() const { return m_size; } [[nodiscard]] int width() const { return m_size.width(); } @@ -293,6 +296,16 @@ ALWAYS_INLINE ARGB32 const* Bitmap::scanline(int y) const return reinterpret_cast<ARGB32 const*>(scanline_u8(y)); } +ALWAYS_INLINE ARGB32* Bitmap::begin() +{ + return scanline(0); +} + +ALWAYS_INLINE ARGB32* Bitmap::end() +{ + return reinterpret_cast<ARGB32*>(reinterpret_cast<u8*>(m_data) + (m_size.height() * m_pitch)); +} + template<> ALWAYS_INLINE Color Bitmap::get_pixel<StorageFormat::BGRx8888>(int x, int y) const { |