dbf-halloween2015

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/image.h	Sun Nov 01 00:09:12 2015 +0200
     1.3 @@ -0,0 +1,49 @@
     1.4 +#ifndef IMAGE_H_
     1.5 +#define IMAGE_H_
     1.6 +
     1.7 +class Image {
     1.8 +private:
     1.9 +	mutable int tex_width, tex_height;
    1.10 +	mutable unsigned int tex;
    1.11 +	mutable bool tex_valid;
    1.12 +
    1.13 +public:
    1.14 +	int width, height;
    1.15 +	unsigned char *pixels;
    1.16 +
    1.17 +	Image();
    1.18 +	~Image();
    1.19 +
    1.20 +	Image(const Image &img);
    1.21 +	Image &operator =(const Image &img);
    1.22 +
    1.23 +	bool create(int width, int height, unsigned char *pixels = 0);
    1.24 +	void destroy();
    1.25 +
    1.26 +	bool load(const char *fname);
    1.27 +	bool save(const char *fname) const;
    1.28 +
    1.29 +	unsigned int texture() const;
    1.30 +	int texture_width() const;
    1.31 +	int texture_height() const;
    1.32 +
    1.33 +	void invalidate_texture();
    1.34 +};
    1.35 +
    1.36 +void clear_image(Image *img);
    1.37 +void clear_image(Image *img, float r, float g, float b, float a = 255);
    1.38 +void clear_image_alpha(Image *img, float a);
    1.39 +
    1.40 +enum ImgCombine {
    1.41 +	IMG_OP_ADD,
    1.42 +	IMG_OP_SUB,
    1.43 +	IMG_OP_MUL,
    1.44 +	IMG_OP_LERP
    1.45 +};
    1.46 +
    1.47 +bool combine_image(Image *dest, const Image *aimg, const Image *bimg, ImgCombine op = IMG_OP_LERP, float t = 0.5);
    1.48 +
    1.49 +void convolve_horiz_image(Image *dest, float *kern, int ksz, float scale = 0.0);
    1.50 +void convolve_vert_image(Image *dest, float *kern, int ksz, float scale = 0.0);
    1.51 +
    1.52 +#endif	// IMAGE_H_