doing stuff
[ld42_outofspace] / src / image.h
1 #ifndef IMAGE_H_
2 #define IMAGE_H_
3
4 #include <string>
5
6 class Image {
7 public:
8         enum Format {
9                 FMT_GREY,
10                 FMT_RGB,
11                 FMT_RGBA,
12                 FMT_GREY_FLOAT,
13                 FMT_RGB_FLOAT,
14                 FMT_RGBA_FLOAT
15         };
16
17 private:
18         Format fmt;
19         int width, height;
20         void *pixels;
21
22 public:
23         std::string name;
24
25         Image();
26         ~Image();
27
28         int get_width() const;
29         int get_height() const;
30
31         Format get_format() const;
32
33         bool create(int x, int y, Format fmt = FMT_RGBA);
34         bool set_pixels(int xsz, int ysz, void *pixels, Format fmt = FMT_RGBA);
35         bool set_pixels(int xsz, int ysz, void *pixels, int scan_width, Format fmt = FMT_RGBA);
36         bool set_pixels(int xsz, int ysz, void *pixels, int x, int y, int scan_width = -1, Format fmt = FMT_RGBA);
37         void *get_pixels() const;
38
39         void flip_horizontal();
40         void flip_vertical();
41         void rotate_180();
42
43         void resize_half();
44
45         bool load(const char *fname);
46         bool save(const char *fname) const;
47 };
48
49 #endif  // IMAGE_H_