summaryrefslogtreecommitdiff
path: root/includes/Image.h
diff options
context:
space:
mode:
authorPixel <Pixel>2002-07-21 11:12:13 +0000
committerPixel <Pixel>2002-07-21 11:12:13 +0000
commit6528f07c516efe4d3b344f01740067878d5d9a43 (patch)
treef097e6797752dffe7b498a4f153e83bdeb59f024 /includes/Image.h
parentb54786a5120b48bd98fc4b199176d45bda3c2d67 (diff)
Hello Baltisot
Diffstat (limited to 'includes/Image.h')
-rw-r--r--includes/Image.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/includes/Image.h b/includes/Image.h
new file mode 100644
index 0000000..8dc6788
--- /dev/null
+++ b/includes/Image.h
@@ -0,0 +1,61 @@
+#ifndef __IMAGE_H__
+#define __IMAGE_H__
+#ifdef __cplusplus
+
+#include <Buffer.h>
+
+enum {
+ FORMAT_TGA_BASIC
+} format_t;
+
+struct Color {
+ Color(unsigned char aR, unsigned char aG, unsigned char aB, unsigned char aA = 255) :
+ R(aR), G(aG), B(aB), A(aA) { }
+ unsigned char R, G, B, A;
+};
+
+class Image : public Buffer {
+ public:
+ Image(unsigned int, unsigned int);
+ virtual ~Image();
+ Color GetPixel(unsigned int, unsigned int);
+ void SetPixel(unsigned int, unsigned int, Color);
+ bool Prepare(unsigned int = FORMAT_TGA_BASIC);
+ void Fill(Color = Color(0, 0, 0));
+ virtual String GetName();
+ virtual bool CanWrite();
+
+ private:
+ typedef unsigned char Byte;
+ typedef unsigned short int Word;
+ typedef unsigned long int DWord;
+ struct TGAHeader {
+ Byte IDLength;
+ Byte ColorMapType;
+ Byte ImageType;
+ Word CM_FirstEntry;
+ Word CM_Length;
+ Byte CM_EntrySize;
+ Word IS_XOrigin;
+ Word IS_YOrigin;
+ Word IS_Width;
+ Word IS_Height;
+ Byte IS_Depth;
+ Byte IS_Descriptor;
+ } __attribute__((packed));
+
+ struct TGAFooter {
+ DWord ExtOffset;
+ DWord DevOffset;
+ char Sig[18];
+ } __attribute__((packed));
+
+ unsigned int x, y;
+ bool r;
+ Color * img;
+};
+
+#else
+#error This only works with a C++ compiler
+#endif
+#endif