goat3dgfx

view src/image.h @ 29:9d581abd0bfb

merged
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 02 Mar 2014 02:18:15 +0200
parents 3d96734fd477
children
line source
1 #ifndef IMAGE_H_
2 #define IMAGE_H_
4 namespace goatgfx {
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 };
17 private:
18 Format fmt;
19 int width, height;
20 void *pixels;
22 public:
23 Image();
24 ~Image();
26 int get_width() const;
27 int get_height() const;
29 Format get_format() const;
31 bool create(int x, int y, Format fmt = FMT_RGBA);
32 bool set_pixels(int xsz, int ysz, void *pixels, Format fmt = FMT_RGBA);
33 bool set_pixels(int xsz, int ysz, void *pixels, int scan_width, Format fmt = FMT_RGBA);
34 bool set_pixels(int xsz, int ysz, void *pixels, int x, int y, int scan_width = -1, Format fmt = FMT_RGBA);
35 void *get_pixels() const;
37 void flip_horizontal();
38 void flip_vertical();
39 void rotate_180();
41 bool load(const char *fname);
42 bool save(const char *fname) const;
43 };
45 } // namespace goatgfx
47 #endif // IMAGE_H_