mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibGfx: Add data_size() accessors to Bitmap and CMYKBitmap
These return the size of the data in bytes.
This commit is contained in:
parent
0acc370f7b
commit
11b623b1fd
Notes:
sideshowbarker
2024-07-17 07:35:03 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/11b623b1fd Pull-request: https://github.com/SerenityOS/serenity/pull/22922 Reviewed-by: https://github.com/LucasChollet ✅
2 changed files with 9 additions and 2 deletions
|
@ -142,6 +142,7 @@ public:
|
|||
|
||||
[[nodiscard]] ARGB32* begin();
|
||||
[[nodiscard]] ARGB32* end();
|
||||
[[nodiscard]] size_t data_size() const;
|
||||
|
||||
[[nodiscard]] IntRect rect() const { return { {}, m_size }; }
|
||||
[[nodiscard]] IntSize size() const { return m_size; }
|
||||
|
@ -282,7 +283,12 @@ ALWAYS_INLINE ARGB32* Bitmap::begin()
|
|||
|
||||
ALWAYS_INLINE ARGB32* Bitmap::end()
|
||||
{
|
||||
return reinterpret_cast<ARGB32*>(reinterpret_cast<u8*>(m_data) + (m_size.height() * m_pitch));
|
||||
return reinterpret_cast<ARGB32*>(reinterpret_cast<u8*>(m_data) + data_size());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE size_t Bitmap::data_size() const
|
||||
{
|
||||
return m_size.height() * m_pitch;
|
||||
}
|
||||
|
||||
template<>
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
|
||||
[[nodiscard]] CMYK* begin();
|
||||
[[nodiscard]] CMYK* end();
|
||||
[[nodiscard]] size_t data_size() const { return m_data.size(); }
|
||||
|
||||
ErrorOr<RefPtr<Bitmap>> to_low_quality_rgb() const;
|
||||
|
||||
|
@ -67,7 +68,7 @@ inline CMYK* CMYKBitmap::begin()
|
|||
|
||||
inline CMYK* CMYKBitmap::end()
|
||||
{
|
||||
return reinterpret_cast<CMYK*>(m_data.data() + m_data.size());
|
||||
return reinterpret_cast<CMYK*>(m_data.data() + data_size());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue