vrshoot

diff src/image.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/image.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,43 @@
     1.4 +#ifndef IMAGE_H_
     1.5 +#define IMAGE_H_
     1.6 +
     1.7 +class Image {
     1.8 +public:
     1.9 +	enum Format {
    1.10 +		FMT_GREY,
    1.11 +		FMT_RGB,
    1.12 +		FMT_RGBA,
    1.13 +		FMT_GREY_FLOAT,
    1.14 +		FMT_RGB_FLOAT,
    1.15 +		FMT_RGBA_FLOAT
    1.16 +	};
    1.17 +
    1.18 +private:
    1.19 +	Format fmt;
    1.20 +	int width, height;
    1.21 +	void *pixels;
    1.22 +
    1.23 +public:
    1.24 +	Image();
    1.25 +	~Image();
    1.26 +
    1.27 +	int get_width() const;
    1.28 +	int get_height() const;
    1.29 +
    1.30 +	Format get_format() const;
    1.31 +
    1.32 +	bool create(int x, int y, Format fmt = FMT_RGBA);
    1.33 +	bool set_pixels(int xsz, int ysz, void *pixels, Format fmt = FMT_RGBA);
    1.34 +	bool set_pixels(int xsz, int ysz, void *pixels, int scan_width, Format fmt = FMT_RGBA);
    1.35 +	bool set_pixels(int xsz, int ysz, void *pixels, int x, int y, int scan_width = -1, Format fmt = FMT_RGBA);
    1.36 +	void *get_pixels() const;
    1.37 +
    1.38 +	void flip_horizontal();
    1.39 +	void flip_vertical();
    1.40 +	void rotate_180();
    1.41 +
    1.42 +	bool load(const char *fname);
    1.43 +	bool save(const char *fname) const;
    1.44 +};
    1.45 +
    1.46 +#endif	// IMAGE_H_