When writing the X11 (linux) implementation there was a problem with X11 defining a "Display" type and we also have a Display class in the engine. So to fix that problem and minimize the risk for running into other name conflicts. We move everything from global namespace.
66 lines
1.4 KiB
C++
66 lines
1.4 KiB
C++
|
|
#ifndef SPECTRE_GRAPHICS_IMAGE_H
|
|
#define SPECTRE_GRAPHICS_IMAGE_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <Spectre/Math/Color.h>
|
|
#include <Spectre/Math/Vector2.h>
|
|
#include <Spectre/Graphics/PixelFormat.h>
|
|
|
|
namespace sp {
|
|
|
|
class Image
|
|
{
|
|
public :
|
|
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);
|
|
|
|
const Vector2u& getSize() const;
|
|
|
|
unsigned int getWidth() const;
|
|
|
|
unsigned int getHeight() const;
|
|
|
|
unsigned int getBpp() 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);
|
|
|
|
const unsigned char* getPixels() const;
|
|
|
|
void flipY();
|
|
|
|
private :
|
|
|
|
Vector2u m_size;
|
|
|
|
PixelFormat m_format;
|
|
|
|
std::vector<unsigned char> m_pixels;
|
|
};
|
|
|
|
} //namespace sp
|
|
|
|
#endif /* SPECTRE_GRAPHICS_IMAGE_H */
|