From 3d993058e5078fbdfd92d479281ad93bb40a4bc6 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 26 Mar 2008 23:24:26 +0000 Subject: improved TGA handling --- src/render/image.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/render/image.h (limited to 'src/render/image.h') 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__ + -- cgit v1.2.3