GraphicsBitmap: Add bpp(), returns the number of bits per pixel.

This commit is contained in:
Andreas Kling 2019-06-25 20:33:24 +02:00
parent b529b4a3e6
commit 5cb324ee02

View file

@ -5,8 +5,8 @@
#include "Size.h"
#include <AK/AKString.h>
#include <AK/MappedFile.h>
#include <AK/RefPtr.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/StringView.h>
#include <SharedBuffer.h>
@ -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; }