X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=ld42_outofspace;a=blobdiff_plain;f=src%2Fimage.h;fp=src%2Fimage.h;h=1d169795386142e1266ceb624c0a188c2eec7d07;hp=0000000000000000000000000000000000000000;hb=b8200afc389ccca3e86463eb48c0563c0e093552;hpb=cf0e9a55d004e5339adc265b7ea6f41bae5c3cfe diff --git a/src/image.h b/src/image.h new file mode 100644 index 0000000..1d16979 --- /dev/null +++ b/src/image.h @@ -0,0 +1,49 @@ +#ifndef IMAGE_H_ +#define IMAGE_H_ + +#include + +class Image { +public: + enum Format { + FMT_GREY, + FMT_RGB, + FMT_RGBA, + FMT_GREY_FLOAT, + FMT_RGB_FLOAT, + FMT_RGBA_FLOAT + }; + +private: + Format fmt; + int width, height; + void *pixels; + +public: + std::string name; + + Image(); + ~Image(); + + int get_width() const; + int get_height() const; + + Format get_format() const; + + bool create(int x, int y, Format fmt = FMT_RGBA); + bool set_pixels(int xsz, int ysz, void *pixels, Format fmt = FMT_RGBA); + bool set_pixels(int xsz, int ysz, void *pixels, int scan_width, Format fmt = FMT_RGBA); + bool set_pixels(int xsz, int ysz, void *pixels, int x, int y, int scan_width = -1, Format fmt = FMT_RGBA); + void *get_pixels() const; + + void flip_horizontal(); + void flip_vertical(); + void rotate_180(); + + void resize_half(); + + bool load(const char *fname); + bool save(const char *fname) const; +}; + +#endif // IMAGE_H_