summaryrefslogtreecommitdiffstats
path: root/ue2/imgsynth2/cpixmap.h
diff options
context:
space:
mode:
Diffstat (limited to 'ue2/imgsynth2/cpixmap.h')
-rw-r--r--ue2/imgsynth2/cpixmap.h162
1 files changed, 162 insertions, 0 deletions
diff --git a/ue2/imgsynth2/cpixmap.h b/ue2/imgsynth2/cpixmap.h
new file mode 100644
index 0000000..c7537cd
--- /dev/null
+++ b/ue2/imgsynth2/cpixmap.h
@@ -0,0 +1,162 @@
1/**
2 * @module CPixMap
3 * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348)
4 * @brief Implementation of CFile CBitmap handling XPM.
5 * @date 27.04.2009
6 */
7
8#ifndef CPixMap_H
9#define CPixMap_H
10
11#include <stdint.h>
12#include <map>
13#include "cbitmap.h"
14
15
16/**
17 * @class CBitmap
18 * @brief Implementation of CFile handling Windows Bitmaps.
19 *
20 * In order to support operations on bitmaps with different color bitcounts
21 * different implementations of CPixelFormat are used. These classes are
22 * allowed to modify the bitmap headers and pixelbuffer directly.
23 *
24 * On error CFile::FileError is thrown.
25 */
26class CPixMap : public CBitmap
27{
28 public:
29 /**
30 * @method CPixMap
31 * @brief Default ctor
32 * @param -
33 * @return -
34 * @globalvars none
35 * @exception none
36 * @conditions none
37 */
38 CPixMap();
39
40 /**
41 * @method ~CPixMap
42 * @brief Default dtor
43 * @param -
44 * @return -
45 * @globalvars none
46 * @exception none
47 * @conditions none
48 */
49 ~CPixMap()
50 {}
51
52 /**
53 * @method read
54 * @brief Reads Windows Bitmap from filestream.
55 * On error an exception is thrown.
56 * @param in filestream to read data from
57 * @return -
58 * @globalvars none
59 * @exception CFile::FileError
60 * @exception bad_alloc
61 * @conditions none
62 */
63 void read(std::ifstream& in);
64
65 /**
66 * @method write
67 * @brief Writes Windows Bitmap to filestream.
68 * @param out filestream to read data from
69 * @return -
70 * @globalvars none
71 * @exception FileError
72 * @exception bad_alloc
73 * @conditions none
74 */
75
76 void write(std::ofstream& out);
77#ifdef DEBUG
78 /**
79 * @method dump
80 * @brief Dumps the Windows Bitmap file headers to ostream
81 * @param out output stream
82 * @return -
83 * @globalvars
84 * @exception
85 * @conditions
86 */
87 void dump(std::ostream& out);
88#endif
89
90
91
92 /**
93 * @brief Windows Bitmap Info Header structure
94 */
95#pragma pack(push,1)
96 typedef struct
97 {
98 /** the xpm width in pixels (signed integer) */
99 uint32_t xpmWidth;
100 /** the xpm height in pixels (signed integer) */
101 uint32_t xpmHeight;
102 /** the number of colors (signed integer) */
103 uint32_t nColor;
104
105 /** the number of characters per pixel (signed integer) */
106 uint32_t nChar;
107
108 /** X-Position Hotspots */
109 uint32_t xHotspot;
110
111 /** Y-Position Hotspots */
112 uint32_t yHotspot;
113
114 /* color tables*/
115 // std::map<std::string, std::map< std::string, std::string > > xpmColors;
116 // std::map<std::string, uint32_t[3]> xpmColors;
117
118
119 } PIXMAP_FILEHEADER;
120#pragma pack(pop)
121
122 /* TODO */
123 const uint32_t getPixelDataSize()
124 {
125 return m_fileheader.xpmWidth *
126 m_fileheader.xpmHeight *
127 m_fileheader.nChar;
128 }
129
130 /* TODO */
131 const uint32_t getHeight()
132 {
133 /* width and height can be negativ */
134 return m_fileheader.xpmHeight;
135 }
136
137 /* TODO */
138 const uint32_t getWidth()
139 {
140 /* width and height can be negativ */
141 return m_fileheader.xpmWidth;
142 }
143
144 /* TODO */
145 const bool isMirrored()
146 {
147 /* pixmap is never mirrored */
148 return false;
149 }
150
151 protected:
152 /* members */
153 /** fileheader */
154 PIXMAP_FILEHEADER m_fileheader;
155 /** infoheader */
156
157
158};
159
160#endif
161
162/* vim: set et sw=2 ts=2: */