summaryrefslogtreecommitdiffstats
path: root/ue2/imgsynth2/cbitmap.h
diff options
context:
space:
mode:
authormanuel <manuel@clan-server.at>2009-04-28 16:29:24 +0200
committermanuel <manuel@clan-server.at>2009-04-28 16:29:24 +0200
commitf3c5bc280737573cf8597f18c011a1a1092e32d3 (patch)
treea0a9d01787bbcbda381fde6fb91ee288b171d410 /ue2/imgsynth2/cbitmap.h
parentaa139a7d2b3f26af7590edbf413df67195c5d900 (diff)
downloadooprog-f3c5bc280737573cf8597f18c011a1a1092e32d3.tar.gz
ooprog-f3c5bc280737573cf8597f18c011a1a1092e32d3.tar.bz2
ooprog-f3c5bc280737573cf8597f18c011a1a1092e32d3.zip
making cbitmap abstract
Diffstat (limited to 'ue2/imgsynth2/cbitmap.h')
-rw-r--r--ue2/imgsynth2/cbitmap.h236
1 files changed, 0 insertions, 236 deletions
diff --git a/ue2/imgsynth2/cbitmap.h b/ue2/imgsynth2/cbitmap.h
deleted file mode 100644
index ca3d6ef..0000000
--- a/ue2/imgsynth2/cbitmap.h
+++ /dev/null
@@ -1,236 +0,0 @@
1/**
2 * @module cbitmap
3 * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348)
4 * @brief Implementation of CFile handling Windows Bitmaps.
5 * @date 17.04.2009
6 */
7
8#ifndef CBITMAP_H
9#define CBITMAP_H
10
11#include <stdint.h>
12#include "cfile.h"
13
14class CPixelFormat;
15#include "cpixelformat.h"
16
17/**
18 * @class CBitmap
19 * @brief Implementation of CFile handling Windows Bitmaps.
20 *
21 * In order to support operations on bitmaps with different color bitcounts
22 * different implementations of CPixelFormat are used. These classes are
23 * allowed to modify the bitmap headers and pixelbuffer directly.
24 *
25 * On error CFile::FileError is thrown.
26 */
27class CBitmap : public CFile
28{
29 public:
30 /**
31 * @method CBitmap
32 * @brief Default ctor
33 * @param -
34 * @return -
35 * @globalvars none
36 * @exception none
37 * @conditions none
38 */
39 CBitmap();
40
41 /**
42 * @method ~CBitmap
43 * @brief Default dtor
44 * @param -
45 * @return -
46 * @globalvars none
47 * @exception none
48 * @conditions none
49 */
50 ~CBitmap();
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 void write(std::ofstream& out);
76
77 /**
78 * @method callFunc
79 * @brief Delegates the function and its parameters to the correct
80 * internal method
81 * @param func function name
82 * @param params function parameters as list
83 * @return -
84 * @globalvars none
85 * @exception ParserError
86 * @conditions none
87 */
88 void callFunc(const std::string& func, const std::list<std::string>& params);
89
90#ifdef DEBUG
91 /**
92 * @method dump
93 * @brief Dumps the Windows Bitmap file headers to ostream
94 * @param out output stream
95 * @return -
96 * @globalvars
97 * @exception
98 * @conditions
99 */
100 void dump(std::ostream& out);
101#endif
102
103 /**
104 * @brief Windows Bitmap File Header structure
105 */
106#pragma pack(push,1)
107 typedef struct
108 {
109 /** the magic number used to identify the BMP file */
110 uint8_t bfType[2];
111 /** the size of the BMP file in bytes */
112 uint32_t bfSize;
113 /** reserved */
114 uint32_t bfReserved;
115 /** the offset of the byte where the bitmap data can be found */
116 uint32_t bfOffBits;
117 } BITMAP_FILEHEADER;
118#pragma pack(pop)
119
120 /**
121 * @brief Windows Bitmap Info Header structure
122 */
123#pragma pack(push,1)
124 typedef struct
125 {
126 /** the size of this header (40 bytes) */
127 uint32_t biSize;
128 /** the bitmap width in pixels (signed integer) */
129 int32_t biWidth;
130 /** the bitmap height in pixels (signed integer) */
131 int32_t biHeight;
132 /** the number of color planes being used. Must be set to 1 */
133 uint16_t biPlanes;
134 /** the number of bits per pixel, which is the color depth of the image */
135 uint16_t biBitCount;
136 /** the compression method being used */
137 uint32_t biCompression;
138 /** the image size */
139 uint32_t biSizeImage;
140 /** the horizontal resolution of the image (pixel per meter) */
141 int32_t biXPelsPerMeter;
142 /** the vertical resolution of the image (pixel per meter) */
143 int32_t biYPelsPerMeter;
144 /** the number of colors in the color palette, or 0 to default to 2^n */
145 uint32_t biClrUsed;
146 /** the number of important colors used, or 0 when every color is
147 * important; generally ignored. */
148 uint32_t biClrImportant;
149 } BITMAP_INFOHEADER;
150#pragma pack(pop)
151
152 /**
153 * @method getFileHeader
154 * @brief Returns reference to fileheader structure of bitmap
155 * @param -
156 * @return reference to fileheader structure
157 * @globalvars none
158 * @exception none
159 * @conditions none
160 */
161 BITMAP_FILEHEADER &getFileHeader()
162 {
163 return m_fileheader;
164 }
165
166 /**
167 * @method getInfoHeader
168 * @brief Returns reference to infoheader structure of bitmap
169 * @param -
170 * @return reference to infoheader structure
171 * @globalvars none
172 * @exception none
173 * @conditions none
174 */
175 BITMAP_INFOHEADER &getInfoHeader()
176 {
177 return m_infoheader;
178 }
179
180 /**
181 * @method getPixelData
182 * @brief Returns pointer to pixelbuffer
183 * @param -
184 * @return pointer to pixelbuffer
185 * @globalvars none
186 * @exception none
187 * @conditions none
188 */
189 uint8_t *getPixelData()
190 {
191 return m_pixeldata;
192 }
193
194 protected:
195 /**
196 * @method fillrect
197 * @brief Fills rectangle in image starting on position x, y
198 * width size width, height and color red, green, blue.
199 * @param params function parameters as list
200 * @return -
201 * @globalvars none
202 * @exception FileError
203 * @conditions none
204 *
205 * Scriptfile syntax: fillrect(x, y, width, height, red, green, blue)
206 */
207 void fillrect(std::list<std::string> params);
208
209 /* TODO */
210 void invert(std::list<std::string> params);
211
212 /* TODO */
213 void brightness(std::list<std::string> params);
214
215 /* TODO */
216 void mirror_y(std::list<std::string> params);
217
218 /* TODO */
219 void mirror_x(std::list<std::string> params);
220
221 /* members */
222 /** fileheader */
223 BITMAP_FILEHEADER m_fileheader;
224 /** infoheader */
225 BITMAP_INFOHEADER m_infoheader;
226 /** pointer to pixelbuffer */
227 uint8_t *m_pixeldata;
228 /** set of supported PixelFormat handlers */
229 std::set<CPixelFormat *> m_handlers;
230 /** pointer to CPixelFormat implementation */
231 CPixelFormat *m_pixelformat;
232};
233
234#endif
235
236/* vim: set et sw=2 ts=2: */