Initial commit
This commit is contained in:
commit
edfc5298e1
252 changed files with 93965 additions and 0 deletions
62
include/Spectre/Graphics/Image.h
Normal file
62
include/Spectre/Graphics/Image.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
|
||||
#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>
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
#endif /* SPECTRE_GRAPHICS_IMAGE_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue