dbf-halloween2015

view src/image.h @ 0:50683c78264e

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 01 Nov 2015 00:09:12 +0200
parents
children
line source
1 #ifndef IMAGE_H_
2 #define IMAGE_H_
4 class Image {
5 private:
6 mutable int tex_width, tex_height;
7 mutable unsigned int tex;
8 mutable bool tex_valid;
10 public:
11 int width, height;
12 unsigned char *pixels;
14 Image();
15 ~Image();
17 Image(const Image &img);
18 Image &operator =(const Image &img);
20 bool create(int width, int height, unsigned char *pixels = 0);
21 void destroy();
23 bool load(const char *fname);
24 bool save(const char *fname) const;
26 unsigned int texture() const;
27 int texture_width() const;
28 int texture_height() const;
30 void invalidate_texture();
31 };
33 void clear_image(Image *img);
34 void clear_image(Image *img, float r, float g, float b, float a = 255);
35 void clear_image_alpha(Image *img, float a);
37 enum ImgCombine {
38 IMG_OP_ADD,
39 IMG_OP_SUB,
40 IMG_OP_MUL,
41 IMG_OP_LERP
42 };
44 bool combine_image(Image *dest, const Image *aimg, const Image *bimg, ImgCombine op = IMG_OP_LERP, float t = 0.5);
46 void convolve_horiz_image(Image *dest, float *kern, int ksz, float scale = 0.0);
47 void convolve_vert_image(Image *dest, float *kern, int ksz, float scale = 0.0);
49 #endif // IMAGE_H_