Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-03-26 23:24:26 +0000
committerStijn Buys <ingar@osirion.org>2008-03-26 23:24:26 +0000
commit3d993058e5078fbdfd92d479281ad93bb40a4bc6 (patch)
treefd578d5a44246a90fc08cdf6b9a18f02313ce431 /src/render/image.h
parent2b9f068e7ee4c0d249c715f9eb5a3c2c8a11e6f8 (diff)
improved TGA handling
Diffstat (limited to 'src/render/image.h')
-rw-r--r--src/render/image.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/render/image.h b/src/render/image.h
new file mode 100644
index 0000000..0c1069b
--- /dev/null
+++ b/src/render/image.h
@@ -0,0 +1,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__
+