#ifndef SPECTRE_GRAPHICS_IMAGE_H #define SPECTRE_GRAPHICS_IMAGE_H #include #include #include #include #include namespace sp { class Image { public : enum Channels { Alpha, RGB, RGBA }; Image(); 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; unsigned int getWidth() const; unsigned int getHeight() const; unsigned int getNumChannels() const; unsigned int getStride() const; PixelFormat getFormat() const; // Returns true if the image has a alpha channel. bool hasAlpha() const; bool loadFromFile(const std::string& filename); bool loadFromMemory(const void *data, unsigned int size); void saveToFile(const std::string& filename) const; void setPixel(unsigned x, unsigned y, const Color& c); Color getPixel(unsigned x, unsigned y) const; void setPixels(const void* pixels, PixelFormat format = PixelFormat::PF_RGBA); const unsigned char* getPixels() const; void flipY(); private : Vector2u m_size; enum Channels m_channels; std::vector m_pixels; }; } //namespace sp #endif /* SPECTRE_GRAPHICS_IMAGE_H */