From 5cb324ee0281682c4baf1e943894f698aff32e5a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 25 Jun 2019 20:33:24 +0200 Subject: [PATCH] GraphicsBitmap: Add bpp(), returns the number of bits per pixel. --- SharedGraphics/GraphicsBitmap.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/SharedGraphics/GraphicsBitmap.h b/SharedGraphics/GraphicsBitmap.h index 426dffa860..149338fe9d 100644 --- a/SharedGraphics/GraphicsBitmap.h +++ b/SharedGraphics/GraphicsBitmap.h @@ -5,8 +5,8 @@ #include "Size.h" #include #include -#include #include +#include #include #include @@ -39,6 +39,21 @@ public: size_t pitch() const { return m_pitch; } int shared_buffer_id() const { return m_shared_buffer ? m_shared_buffer->shared_buffer_id() : -1; } + unsigned bpp() const + { + switch (m_format) { + case Format::Indexed8: + return 8; + case Format::RGB32: + case Format::RGBA32: + return 32; + case Format::Invalid: + return 0; + default: + ASSERT_NOT_REACHED(); + } + } + void fill(Color); bool has_alpha_channel() const { return m_format == Format::RGBA32; }