Graphics/Image: dont store PixelFormat, instead define a new enum for number of channels.
The image class has a strict internal representation so we dont need "format". PixelFormat enum can be passed to functions that modify the pixel data (like setPixels()) so that a proper convertion can be done.
This commit is contained in:
parent
6f9b33be8f
commit
f7fcc2633c
4 changed files with 53 additions and 86 deletions
|
|
@ -13,13 +13,16 @@ namespace sp {
|
|||
class Image
|
||||
{
|
||||
public :
|
||||
enum Channels {
|
||||
Alpha,
|
||||
RGB,
|
||||
RGBA
|
||||
};
|
||||
|
||||
Image();
|
||||
|
||||
void create(unsigned width, unsigned height, const Color& color = Color::Black);
|
||||
|
||||
void create(unsigned width, unsigned height, const void* pixels);
|
||||
void create(PixelFormat format, unsigned width, unsigned height, const Color& color = Color::Black);
|
||||
void create(PixelFormat format, unsigned width, unsigned height, const void* pixels);
|
||||
void create(unsigned width, unsigned height, const Color& color = Color::Black, enum Channels comp = Channels::RGBA);
|
||||
void create(unsigned width, unsigned height, const void* pixels, PixelFormat format = PixelFormat::PF_RGBA);
|
||||
|
||||
const Vector2u& getSize() const;
|
||||
|
||||
|
|
@ -27,7 +30,7 @@ public :
|
|||
|
||||
unsigned int getHeight() const;
|
||||
|
||||
unsigned int getBpp() const;
|
||||
unsigned int getNumChannels() const;
|
||||
|
||||
unsigned int getStride() const;
|
||||
|
||||
|
|
@ -46,7 +49,7 @@ public :
|
|||
|
||||
Color getPixel(unsigned x, unsigned y) const;
|
||||
|
||||
void setPixels(const void* pixels);
|
||||
void setPixels(const void* pixels, PixelFormat format = PixelFormat::PF_RGBA);
|
||||
|
||||
const unsigned char* getPixels() const;
|
||||
|
||||
|
|
@ -56,7 +59,7 @@ private :
|
|||
|
||||
Vector2u m_size;
|
||||
|
||||
PixelFormat m_format;
|
||||
enum Channels m_channels;
|
||||
|
||||
std::vector<unsigned char> m_pixels;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue