Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 0c1069bf3adb5725c9b0466e8b1a0f3512088964 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
   render/image.h
   This file is part of the Osirion project and is distributed under 
   the terms of the GNU General Public License version 2 
*/

#ifndef __INCLUDED_RENDER_IMAGE_H__
#define __INCLUDED_RENDER_IMAGE_H__

namespace render {

/// RGB (24bpp) or RGBA (32bpp) image data
class Image {
public:
	Image(unsigned int width, unsigned int height, unsigned int channels);
	~Image();

	// pointer to the image data
	inline unsigned char *data() { return image_data; }

	// index into the image data
	inline unsigned char *operator[](size_t index) { return &image_data[index]; }

	// width of the image in pixels
	inline unsigned int width() const { return image_width; }

	// height of the image in pixels
	inline unsigned int height() const { return image_height; }

	// size of the image data in bytes
	inline size_t size() const { return ((size_t) image_width * (size_t) image_height * (size_t) image_channels); }

	// number of channels 3 (RGB) or 4 (RGBA)
	inline unsigned int channels() const { return image_channels; }

	// set image data to zero
	void clear();

	// swap the red and blue channel values of the image
	void swap_channels();

	// flip upside-down
	void flip();

private:
	unsigned char 		*image_data;

	unsigned int		image_width;
	unsigned int		image_height;
	unsigned int		image_channels;
};

}

#endif // __INCLUDED_RENDER_IMAGE_H__