diff options
| author | manuel <manuel@nc8430.lan> | 2009-04-27 00:25:16 +0200 |
|---|---|---|
| committer | manuel <manuel@nc8430.lan> | 2009-04-27 00:25:16 +0200 |
| commit | aa139a7d2b3f26af7590edbf413df67195c5d900 (patch) | |
| tree | ba99ea3b2af9aa191386550f025520117f18f4f8 /ue2/imgsynth2 | |
| parent | 384539f7cc9feaa7ef7cee385cce472c6966c843 (diff) | |
| download | ooprog-aa139a7d2b3f26af7590edbf413df67195c5d900.tar.gz ooprog-aa139a7d2b3f26af7590edbf413df67195c5d900.tar.bz2 ooprog-aa139a7d2b3f26af7590edbf413df67195c5d900.zip | |
Adding ue2
Diffstat (limited to 'ue2/imgsynth2')
31 files changed, 1845 insertions, 0 deletions
diff --git a/ue2/imgsynth2/Makefile b/ue2/imgsynth2/Makefile new file mode 100644 index 0000000..cbf3d33 --- /dev/null +++ b/ue2/imgsynth2/Makefile | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | # Makefile for imgsynth2 | ||
| 2 | # Author: Guenther Neuwirth (0626638), Manuel Mausz (0728348) | ||
| 3 | # Created: 26.04.2009 | ||
| 4 | |||
| 5 | CC= g++ | ||
| 6 | LD= $(CC) | ||
| 7 | DEBUGFLAGS= -DNDEBUG | ||
| 8 | CFLAGS= -O -ansi -pedantic-errors -Wall $(DEBUGFLAGS) | ||
| 9 | LDFLAGS= | ||
| 10 | LIBS= -lboost_program_options | ||
| 11 | |||
| 12 | BIN= imgsynth2 | ||
| 13 | OBJS= cpixelformat_bgr24.o cpixelformat_bgr555.o \ | ||
| 14 | cbitmap.o cscriptparser.o imgsynth2.o | ||
| 15 | HEADERS= cpixelformat.h cpixelformat_bgr24.h cpixelformat_bgr555.h \ | ||
| 16 | cfile.h cbitmap.h cscriptparser.h | ||
| 17 | |||
| 18 | .SUFFIXES: .cpp .o | ||
| 19 | |||
| 20 | all: $(BIN) | ||
| 21 | |||
| 22 | .cpp.o: | ||
| 23 | $(CC) $(CFLAGS) -c $< -o $@ | ||
| 24 | |||
| 25 | $(OBJS): $(HEADERS) | ||
| 26 | |||
| 27 | $(BIN): $(OBJS) | ||
| 28 | $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) | ||
| 29 | |||
| 30 | debug: | ||
| 31 | @$(MAKE) all "DEBUGFLAGS=-DDEBUG -g" | ||
| 32 | |||
| 33 | clean: | ||
| 34 | rm -f $(OBJS) $(BIN) | ||
| 35 | |||
| 36 | run test: all | ||
| 37 | @./test/test.sh | ||
| 38 | |||
| 39 | .PHONY: clean | ||
| 40 | |||
| 41 | # vim600: noet sw=8 ts=8 | ||
diff --git a/ue2/imgsynth2/cbitmap.cpp b/ue2/imgsynth2/cbitmap.cpp new file mode 100644 index 0000000..fc1a7c0 --- /dev/null +++ b/ue2/imgsynth2/cbitmap.cpp | |||
| @@ -0,0 +1,382 @@ | |||
| 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 | #include <boost/lexical_cast.hpp> | ||
| 9 | #include <boost/numeric/conversion/cast.hpp> | ||
| 10 | #ifdef DEBUG | ||
| 11 | # include <iostream> | ||
| 12 | #endif | ||
| 13 | #include "cbitmap.h" | ||
| 14 | #include "cpixelformat_bgr24.h" | ||
| 15 | #include "cpixelformat_bgr555.h" | ||
| 16 | |||
| 17 | using namespace std; | ||
| 18 | |||
| 19 | CBitmap::CBitmap() | ||
| 20 | : m_pixeldata(NULL), m_pixelformat(NULL) | ||
| 21 | { | ||
| 22 | m_types.insert("BMP"); | ||
| 23 | |||
| 24 | /* add our handlers */ | ||
| 25 | m_handlers.insert(new CPixelFormat_BGR24(this)); | ||
| 26 | m_handlers.insert(new CPixelFormat_BGR555(this)); | ||
| 27 | } | ||
| 28 | |||
| 29 | /*----------------------------------------------------------------------------*/ | ||
| 30 | |||
| 31 | CBitmap::~CBitmap() | ||
| 32 | { | ||
| 33 | /* delete pixeldata */ | ||
| 34 | if (m_pixeldata != NULL) | ||
| 35 | delete[] m_pixeldata; | ||
| 36 | m_pixeldata = NULL; | ||
| 37 | |||
| 38 | /* delete pixelformat handlers */ | ||
| 39 | set<CPixelFormat *>::iterator it; | ||
| 40 | for (it = m_handlers.begin(); it != m_handlers.end(); it++) | ||
| 41 | delete *it; | ||
| 42 | m_pixelformat = NULL; | ||
| 43 | } | ||
| 44 | |||
| 45 | /*----------------------------------------------------------------------------*/ | ||
| 46 | |||
| 47 | void CBitmap::read(std::ifstream& in) | ||
| 48 | { | ||
| 49 | /* read and check file header */ | ||
| 50 | in.read(reinterpret_cast<char *>(&m_fileheader), sizeof(m_fileheader)); | ||
| 51 | |||
| 52 | if (m_fileheader.bfType[0] != 'B' || m_fileheader.bfType[1] != 'M') | ||
| 53 | throw FileError("Imagefile has invalid Bitmap header."); | ||
| 54 | /* bfSize is unreliable (http://de.wikipedia.org/wiki/Windows_Bitmap) */ | ||
| 55 | if (m_fileheader.bfSize < 0) | ||
| 56 | throw FileError("Bitmap filesize is less than zero?"); | ||
| 57 | |||
| 58 | /* read and check info header */ | ||
| 59 | in.read(reinterpret_cast<char *>(&m_infoheader), sizeof(m_infoheader)); | ||
| 60 | |||
| 61 | if (m_infoheader.biSize != 40) | ||
| 62 | throw FileError("Bitmap info header size is invalid."); | ||
| 63 | if (m_infoheader.biPlanes != 1) | ||
| 64 | throw FileError("Bitmap color planes is not set to 1."); | ||
| 65 | if (m_infoheader.biCompression != 0) | ||
| 66 | throw FileError("Bitmap compression is set but not supported."); | ||
| 67 | if (m_infoheader.biSizeImage < 0) | ||
| 68 | throw FileError("Bitmap image size is less than zero?"); | ||
| 69 | if (m_infoheader.biClrUsed != 0 || m_infoheader.biClrImportant != 0) | ||
| 70 | throw FileError("Bitmap colortable is used but not supported."); | ||
| 71 | |||
| 72 | /* read pixel data using separate class */ | ||
| 73 | if (m_infoheader.biSizeImage > 0) | ||
| 74 | { | ||
| 75 | if (m_pixeldata != NULL) | ||
| 76 | delete[] m_pixeldata; | ||
| 77 | m_pixeldata = new uint8_t[m_infoheader.biSizeImage]; | ||
| 78 | in.read(reinterpret_cast<char *>(m_pixeldata), m_infoheader.biSizeImage); | ||
| 79 | } | ||
| 80 | |||
| 81 | /* get pixelformat instance */ | ||
| 82 | m_pixelformat = NULL; | ||
| 83 | set<CPixelFormat *>::iterator it; | ||
| 84 | for (it = m_handlers.begin(); it != m_handlers.end(); it++) | ||
| 85 | { | ||
| 86 | if (m_infoheader.biBitCount == (*it)->getBitCount()) | ||
| 87 | { | ||
| 88 | m_pixelformat = *it; | ||
| 89 | break; | ||
| 90 | } | ||
| 91 | } | ||
| 92 | if (m_pixelformat == NULL) | ||
| 93 | throw FileError("Bitmap bitcount is not supported."); | ||
| 94 | } | ||
| 95 | |||
| 96 | /*----------------------------------------------------------------------------*/ | ||
| 97 | |||
| 98 | void CBitmap::write(std::ofstream& out) | ||
| 99 | { | ||
| 100 | /* set header values */ | ||
| 101 | m_fileheader.bfSize = m_infoheader.biSizeImage + sizeof(m_infoheader) + sizeof(m_fileheader); | ||
| 102 | |||
| 103 | /* write file header */ | ||
| 104 | out.write(reinterpret_cast<char *>(&m_fileheader), sizeof(m_fileheader)); | ||
| 105 | |||
| 106 | /* write info header */ | ||
| 107 | out.write(reinterpret_cast<char *>(&m_infoheader), sizeof(m_infoheader)); | ||
| 108 | |||
| 109 | /* write pixel data */ | ||
| 110 | if (m_pixeldata != NULL) | ||
| 111 | out.write(reinterpret_cast<char *>(m_pixeldata), m_infoheader.biSizeImage); | ||
| 112 | } | ||
| 113 | |||
| 114 | /*----------------------------------------------------------------------------*/ | ||
| 115 | |||
| 116 | void CBitmap::callFunc(const std::string& func, const std::list<std::string>& params) | ||
| 117 | { | ||
| 118 | if (func.empty()) | ||
| 119 | throw FileError("Function name is empty."); | ||
| 120 | |||
| 121 | if (func == "fillrect") | ||
| 122 | fillrect(params); | ||
| 123 | else if (func == "mirror_x") | ||
| 124 | mirror_x(params); | ||
| 125 | else if (func == "mirror_y") | ||
| 126 | mirror_y(params); | ||
| 127 | else if (func == "invert") | ||
| 128 | invert(params); | ||
| 129 | else | ||
| 130 | throw FileError("Unknown function '" + func + "'."); | ||
| 131 | } | ||
| 132 | |||
| 133 | /*----------------------------------------------------------------------------*/ | ||
| 134 | |||
| 135 | void CBitmap::fillrect(std::list<std::string> params) | ||
| 136 | { | ||
| 137 | /* check prerequirements */ | ||
| 138 | if (params.size() != 7) | ||
| 139 | throw FileError("Invalid number of function parameters (must be 7)."); | ||
| 140 | |||
| 141 | /* do nothing if no pixel exists */ | ||
| 142 | if (m_pixeldata == NULL || m_pixelformat == NULL) | ||
| 143 | return; | ||
| 144 | |||
| 145 | /* convert parameters */ | ||
| 146 | uint32_t pparams[7]; | ||
| 147 | int i = 0; | ||
| 148 | try | ||
| 149 | { | ||
| 150 | for(i = 0; i < 7; i++) | ||
| 151 | { | ||
| 152 | pparams[i] = boost::lexical_cast<uint32_t>(params.front()); | ||
| 153 | params.pop_front(); | ||
| 154 | } | ||
| 155 | } | ||
| 156 | catch(boost::bad_lexical_cast& ex) | ||
| 157 | { | ||
| 158 | throw FileError("Invalid parameter (" + params.front() + ")."); | ||
| 159 | } | ||
| 160 | |||
| 161 | /* width and height can be negativ */ | ||
| 162 | uint32_t width = static_cast<uint32_t>(abs(m_infoheader.biWidth)); | ||
| 163 | uint32_t height = static_cast<uint32_t>(abs(m_infoheader.biHeight)); | ||
| 164 | |||
| 165 | /* check parameter values are in range */ | ||
| 166 | if (pparams[0] < 0 || pparams[0] > width | ||
| 167 | || pparams[1] < 0 || pparams[1] > height) | ||
| 168 | throw FileError("At least one x/y-parameter is out of range."); | ||
| 169 | |||
| 170 | /* check parameter values are in range */ | ||
| 171 | unsigned int max[3]; | ||
| 172 | m_pixelformat->getMaxColor(&max[0], &max[1], &max[2]); | ||
| 173 | if (pparams[4] < 0 || pparams[4] > max[0] | ||
| 174 | || pparams[5] < 0 || pparams[5] > max[1] | ||
| 175 | || pparams[6] < 0 || pparams[6] > max[2]) | ||
| 176 | throw FileError("At least one pixel color parameter is out of range."); | ||
| 177 | |||
| 178 | if (pparams[2] < 0 || pparams[2] + pparams[0] > width | ||
| 179 | || pparams[3] < 0 || pparams[3] + pparams[1] > height) | ||
| 180 | throw FileError("At least one w/h-parameter is out of range."); | ||
| 181 | |||
| 182 | /* call setPixel for every pixel in the rectangel */ | ||
| 183 | for(uint32_t i = pparams[0]; i < pparams[2] + pparams[0]; i++) | ||
| 184 | { | ||
| 185 | for(uint32_t j = pparams[1]; j < pparams[3] + pparams[1]; j++) | ||
| 186 | { | ||
| 187 | try | ||
| 188 | { | ||
| 189 | m_pixelformat->setPixel(&pparams[4], i, j); | ||
| 190 | } | ||
| 191 | catch(CPixelFormat::PixelFormatError& ex) | ||
| 192 | { | ||
| 193 | stringstream errstr; | ||
| 194 | errstr << "Can't set pixel (pos=[" << i << "," << j << "] col=[" | ||
| 195 | << pparams[4] << "," << pparams[5] << "," << pparams[6] << "]): " | ||
| 196 | << ex.what(); | ||
| 197 | throw FileError(errstr.str()); | ||
| 198 | } | ||
| 199 | } | ||
| 200 | } | ||
| 201 | } | ||
| 202 | |||
| 203 | /*----------------------------------------------------------------------------*/ | ||
| 204 | |||
| 205 | #include <iostream> | ||
| 206 | void CBitmap::invert(std::list<std::string> params) | ||
| 207 | { | ||
| 208 | /* check prerequirements */ | ||
| 209 | if (params.size() != 0) | ||
| 210 | throw FileError("Invalid number of function parameters (must be 0)."); | ||
| 211 | |||
| 212 | /* do nothing if no pixel exists */ | ||
| 213 | if (m_pixeldata == NULL || m_pixelformat == NULL) | ||
| 214 | return; | ||
| 215 | |||
| 216 | /* width and height can be negativ */ | ||
| 217 | uint32_t width = static_cast<uint32_t>(abs(m_infoheader.biWidth)); | ||
| 218 | uint32_t height = static_cast<uint32_t>(abs(m_infoheader.biHeight)); | ||
| 219 | unsigned int pixelwidth = m_pixelformat->getBitCount()/8; | ||
| 220 | |||
| 221 | /* calc rowsize - boundary is 32 */ | ||
| 222 | uint32_t rowsize = 4 * static_cast<uint32_t>( | ||
| 223 | ((m_pixelformat->getBitCount() * abs(m_infoheader.biWidth)) + 31) / 32 | ||
| 224 | ); | ||
| 225 | |||
| 226 | for(uint32_t i = 0; i < height; i++) | ||
| 227 | { | ||
| 228 | for(uint32_t j = 0; j <= width; j++) | ||
| 229 | { | ||
| 230 | cout << j << endl; | ||
| 231 | } | ||
| 232 | } | ||
| 233 | |||
| 234 | #if 0 | ||
| 235 | /* uint32_t offset = i * rowsize; | ||
| 236 | |||
| 237 | for(uint32_t j = 0; j <= width/2; j++) | ||
| 238 | { | ||
| 239 | uint32_t poffset = offset + j * pixelwidth; | ||
| 240 | uint32_t pbackset = offset + width * pixelwidth - j * pixelwidth; | ||
| 241 | |||
| 242 | /* boundary check */ | ||
| 243 | if (pbackset > m_infoheader.biSizeImage) | ||
| 244 | throw FileError("Mirrored pixel position is out of range."); | ||
| 245 | |||
| 246 | /* mirroring, backup right data first */ | ||
| 247 | copy(m_pixeldata + pbackset - pixelwidth, m_pixeldata + pbackset, buf); | ||
| 248 | copy(m_pixeldata + poffset, m_pixeldata + poffset + pixelwidth, m_pixeldata + pbackset - pixelwidth); | ||
| 249 | copy(buf, buf + pixelwidth, m_pixeldata + poffset); | ||
| 250 | } | ||
| 251 | } | ||
| 252 | #endif | ||
| 253 | } | ||
| 254 | |||
| 255 | /*----------------------------------------------------------------------------*/ | ||
| 256 | |||
| 257 | void CBitmap::brightness(std::list<std::string> params) | ||
| 258 | { | ||
| 259 | } | ||
| 260 | |||
| 261 | /*----------------------------------------------------------------------------*/ | ||
| 262 | |||
| 263 | void CBitmap::mirror_y(std::list<std::string> params) | ||
| 264 | { | ||
| 265 | /* check prerequirements */ | ||
| 266 | if (params.size() != 0) | ||
| 267 | throw FileError("Invalid number of function parameters (must be 0)."); | ||
| 268 | |||
| 269 | /* do nothing if no pixel exists */ | ||
| 270 | if (m_pixeldata == NULL || m_pixelformat == NULL) | ||
| 271 | return; | ||
| 272 | |||
| 273 | /* height can be negativ */ | ||
| 274 | uint32_t height = static_cast<uint32_t>(abs(m_infoheader.biHeight)); | ||
| 275 | |||
| 276 | /* calc rowsize - boundary is 32 */ | ||
| 277 | uint32_t rowsize = 4 * static_cast<uint32_t>( | ||
| 278 | ((m_pixelformat->getBitCount() * abs(m_infoheader.biWidth)) + 31) / 32 | ||
| 279 | ); | ||
| 280 | |||
| 281 | uint8_t *buf = new uint8_t[rowsize]; | ||
| 282 | for(uint32_t i = 0; i < height/2; i++) | ||
| 283 | { | ||
| 284 | uint32_t j = height - i - 1; | ||
| 285 | uint32_t offset = i * rowsize; | ||
| 286 | uint32_t backset = j * rowsize; | ||
| 287 | |||
| 288 | /* boundary check */ | ||
| 289 | if (offset + rowsize > m_infoheader.biSizeImage | ||
| 290 | || backset + rowsize > m_infoheader.biSizeImage) | ||
| 291 | throw FileError("Mirrored pixel position is out of range."); | ||
| 292 | |||
| 293 | /* mirroring, backup lower data first */ | ||
| 294 | copy(m_pixeldata + backset, m_pixeldata + backset + rowsize, buf); | ||
| 295 | copy(m_pixeldata + offset, m_pixeldata + offset + rowsize, m_pixeldata + backset); | ||
| 296 | copy(buf, buf + rowsize, m_pixeldata + offset); | ||
| 297 | } | ||
| 298 | delete[] buf; | ||
| 299 | } | ||
| 300 | |||
| 301 | /*----------------------------------------------------------------------------*/ | ||
| 302 | |||
| 303 | void CBitmap::mirror_x(std::list<std::string> params) | ||
| 304 | { | ||
| 305 | /* check prerequirements */ | ||
| 306 | if (params.size() != 0) | ||
| 307 | throw FileError("Invalid number of function parameters (must be 0)."); | ||
| 308 | |||
| 309 | /* do nothing if no pixel exists */ | ||
| 310 | if (m_pixeldata == NULL || m_pixelformat == NULL) | ||
| 311 | return; | ||
| 312 | |||
| 313 | /* width and height can be negativ */ | ||
| 314 | uint32_t width = static_cast<uint32_t>(abs(m_infoheader.biWidth)); | ||
| 315 | uint32_t height = static_cast<uint32_t>(abs(m_infoheader.biHeight)); | ||
| 316 | |||
| 317 | /* calc rowsize - boundary is 32 */ | ||
| 318 | uint32_t rowsize = 4 * static_cast<uint32_t>( | ||
| 319 | ((m_pixelformat->getBitCount() * abs(m_infoheader.biWidth)) + 31) / 32 | ||
| 320 | ); | ||
| 321 | |||
| 322 | /* calc pixelwidth */ | ||
| 323 | unsigned int pixelwidth = m_pixelformat->getBitCount()/8; | ||
| 324 | |||
| 325 | uint8_t *buf = new uint8_t[pixelwidth]; | ||
| 326 | for(uint32_t i = 0; i < height; i++) | ||
| 327 | { | ||
| 328 | uint32_t offset = i * rowsize; | ||
| 329 | |||
| 330 | for(uint32_t j = 0; j <= width/2; j++) | ||
| 331 | { | ||
| 332 | uint32_t poffset = offset + j * pixelwidth; | ||
| 333 | uint32_t pbackset = offset + width * pixelwidth - j * pixelwidth; | ||
| 334 | |||
| 335 | /* boundary check */ | ||
| 336 | if (pbackset > m_infoheader.biSizeImage) | ||
| 337 | throw FileError("Mirrored pixel position is out of range."); | ||
| 338 | |||
| 339 | /* mirroring, backup right data first */ | ||
| 340 | copy(m_pixeldata + pbackset - pixelwidth, m_pixeldata + pbackset, buf); | ||
| 341 | copy(m_pixeldata + poffset, m_pixeldata + poffset + pixelwidth, m_pixeldata + pbackset - pixelwidth); | ||
| 342 | copy(buf, buf + pixelwidth, m_pixeldata + poffset); | ||
| 343 | } | ||
| 344 | } | ||
| 345 | delete[] buf; | ||
| 346 | } | ||
| 347 | |||
| 348 | /*----------------------------------------------------------------------------*/ | ||
| 349 | |||
| 350 | #ifdef DEBUG | ||
| 351 | void CBitmap::dump(std::ostream& out) | ||
| 352 | { | ||
| 353 | out | ||
| 354 | << "Bitmap File Header:" << endl | ||
| 355 | << " bfType=" << m_fileheader.bfType[0] << m_fileheader.bfType[1] | ||
| 356 | << ", bfSize=" << m_fileheader.bfSize | ||
| 357 | << ", bfReserved=" << m_fileheader.bfReserved | ||
| 358 | << ", bfOffBits=" << m_fileheader.bfOffBits | ||
| 359 | << endl; | ||
| 360 | |||
| 361 | out | ||
| 362 | << "Bitmap Info Header:" << endl | ||
| 363 | << " biSize=" << m_infoheader.biSize | ||
| 364 | << ", biWidth=" << m_infoheader.biWidth | ||
| 365 | << ", biHeight=" << m_infoheader.biHeight | ||
| 366 | << ", biPlanes=" << m_infoheader.biPlanes | ||
| 367 | << endl | ||
| 368 | |||
| 369 | << " biBitCount=" << m_infoheader.biBitCount | ||
| 370 | << ", biCompression=" << m_infoheader.biCompression | ||
| 371 | << ", biSizeImage=" << m_infoheader.biSizeImage | ||
| 372 | << endl | ||
| 373 | |||
| 374 | << " biXPelsPerMeter=" << m_infoheader.biXPelsPerMeter | ||
| 375 | << ", biYPelsPerMeter=" << m_infoheader.biYPelsPerMeter | ||
| 376 | << ", biClrUsed=" << m_infoheader.biClrUsed | ||
| 377 | << ", biClrImportant=" << m_infoheader.biClrImportant | ||
| 378 | << endl; | ||
| 379 | } | ||
| 380 | #endif | ||
| 381 | |||
| 382 | /* vim: set et sw=2 ts=2: */ | ||
diff --git a/ue2/imgsynth2/cbitmap.h b/ue2/imgsynth2/cbitmap.h new file mode 100644 index 0000000..ca3d6ef --- /dev/null +++ b/ue2/imgsynth2/cbitmap.h | |||
| @@ -0,0 +1,236 @@ | |||
| 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 | |||
| 14 | class 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 | */ | ||
| 27 | class 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: */ | ||
diff --git a/ue2/imgsynth2/cfile.h b/ue2/imgsynth2/cfile.h new file mode 100644 index 0000000..a5c4d2a --- /dev/null +++ b/ue2/imgsynth2/cfile.h | |||
| @@ -0,0 +1,121 @@ | |||
| 1 | /** | ||
| 2 | * @module cfile | ||
| 3 | * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) | ||
| 4 | * @brief Abstract class for handling files. | ||
| 5 | * Needed for generic use in CScriptparser. | ||
| 6 | * @date 17.04.2009 | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef CFILE_H | ||
| 10 | #define CFILE_H | ||
| 11 | |||
| 12 | #include <string> | ||
| 13 | #include <set> | ||
| 14 | #include <list> | ||
| 15 | #include <fstream> | ||
| 16 | #include <stdexcept> | ||
| 17 | |||
| 18 | /** | ||
| 19 | * @class CFile | ||
| 20 | * @brief Abstract class for handling files. Needed for generic use in | ||
| 21 | * CScriptparser. | ||
| 22 | * | ||
| 23 | * In order for CScriptparser to determine which instance of CFile supports | ||
| 24 | * which filetype, every implemententation need to insert their filetypes to | ||
| 25 | * the member m_types in their constructor. | ||
| 26 | * | ||
| 27 | * On error throw FileError. | ||
| 28 | */ | ||
| 29 | class CFile | ||
| 30 | { | ||
| 31 | public: | ||
| 32 | /** | ||
| 33 | * @class FileError | ||
| 34 | * @brief Exception thrown by implemententations of CFile | ||
| 35 | */ | ||
| 36 | class FileError : public std::invalid_argument { | ||
| 37 | public: | ||
| 38 | /** | ||
| 39 | * @method FileError | ||
| 40 | * @brief Default exception ctor | ||
| 41 | * @param what message to pass along | ||
| 42 | * @return - | ||
| 43 | * @globalvars none | ||
| 44 | * @exception none | ||
| 45 | * @conditions none | ||
| 46 | */ | ||
| 47 | FileError(const std::string& what) | ||
| 48 | : std::invalid_argument(what) | ||
| 49 | {} | ||
| 50 | }; | ||
| 51 | |||
| 52 | /** | ||
| 53 | * @method ~CFile | ||
| 54 | * @brief Default dtor (virtual) | ||
| 55 | * @param - | ||
| 56 | * @return - | ||
| 57 | * @globalvars none | ||
| 58 | * @exception none | ||
| 59 | * @conditions none | ||
| 60 | */ | ||
| 61 | virtual ~CFile() | ||
| 62 | {}; | ||
| 63 | |||
| 64 | /** | ||
| 65 | * @method read | ||
| 66 | * @brief Pure virtual method (interface). Should read data from filestream. | ||
| 67 | * @param in filestream to read data from | ||
| 68 | * @return - | ||
| 69 | * @globalvars none | ||
| 70 | * @exception FileError | ||
| 71 | * @conditions none | ||
| 72 | */ | ||
| 73 | virtual void read(std::ifstream& in) = 0; | ||
| 74 | |||
| 75 | /** | ||
| 76 | * @method write | ||
| 77 | * @brief Pure virtual method (interface). Should write data to filestream. | ||
| 78 | * @param out filestream to write data to | ||
| 79 | * @return - | ||
| 80 | * @globalvars none | ||
| 81 | * @exception FileError | ||
| 82 | * @conditions none | ||
| 83 | */ | ||
| 84 | virtual void write(std::ofstream& out) = 0; | ||
| 85 | |||
| 86 | /** | ||
| 87 | * @method callFunc | ||
| 88 | * @brief Pure virtual method (interface). Should delegate the function | ||
| 89 | * and its parameters to the correct internal method. | ||
| 90 | * @param func function name | ||
| 91 | * @param params function parameters as list | ||
| 92 | * @return - | ||
| 93 | * @globalvars none | ||
| 94 | * @exception FileError | ||
| 95 | * @conditions none | ||
| 96 | */ | ||
| 97 | virtual void callFunc(const std::string& func, const std::list<std::string>& params) = 0; | ||
| 98 | |||
| 99 | /** | ||
| 100 | * @method supportsType | ||
| 101 | * @brief Check if filetype is supported by this implementation. | ||
| 102 | * @param type filetype | ||
| 103 | * @return true if filetype is supported. false otherwise | ||
| 104 | * @globalvars none | ||
| 105 | * @exception none | ||
| 106 | * @conditions none | ||
| 107 | */ | ||
| 108 | bool supportsType(const std::string& type) | ||
| 109 | { | ||
| 110 | return (m_types.find(type) == m_types.end()) ? false : true; | ||
| 111 | } | ||
| 112 | |||
| 113 | protected: | ||
| 114 | /* members */ | ||
| 115 | /** set of filetypes suppported by this implementation */ | ||
| 116 | std::set<std::string> m_types; | ||
| 117 | }; | ||
| 118 | |||
| 119 | #endif | ||
| 120 | |||
| 121 | /* vim: set et sw=2 ts=2: */ | ||
diff --git a/ue2/imgsynth2/cpixelformat.h b/ue2/imgsynth2/cpixelformat.h new file mode 100644 index 0000000..49145df --- /dev/null +++ b/ue2/imgsynth2/cpixelformat.h | |||
| @@ -0,0 +1,124 @@ | |||
| 1 | /** | ||
| 2 | * @module cpixelformat | ||
| 3 | * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) | ||
| 4 | * @brief Abstract class for handling different color bitcount of Bitmaps. | ||
| 5 | * Needed for generic use in CBitmap. | ||
| 6 | * @date 18.04.2009 | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef CPIXELFORMAT_H | ||
| 10 | #define CPIXELFORMAT_H | ||
| 11 | |||
| 12 | #include <fstream> | ||
| 13 | #include <stdexcept> | ||
| 14 | |||
| 15 | class CBitmap; | ||
| 16 | #include "cbitmap.h" | ||
| 17 | |||
| 18 | /** | ||
| 19 | * @class CPixelFormat | ||
| 20 | * @brief Abstract class for handling different color bitcount of Bitmaps. | ||
| 21 | * | ||
| 22 | * Needed for generic use in CBitmap. | ||
| 23 | * | ||
| 24 | * On error throw PixelFormatError. | ||
| 25 | */ | ||
| 26 | class CPixelFormat | ||
| 27 | { | ||
| 28 | public: | ||
| 29 | /** | ||
| 30 | * @class PixelFormatError | ||
| 31 | * @brief Exception thrown by implemententations of CPixelFormat | ||
| 32 | */ | ||
| 33 | class PixelFormatError : public std::invalid_argument { | ||
| 34 | public: | ||
| 35 | /** | ||
| 36 | * @method PixelFormatError | ||
| 37 | * @brief Default exception ctor | ||
| 38 | * @param what message to pass along | ||
| 39 | * @return - | ||
| 40 | * @globalvars none | ||
| 41 | * @exception none | ||
| 42 | * @conditions none | ||
| 43 | */ | ||
| 44 | PixelFormatError(const std::string& what) | ||
| 45 | : std::invalid_argument(what) | ||
| 46 | {} | ||
| 47 | }; | ||
| 48 | |||
| 49 | /** | ||
| 50 | * @method CBitmap | ||
| 51 | * @brief Default ctor | ||
| 52 | * @param bitmap pointer to CBitmap instance | ||
| 53 | * @return - | ||
| 54 | * @globalvars none | ||
| 55 | * @exception none | ||
| 56 | * @conditions none | ||
| 57 | */ | ||
| 58 | CPixelFormat(CBitmap *bitmap) | ||
| 59 | : m_bitmap(bitmap) | ||
| 60 | {} | ||
| 61 | |||
| 62 | /** | ||
| 63 | * @method ~CPixelFormat | ||
| 64 | * @brief Default dtor (virtual) | ||
| 65 | * @param - | ||
| 66 | * @return - | ||
| 67 | * @globalvars none | ||
| 68 | * @exception none | ||
| 69 | * @conditions none | ||
| 70 | */ | ||
| 71 | virtual ~CPixelFormat() | ||
| 72 | {}; | ||
| 73 | |||
| 74 | /** | ||
| 75 | * @method setPixel | ||
| 76 | * @brief Modifies pixel at coordinates x, y | ||
| 77 | * @param pixel pointer to new pixel data | ||
| 78 | * @param x x-coordinate | ||
| 79 | * @param y y-coordinate | ||
| 80 | * @return - | ||
| 81 | * @globalvars none | ||
| 82 | * @exception PixelFormatError | ||
| 83 | * @conditions none | ||
| 84 | */ | ||
| 85 | virtual void setPixel(const uint32_t *pixel, const uint32_t x, const uint32_t y) = 0; | ||
| 86 | |||
| 87 | /** | ||
| 88 | * @method getPixel | ||
| 89 | * @brief Get pixel at coordinates x, y | ||
| 90 | * @param pixel pointer to pixel data | ||
| 91 | * @param x x-coordinate | ||
| 92 | * @param y y-coordinate | ||
| 93 | * @return - | ||
| 94 | * @globalvars none | ||
| 95 | * @exception PixelFormatError | ||
| 96 | * @conditions none | ||
| 97 | */ | ||
| 98 | //TODO virtual void getPixel(const uint32_t *pixel, const uint32_t x, const uint32_t y) = 0; | ||
| 99 | |||
| 100 | /** | ||
| 101 | * @method getBitCount | ||
| 102 | * @brief returns color bitcount supported by this class | ||
| 103 | * @param - | ||
| 104 | * @return color bitcount supported by this class | ||
| 105 | * @globalvars none | ||
| 106 | * @exception none | ||
| 107 | * @conditions none | ||
| 108 | */ | ||
| 109 | virtual uint32_t getBitCount() = 0; | ||
| 110 | |||
| 111 | /* | ||
| 112 | * TODO | ||
| 113 | */ | ||
| 114 | virtual void getMaxColor(unsigned int *red, unsigned int *green, unsigned int *blue) = 0; | ||
| 115 | |||
| 116 | protected: | ||
| 117 | /* members */ | ||
| 118 | /** pointer to CBitmap instance */ | ||
| 119 | CBitmap *m_bitmap; | ||
| 120 | }; | ||
| 121 | |||
| 122 | #endif | ||
| 123 | |||
| 124 | /* vim: set et sw=2 ts=2: */ | ||
diff --git a/ue2/imgsynth2/cpixelformat_bgr24.cpp b/ue2/imgsynth2/cpixelformat_bgr24.cpp new file mode 100644 index 0000000..cc02dcc --- /dev/null +++ b/ue2/imgsynth2/cpixelformat_bgr24.cpp | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | /** | ||
| 2 | * @module cpixelformat_BGR24 | ||
| 3 | * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) | ||
| 4 | * @brief Implementation of CPixelFormat handling 24bit color Windows Bitmaps. | ||
| 5 | * @date 18.04.2009 | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include <boost/numeric/conversion/cast.hpp> | ||
| 9 | #include "cpixelformat_bgr24.h" | ||
| 10 | |||
| 11 | using namespace std; | ||
| 12 | |||
| 13 | void CPixelFormat_BGR24::getPixel(uint32_t *pixel, uint32_t x, uint32_t y) | ||
| 14 | { | ||
| 15 | /* | ||
| 16 | * pixel[0] ... red | ||
| 17 | * pixel[1] ... green | ||
| 18 | * pixel[2] ... blue | ||
| 19 | */ | ||
| 20 | if (m_bitmap->getPixelData() == NULL) | ||
| 21 | throw PixelFormatError("No pixelbuffer allocated."); | ||
| 22 | |||
| 23 | /* calc rowsize - boundary is 32 */ | ||
| 24 | uint32_t rowsize = 4 * static_cast<uint32_t>( | ||
| 25 | ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32 | ||
| 26 | ); | ||
| 27 | |||
| 28 | /* if height is positive the y-coordinates are mirrored */ | ||
| 29 | if (m_bitmap->getInfoHeader().biHeight > 0) | ||
| 30 | y = m_bitmap->getInfoHeader().biHeight - y - 1; | ||
| 31 | uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); | ||
| 32 | |||
| 33 | /* boundary check */ | ||
| 34 | if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) | ||
| 35 | throw PixelFormatError("Pixel position is out of range."); | ||
| 36 | |||
| 37 | /* get pixel */ | ||
| 38 | try | ||
| 39 | { | ||
| 40 | pixel[0] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset + 2)); | ||
| 41 | pixel[1] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset + 1)); | ||
| 42 | pixel[2] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset)); | ||
| 43 | } | ||
| 44 | catch(boost::numeric::bad_numeric_cast& ex) | ||
| 45 | { | ||
| 46 | throw PixelFormatError("Unable to convert pixelcolor to correct size: " + string(ex.what())); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | void CPixelFormat_BGR24::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y) | ||
| 51 | { | ||
| 52 | /* | ||
| 53 | * pixel[0] ... red | ||
| 54 | * pixel[1] ... green | ||
| 55 | * pixel[2] ... blue | ||
| 56 | */ | ||
| 57 | if (m_bitmap->getPixelData() == NULL) | ||
| 58 | throw PixelFormatError("No pixelbuffer allocated."); | ||
| 59 | |||
| 60 | /* calc rowsize - boundary is 32 */ | ||
| 61 | uint32_t rowsize = 4 * static_cast<uint32_t>( | ||
| 62 | ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32 | ||
| 63 | ); | ||
| 64 | |||
| 65 | /* if height is positive the y-coordinates are mirrored */ | ||
| 66 | if (m_bitmap->getInfoHeader().biHeight > 0) | ||
| 67 | y = m_bitmap->getInfoHeader().biHeight - y - 1; | ||
| 68 | uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); | ||
| 69 | |||
| 70 | /* boundary check */ | ||
| 71 | if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) | ||
| 72 | throw PixelFormatError("Pixel position is out of range."); | ||
| 73 | |||
| 74 | /* convert color values to correct types */ | ||
| 75 | uint8_t data[3]; | ||
| 76 | try | ||
| 77 | { | ||
| 78 | data[0] = boost::numeric_cast<uint8_t>(pixel[2]); | ||
| 79 | data[1] = boost::numeric_cast<uint8_t>(pixel[1]); | ||
| 80 | data[2] = boost::numeric_cast<uint8_t>(pixel[0]); | ||
| 81 | } | ||
| 82 | catch(boost::numeric::bad_numeric_cast& ex) | ||
| 83 | { | ||
| 84 | throw PixelFormatError("Unable to convert pixelcolor to correct size: " + string(ex.what())); | ||
| 85 | } | ||
| 86 | |||
| 87 | copy(data, data + 3, m_bitmap->getPixelData() + offset); | ||
| 88 | } | ||
| 89 | |||
| 90 | /* vim: set et sw=2 ts=2: */ | ||
diff --git a/ue2/imgsynth2/cpixelformat_bgr24.h b/ue2/imgsynth2/cpixelformat_bgr24.h new file mode 100644 index 0000000..c3e1b72 --- /dev/null +++ b/ue2/imgsynth2/cpixelformat_bgr24.h | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | /** | ||
| 2 | * @module cpixelformat_bgr24 | ||
| 3 | * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) | ||
| 4 | * @brief Implementation of CPixelFormat handling 24bit color Windows Bitmaps. | ||
| 5 | * @date 18.04.2009 | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef CPIXELFORMAT_BGR24_H | ||
| 9 | #define CPIXELFORMAT_BGR24_H | ||
| 10 | |||
| 11 | #include <fstream> | ||
| 12 | #include "cpixelformat.h" | ||
| 13 | |||
| 14 | /** | ||
| 15 | * @class CPixelFormat_BGR24 | ||
| 16 | * @brief Implementation of CPixelFormat handling 24bit color Windows Bitmaps. | ||
| 17 | * | ||
| 18 | * On error CPixelFormat::PixelFormatError is thrown. | ||
| 19 | */ | ||
| 20 | class CPixelFormat_BGR24 : public CPixelFormat | ||
| 21 | { | ||
| 22 | public: | ||
| 23 | /** | ||
| 24 | * @method CPixelFormat_BGR24 | ||
| 25 | * @brief Default ctor | ||
| 26 | * @param bitmap pointer to CBitmap instance | ||
| 27 | * @return - | ||
| 28 | * @globalvars none | ||
| 29 | * @exception none | ||
| 30 | * @conditions none | ||
| 31 | */ | ||
| 32 | CPixelFormat_BGR24(CBitmap *bitmap) | ||
| 33 | : CPixelFormat(bitmap) | ||
| 34 | {} | ||
| 35 | |||
| 36 | /** | ||
| 37 | * @method ~CPixelFormat_BGR24 | ||
| 38 | * @brief Default dtor | ||
| 39 | * @param - | ||
| 40 | * @return - | ||
| 41 | * @globalvars none | ||
| 42 | * @exception none | ||
| 43 | * @conditions none | ||
| 44 | */ | ||
| 45 | ~CPixelFormat_BGR24() | ||
| 46 | {} | ||
| 47 | |||
| 48 | /** | ||
| 49 | * @method setPixel | ||
| 50 | * @brief Modifies pixel at coordinates x, y | ||
| 51 | * @param pixel pointer to new pixel data | ||
| 52 | * @param x x-coordinate | ||
| 53 | * @param y y-coordinate | ||
| 54 | * @return - | ||
| 55 | * @globalvars none | ||
| 56 | * @exception PixelFormatError | ||
| 57 | * @conditions none | ||
| 58 | */ | ||
| 59 | void setPixel(const uint32_t *pixel, uint32_t x, uint32_t y); | ||
| 60 | |||
| 61 | /* TODO */ | ||
| 62 | void getPixel(uint32_t *pixel, uint32_t x, uint32_t y); | ||
| 63 | |||
| 64 | /** | ||
| 65 | * @method getBitCount | ||
| 66 | * @brief returns color bitcount supported by this class | ||
| 67 | * @param - | ||
| 68 | * @return color bitcount supported by this class | ||
| 69 | * @globalvars none | ||
| 70 | * @exception none | ||
| 71 | * @conditions none | ||
| 72 | */ | ||
| 73 | uint32_t getBitCount() | ||
| 74 | { | ||
| 75 | return 24; | ||
| 76 | } | ||
| 77 | |||
| 78 | /* | ||
| 79 | * TODO | ||
| 80 | */ | ||
| 81 | void getMaxColor(unsigned int *red, unsigned int *green, unsigned int *blue) | ||
| 82 | { | ||
| 83 | *red = *green = *blue = 255; /* 2^8 - 1 */ | ||
| 84 | } | ||
| 85 | }; | ||
| 86 | |||
| 87 | #endif | ||
| 88 | |||
| 89 | /* vim: set et sw=2 ts=2: */ | ||
diff --git a/ue2/imgsynth2/cpixelformat_bgr555.cpp b/ue2/imgsynth2/cpixelformat_bgr555.cpp new file mode 100644 index 0000000..4a3c833 --- /dev/null +++ b/ue2/imgsynth2/cpixelformat_bgr555.cpp | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | /** | ||
| 2 | * @module cpixelformat_BGR555 | ||
| 3 | * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) | ||
| 4 | * @brief Implementation of CPixelFormat handling BGR555 color (real color) | ||
| 5 | * Windows Bitmaps. | ||
| 6 | * @date 18.04.2009 | ||
| 7 | */ | ||
| 8 | |||
| 9 | #include <boost/numeric/conversion/cast.hpp> | ||
| 10 | #include "cpixelformat_bgr555.h" | ||
| 11 | |||
| 12 | using namespace std; | ||
| 13 | |||
| 14 | void CPixelFormat_BGR555::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y) | ||
| 15 | { | ||
| 16 | /* | ||
| 17 | * pixel[0] ... red | ||
| 18 | * pixel[1] ... green | ||
| 19 | * pixel[2] ... blue | ||
| 20 | */ | ||
| 21 | |||
| 22 | if (m_bitmap->getPixelData() == NULL) | ||
| 23 | throw PixelFormatError("No pixelbuffer allocated."); | ||
| 24 | |||
| 25 | /* calc rowsize - boundary is 32 */ | ||
| 26 | uint32_t rowsize = 4 * static_cast<uint32_t>( | ||
| 27 | ((CPixelFormat_BGR555::getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32 | ||
| 28 | ); | ||
| 29 | |||
| 30 | /* if height is positive the y-coordinates are mirrored */ | ||
| 31 | if (m_bitmap->getInfoHeader().biHeight > 0) | ||
| 32 | y = m_bitmap->getInfoHeader().biHeight - y - 1; | ||
| 33 | uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); | ||
| 34 | |||
| 35 | /* boundary check */ | ||
| 36 | if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) | ||
| 37 | throw PixelFormatError("Pixel position is out of range."); | ||
| 38 | |||
| 39 | /* convert color values to correct types */ | ||
| 40 | uint8_t *o = m_bitmap->getPixelData() + offset; | ||
| 41 | *(uint16_t *)o = (uint16_t)(((pixel[2] << BGR555_BLUE_SHIFT) & BGR555_BLUE_MASK) | | ||
| 42 | ((pixel[1] << BGR555_GREEN_SHIFT) & BGR555_GREEN_MASK) | | ||
| 43 | ((pixel[0] << BGR555_RED_SHIFT) & BGR555_RED_MASK)); | ||
| 44 | } | ||
| 45 | |||
| 46 | /* vim: set et sw=2 ts=2: */ | ||
diff --git a/ue2/imgsynth2/cpixelformat_bgr555.h b/ue2/imgsynth2/cpixelformat_bgr555.h new file mode 100644 index 0000000..7a49c7c --- /dev/null +++ b/ue2/imgsynth2/cpixelformat_bgr555.h | |||
| @@ -0,0 +1,96 @@ | |||
| 1 | /** | ||
| 2 | * @module cpixelformat_bgr555 | ||
| 3 | * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) | ||
| 4 | * @brief Implementation of CPixelFormat handling BGR555 color (real color) | ||
| 5 | * Windows Bitmaps. | ||
| 6 | * @date 26.04.2009 | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef CPIXELFORMAT_BGR555_H | ||
| 10 | #define CPIXELFORMAT_BGR555_H | ||
| 11 | |||
| 12 | #include <fstream> | ||
| 13 | #include "cpixelformat.h" | ||
| 14 | |||
| 15 | /* TODO */ | ||
| 16 | #define BGR555_RED_SHIFT 10 | ||
| 17 | #define BGR555_GREEN_SHIFT 5 | ||
| 18 | #define BGR555_BLUE_SHIFT 0 | ||
| 19 | #define BGR555_RED_MASK 0x7C00 | ||
| 20 | #define BGR555_GREEN_MASK 0x03E0 | ||
| 21 | #define BGR555_BLUE_MASK 0x001F | ||
| 22 | |||
| 23 | /** | ||
| 24 | * @class CPixelFormat_BGR555 | ||
| 25 | * @brief Implementation of CPixelFormat handling BGR555 color (real color) | ||
| 26 | * Windows Bitmaps. | ||
| 27 | * | ||
| 28 | * On error CPixelFormat::PixelFormatError is thrown. | ||
| 29 | */ | ||
| 30 | class CPixelFormat_BGR555 : public CPixelFormat | ||
| 31 | { | ||
| 32 | public: | ||
| 33 | /** | ||
| 34 | * @method CPixelFormat_BGR55 | ||
| 35 | * @brief Default ctor | ||
| 36 | * @param bitmap pointer to CBitmap instance | ||
| 37 | * @return - | ||
| 38 | * @globalvars none | ||
| 39 | * @exception none | ||
| 40 | * @conditions none | ||
| 41 | */ | ||
| 42 | CPixelFormat_BGR555(CBitmap *bitmap) | ||
| 43 | : CPixelFormat(bitmap) | ||
| 44 | {} | ||
| 45 | |||
| 46 | /** | ||
| 47 | * @method ~CPixelFormat_BGR555 | ||
| 48 | * @brief Default dtor | ||
| 49 | * @param - | ||
| 50 | * @return - | ||
| 51 | * @globalvars none | ||
| 52 | * @exception none | ||
| 53 | * @conditions none | ||
| 54 | */ | ||
| 55 | ~CPixelFormat_BGR555() | ||
| 56 | {} | ||
| 57 | |||
| 58 | /** | ||
| 59 | * @method setPixel | ||
| 60 | * @brief Modifies pixel at coordinates x, y | ||
| 61 | * @param pixel pointer to new pixel data | ||
| 62 | * @param x x-coordinate | ||
| 63 | * @param y y-coordinate | ||
| 64 | * @return - | ||
| 65 | * @globalvars none | ||
| 66 | * @exception PixelFormatError | ||
| 67 | * @conditions none | ||
| 68 | */ | ||
| 69 | void setPixel(const uint32_t *pixel, uint32_t x, uint32_t y); | ||
| 70 | |||
| 71 | /** | ||
| 72 | * @method getBitCount | ||
| 73 | * @brief returns color bitcount supported by this class | ||
| 74 | * @param - | ||
| 75 | * @return color bitcount supported by this class | ||
| 76 | * @globalvars none | ||
| 77 | * @exception none | ||
| 78 | * @conditions none | ||
| 79 | */ | ||
| 80 | uint32_t getBitCount() | ||
| 81 | { | ||
| 82 | return 16; | ||
| 83 | } | ||
| 84 | |||
| 85 | /* | ||
| 86 | * TODO | ||
| 87 | */ | ||
| 88 | void getMaxColor(unsigned int *red, unsigned int *green, unsigned int *blue) | ||
| 89 | { | ||
| 90 | *red = *green = *blue = 31; /* 2^5 -1 */ | ||
| 91 | } | ||
| 92 | }; | ||
| 93 | |||
| 94 | #endif | ||
| 95 | |||
| 96 | /* vim: set et sw=2 ts=2: */ | ||
diff --git a/ue2/imgsynth2/cscriptparser.cpp b/ue2/imgsynth2/cscriptparser.cpp new file mode 100644 index 0000000..df3df1e --- /dev/null +++ b/ue2/imgsynth2/cscriptparser.cpp | |||
| @@ -0,0 +1,209 @@ | |||
| 1 | /** | ||
| 2 | * @module cscriptparser | ||
| 3 | * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) | ||
| 4 | * @brief class for parsing simple scriptfiles | ||
| 5 | * @date 17.04.2009 | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include <fstream> | ||
| 9 | #include <boost/tokenizer.hpp> | ||
| 10 | #include <boost/algorithm/string.hpp> | ||
| 11 | #include "cscriptparser.h" | ||
| 12 | #include "cbitmap.h" | ||
| 13 | |||
| 14 | using namespace std; | ||
| 15 | using namespace boost; | ||
| 16 | |||
| 17 | CScriptparser::CScriptparser(const std::string& scriptfile) | ||
| 18 | : m_scriptfile(scriptfile), m_handler(NULL) | ||
| 19 | { | ||
| 20 | /* add our handlers */ | ||
| 21 | m_handlers.insert(new CBitmap); | ||
| 22 | } | ||
| 23 | |||
| 24 | /*----------------------------------------------------------------------------*/ | ||
| 25 | |||
| 26 | CScriptparser::~CScriptparser() | ||
| 27 | { | ||
| 28 | /* delete image handlers */ | ||
| 29 | set<CFile *>::iterator it; | ||
| 30 | for (it = m_handlers.begin(); it != m_handlers.end(); it++) | ||
| 31 | delete *it; | ||
| 32 | m_handler = NULL; | ||
| 33 | } | ||
| 34 | |||
| 35 | /*----------------------------------------------------------------------------*/ | ||
| 36 | |||
| 37 | void CScriptparser::parse() | ||
| 38 | { | ||
| 39 | /* open and read file */ | ||
| 40 | ifstream file(m_scriptfile.c_str(), ios::in); | ||
| 41 | if (!file) | ||
| 42 | throw ParserError("Unable to open scriptfile '" + m_scriptfile + "'."); | ||
| 43 | |||
| 44 | while (!file.eof() && file.good()) | ||
| 45 | { | ||
| 46 | /* read file pre line */ | ||
| 47 | getline(file, m_curline); | ||
| 48 | if (m_curline.empty()) | ||
| 49 | continue; | ||
| 50 | |||
| 51 | trim(m_curline); | ||
| 52 | |||
| 53 | /* ignore comments */ | ||
| 54 | if (m_curline.find_first_of('#') == 0) | ||
| 55 | continue; | ||
| 56 | |||
| 57 | /* line has no function call */ | ||
| 58 | size_t pos1 = m_curline.find_first_of('('); | ||
| 59 | size_t pos2 = m_curline.find_last_of(')'); | ||
| 60 | if (pos1 == string::npos || pos2 == string::npos) | ||
| 61 | throw ParserError("Invalid syntax. Not a function", m_curline); | ||
| 62 | |||
| 63 | /* first parse function name and tokenize all parameters */ | ||
| 64 | string func = m_curline.substr(0, pos1); | ||
| 65 | string params = m_curline.substr(pos1 + 1, pos2 - pos1 - 1); | ||
| 66 | list<string> funcparams; | ||
| 67 | tokenizer< char_separator<char> > tokens(params, char_separator<char>(",")); | ||
| 68 | /* BOOST_FOREACH isn't available on OOP-servers... */ | ||
| 69 | for (tokenizer< char_separator<char> >::iterator it = tokens.begin(); | ||
| 70 | it != tokens.end(); | ||
| 71 | it++) | ||
| 72 | { | ||
| 73 | string tok(*it); | ||
| 74 | trim(tok); | ||
| 75 | if (tok.find_first_of(' ') != string::npos) | ||
| 76 | { | ||
| 77 | if (tok.find_first_of('"') == string::npos) | ||
| 78 | throw ParserError("Invalid syntax", m_curline); | ||
| 79 | } | ||
| 80 | trim_if(tok, is_any_of("\"")); | ||
| 81 | funcparams.push_back(tok); | ||
| 82 | } | ||
| 83 | |||
| 84 | /* then call the corresponding function */ | ||
| 85 | callFunc(func, funcparams); | ||
| 86 | } | ||
| 87 | |||
| 88 | file.close(); | ||
| 89 | } | ||
| 90 | |||
| 91 | /*----------------------------------------------------------------------------*/ | ||
| 92 | |||
| 93 | void CScriptparser::callFunc(const std::string& func, const std::list<std::string>& funcparams) | ||
| 94 | { | ||
| 95 | if (func.empty()) | ||
| 96 | throw ParserError("Function name is empty.", m_curline); | ||
| 97 | |||
| 98 | if (func == "read") | ||
| 99 | read(funcparams); | ||
| 100 | else if (func == "write") | ||
| 101 | write(funcparams); | ||
| 102 | else | ||
| 103 | { | ||
| 104 | if (m_handler == NULL) | ||
| 105 | throw ParserError("No image is being processed.", m_curline); | ||
| 106 | |||
| 107 | /* call function from handler */ | ||
| 108 | try | ||
| 109 | { | ||
| 110 | m_handler->callFunc(func, funcparams); | ||
| 111 | } | ||
| 112 | catch(CFile::FileError& ex) | ||
| 113 | { | ||
| 114 | throw ParserError(ex.what(), m_curline); | ||
| 115 | } | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 119 | /*----------------------------------------------------------------------------*/ | ||
| 120 | |||
| 121 | void CScriptparser::read(std::list<std::string> funcparams) | ||
| 122 | { | ||
| 123 | /* check prerequirements */ | ||
| 124 | if (funcparams.size() != 2) | ||
| 125 | throw ParserError("Invalid number of function parameters (must be 2).", m_curline); | ||
| 126 | if (m_handler != NULL) | ||
| 127 | throw ParserError("An image is already being processed. Unable to open another.", m_curline); | ||
| 128 | |||
| 129 | string type = funcparams.front(); | ||
| 130 | to_upper(type); | ||
| 131 | funcparams.pop_front(); | ||
| 132 | string filename = funcparams.front(); | ||
| 133 | |||
| 134 | /* fetch image handler supporting requested filetype */ | ||
| 135 | m_handler = NULL; | ||
| 136 | set<CFile *>::iterator it; | ||
| 137 | for (it = m_handlers.begin(); it != m_handlers.end(); it++) | ||
| 138 | { | ||
| 139 | if ((*it)->supportsType(type)) | ||
| 140 | { | ||
| 141 | m_handler = *it; | ||
| 142 | break; | ||
| 143 | } | ||
| 144 | } | ||
| 145 | if (m_handler == NULL) | ||
| 146 | throw ParserError("Unknown filetype.", m_curline); | ||
| 147 | |||
| 148 | /* open file in binary mode */ | ||
| 149 | ifstream file(filename.c_str(), ios::in | ios::binary); | ||
| 150 | if (!file) | ||
| 151 | throw ParserError("Unable to read file.", m_curline); | ||
| 152 | |||
| 153 | /* let handlers read() parse the file */ | ||
| 154 | try | ||
| 155 | { | ||
| 156 | m_handler->read(file); | ||
| 157 | if (!file.good()) | ||
| 158 | throw ParserError("Error while reading image file.", m_curline); | ||
| 159 | file.close(); | ||
| 160 | } | ||
| 161 | catch(CFile::FileError& ex) | ||
| 162 | { | ||
| 163 | file.close(); | ||
| 164 | throw ParserError(ex.what(), m_curline); | ||
| 165 | } | ||
| 166 | } | ||
| 167 | |||
| 168 | /*----------------------------------------------------------------------------*/ | ||
| 169 | |||
| 170 | void CScriptparser::write(std::list<std::string> funcparams) | ||
| 171 | { | ||
| 172 | /* check prerequirements */ | ||
| 173 | if (funcparams.size() != 2) | ||
| 174 | throw ParserError("Invalid number of function parameters (must be 2).", m_curline); | ||
| 175 | if (m_handler == NULL) | ||
| 176 | throw ParserError("No image is being processed.", m_curline); | ||
| 177 | |||
| 178 | string type = funcparams.front(); | ||
| 179 | to_upper(type); | ||
| 180 | funcparams.pop_front(); | ||
| 181 | string filename = funcparams.front(); | ||
| 182 | |||
| 183 | /* do we have an image handler supporting the filetype? */ | ||
| 184 | if (!m_handler->supportsType(type)) | ||
| 185 | throw ParserError("Unknown filetype.", m_curline); | ||
| 186 | |||
| 187 | /* open file in binary mode */ | ||
| 188 | ofstream file(filename.c_str(), ios::out | ios::binary); | ||
| 189 | if (!file) | ||
| 190 | throw ParserError("Unable to open file.", m_curline); | ||
| 191 | |||
| 192 | /* let handlers write() parse the file */ | ||
| 193 | try | ||
| 194 | { | ||
| 195 | m_handler->write(file); | ||
| 196 | if (!file.good()) | ||
| 197 | throw ParserError("Error while writing image file.", m_curline); | ||
| 198 | file.close(); | ||
| 199 | m_handler = NULL; | ||
| 200 | } | ||
| 201 | catch(CFile::FileError& ex) | ||
| 202 | { | ||
| 203 | file.close(); | ||
| 204 | m_handler = NULL; | ||
| 205 | throw ParserError(ex.what(), m_curline); | ||
| 206 | } | ||
| 207 | } | ||
| 208 | |||
| 209 | /* vim: set et sw=2 ts=2: */ | ||
diff --git a/ue2/imgsynth2/cscriptparser.h b/ue2/imgsynth2/cscriptparser.h new file mode 100644 index 0000000..d4ebd0e --- /dev/null +++ b/ue2/imgsynth2/cscriptparser.h | |||
| @@ -0,0 +1,181 @@ | |||
| 1 | /** | ||
| 2 | * @module cscriptparser | ||
| 3 | * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) | ||
| 4 | * @brief class for parsing simple scriptfiles | ||
| 5 | * @date 17.04.2009 | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef CSCRIPTPARSER_H | ||
| 9 | #define CSCRIPTPARSER_H | ||
| 10 | |||
| 11 | #include <stdexcept> | ||
| 12 | #include <string> | ||
| 13 | #include <list> | ||
| 14 | #include <set> | ||
| 15 | #include "cfile.h" | ||
| 16 | |||
| 17 | /** | ||
| 18 | * @class CScriptparser | ||
| 19 | * | ||
| 20 | * Parses a simple line based scriptfile with some limitations: | ||
| 21 | * first function (starting a block) must be a read-command, | ||
| 22 | * last must be a write-command (ending this block). | ||
| 23 | * | ||
| 24 | * read- and write-commands have hard coded parameters, number#1 being a filetype. | ||
| 25 | * Classes handling certain filetypes must be of type CFile. | ||
| 26 | * Custom functions will be passed to CFile::callFunc(). | ||
| 27 | * | ||
| 28 | * On error ParserError will be thrown. | ||
| 29 | */ | ||
| 30 | class CScriptparser | ||
| 31 | { | ||
| 32 | public: | ||
| 33 | /** | ||
| 34 | * @class ParserError | ||
| 35 | * @brief Exception thrown by CScriptparser | ||
| 36 | */ | ||
| 37 | class ParserError : public std::invalid_argument { | ||
| 38 | public: | ||
| 39 | /** | ||
| 40 | * @method ParserError | ||
| 41 | * @brief Default exception ctor | ||
| 42 | * @param what message to pass along | ||
| 43 | * @return - | ||
| 44 | * @globalvars none | ||
| 45 | * @exception none | ||
| 46 | * @conditions none | ||
| 47 | */ | ||
| 48 | ParserError(const std::string& what) | ||
| 49 | : std::invalid_argument(what), m_line("") | ||
| 50 | {} | ||
| 51 | |||
| 52 | /** | ||
| 53 | * @method ParserError | ||
| 54 | * @brief Custom exception ctor | ||
| 55 | * @param what message to pass along | ||
| 56 | * @param line scriptline which is currently being parsed | ||
| 57 | * @return - | ||
| 58 | * @globalvars none | ||
| 59 | * @exception none | ||
| 60 | * @conditions none | ||
| 61 | */ | ||
| 62 | ParserError(const std::string& what, const std::string& line) | ||
| 63 | : std::invalid_argument(what), m_line(line) | ||
| 64 | {} | ||
| 65 | |||
| 66 | /** | ||
| 67 | * @method ~ParserError | ||
| 68 | * @brief Default dtor | ||
| 69 | * @param - | ||
| 70 | * @return - | ||
| 71 | * @globalvars none | ||
| 72 | * @exception not allowed | ||
| 73 | * @conditions none | ||
| 74 | */ | ||
| 75 | ~ParserError() throw() | ||
| 76 | {} | ||
| 77 | |||
| 78 | /** | ||
| 79 | * @method getLine | ||
| 80 | * @brief returns reference to currently parsed scriptline (if set) | ||
| 81 | * @return reference to currently parsed scriptline (maybe empty string) | ||
| 82 | * @globalvars none | ||
| 83 | * @exception none | ||
| 84 | * @conditions none | ||
| 85 | */ | ||
| 86 | const std::string &getLine() | ||
| 87 | { | ||
| 88 | return m_line; | ||
| 89 | } | ||
| 90 | |||
| 91 | private: | ||
| 92 | /* members*/ | ||
| 93 | std::string m_line; | ||
| 94 | }; | ||
| 95 | |||
| 96 | /** | ||
| 97 | * @method CScriptparser | ||
| 98 | * @brief Default ctor | ||
| 99 | * @param scriptfile filename of script to parse | ||
| 100 | * @return - | ||
| 101 | * @globalvars none | ||
| 102 | * @exception bad_alloc | ||
| 103 | * @conditions none | ||
| 104 | */ | ||
| 105 | CScriptparser(const std::string& scriptfile); | ||
| 106 | |||
| 107 | /** | ||
| 108 | * @method ~CScriptparser | ||
| 109 | * @brief Default dtor | ||
| 110 | * @param - | ||
| 111 | * @return - | ||
| 112 | * @globalvars none | ||
| 113 | * @exception none | ||
| 114 | * @conditions none | ||
| 115 | */ | ||
| 116 | ~CScriptparser(); | ||
| 117 | |||
| 118 | /** | ||
| 119 | * @method parse | ||
| 120 | * @brief Start parsing the scriptfile | ||
| 121 | * @param - | ||
| 122 | * @return - | ||
| 123 | * @globalvars none | ||
| 124 | * @exception ParserError | ||
| 125 | * @conditions none | ||
| 126 | */ | ||
| 127 | void parse(); | ||
| 128 | |||
| 129 | protected: | ||
| 130 | /** | ||
| 131 | * @method callFunc | ||
| 132 | * @brief Delegates the function and its parameters to the correct | ||
| 133 | * method (internal or handler) | ||
| 134 | * @param func function name | ||
| 135 | * @param funcparams function parameters as list | ||
| 136 | * @return - | ||
| 137 | * @globalvars none | ||
| 138 | * @exception ParserError | ||
| 139 | * @conditions none | ||
| 140 | */ | ||
| 141 | void callFunc(const std::string& func, const std::list<std::string>& funcparams); | ||
| 142 | |||
| 143 | /** | ||
| 144 | * @method read | ||
| 145 | * @brief Handles/wrappes read-command. according to the filetype the | ||
| 146 | * read-method of the corresponding handler will be called inside. | ||
| 147 | * @param funcparams function parameters as list | ||
| 148 | * @return - | ||
| 149 | * @globalvars none | ||
| 150 | * @exception ParserError | ||
| 151 | * @conditions none | ||
| 152 | * | ||
| 153 | * Scriptfile syntax: read(<FILETYPE>, <FILENAME>) | ||
| 154 | */ | ||
| 155 | void read(std::list<std::string> funcparams); | ||
| 156 | |||
| 157 | /** | ||
| 158 | * @method write | ||
| 159 | * @brief Handles/wrappes write-command. according to the filetype the | ||
| 160 | * write-method of the corresponding handler will be called inside. | ||
| 161 | * @param funcparams function parameters as list | ||
| 162 | * @return - | ||
| 163 | * @globalvars none | ||
| 164 | * @exception ParserError | ||
| 165 | * @conditions none | ||
| 166 | * | ||
| 167 | * Scriptfile syntax: write(<FILETYPE>, <FILENAME>) | ||
| 168 | */ | ||
| 169 | void write(std::list<std::string> funcparams); | ||
| 170 | |||
| 171 | private: | ||
| 172 | /* members */ | ||
| 173 | std::set<CFile *> m_handlers; | ||
| 174 | std::string m_scriptfile; | ||
| 175 | std::string m_curline; | ||
| 176 | CFile *m_handler; | ||
| 177 | }; | ||
| 178 | |||
| 179 | #endif | ||
| 180 | |||
| 181 | /* vim: set et sw=2 ts=2: */ | ||
diff --git a/ue2/imgsynth2/imgsynth2.cpp b/ue2/imgsynth2/imgsynth2.cpp new file mode 100644 index 0000000..135d31f --- /dev/null +++ b/ue2/imgsynth2/imgsynth2.cpp | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | /** | ||
| 2 | * @module imgsynth2 | ||
| 3 | * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) | ||
| 4 | * @brief imgsynth2 reads a scriptfile given as commandline option | ||
| 5 | * and executes all known function inside. | ||
| 6 | * On error (e.g. unknown function) the program will terminate | ||
| 7 | * @date 17.04.2009 | ||
| 8 | * @par Exercise | ||
| 9 | * 2 | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <iostream> | ||
| 13 | #include <boost/program_options.hpp> | ||
| 14 | #include "cscriptparser.h" | ||
| 15 | |||
| 16 | using namespace std; | ||
| 17 | namespace po = boost::program_options; | ||
| 18 | |||
| 19 | /** | ||
| 20 | * @func main | ||
| 21 | * @brief program entry point | ||
| 22 | * @param argc standard parameter of main | ||
| 23 | * @param argv standard parameter of main | ||
| 24 | * @return 0 on success, not 0 otherwise | ||
| 25 | * @globalvars none | ||
| 26 | * @exception none | ||
| 27 | * @conditions none | ||
| 28 | * | ||
| 29 | * setup commandline options, parse them and pass scriptfile to scriptparser | ||
| 30 | * instance. On error print error message to stderr. | ||
| 31 | * Unknown commandline options will print a usage message. | ||
| 32 | */ | ||
| 33 | int main(int argc, char* argv[]) | ||
| 34 | { | ||
| 35 | string me(argv[0]); | ||
| 36 | |||
| 37 | /* define commandline options */ | ||
| 38 | po::options_description desc("Allowed options"); | ||
| 39 | desc.add_options() | ||
| 40 | ("help,h", "this help message") | ||
| 41 | ("input,i", po::value<string>(), "input scriptfile"); | ||
| 42 | |||
| 43 | /* parse commandline options */ | ||
| 44 | po::variables_map vm; | ||
| 45 | try | ||
| 46 | { | ||
| 47 | po::store(po::parse_command_line(argc, argv, desc), vm); | ||
| 48 | po::notify(vm); | ||
| 49 | } | ||
| 50 | catch(po::error& ex) | ||
| 51 | { | ||
| 52 | cerr << "Error: " << ex.what() << endl; | ||
| 53 | } | ||
| 54 | |||
| 55 | /* print usage upon request or missing params */ | ||
| 56 | if (vm.count("help") || !vm.count("input")) | ||
| 57 | { | ||
| 58 | cout << "Usage: " << me << " -i <scriptfile>" << endl; | ||
| 59 | cout << desc << endl; | ||
| 60 | return 0; | ||
| 61 | } | ||
| 62 | |||
| 63 | CScriptparser parser(vm["input"].as<string>()); | ||
| 64 | try | ||
| 65 | { | ||
| 66 | parser.parse(); | ||
| 67 | } | ||
| 68 | catch(CScriptparser::ParserError& ex) | ||
| 69 | { | ||
| 70 | cerr << me << ": Error while processing scriptfile: " << ex.what() << endl; | ||
| 71 | if (!ex.getLine().empty()) | ||
| 72 | cerr << "Scriptline: '" << ex.getLine() << "'" << endl; | ||
| 73 | return 1; | ||
| 74 | } | ||
| 75 | catch(exception& ex) | ||
| 76 | { | ||
| 77 | cerr << me << ": Unexpected exception: " << ex.what() << endl; | ||
| 78 | return 1; | ||
| 79 | } | ||
| 80 | |||
| 81 | return 0; | ||
| 82 | } | ||
| 83 | |||
| 84 | /* vim: set et sw=2 ts=2: */ | ||
diff --git a/ue2/imgsynth2/test/input_yellow_man1_rgb24 b/ue2/imgsynth2/test/input_yellow_man1_rgb24 new file mode 100644 index 0000000..ce2743b --- /dev/null +++ b/ue2/imgsynth2/test/input_yellow_man1_rgb24 | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | #in: test/yellow_man1_rgb24_in.bmp | ||
| 2 | #out: test/yellow_man1_rgb24_out.bmp | ||
| 3 | #ref: test/yellow_man1_rgb24_ref.bmp | ||
| 4 | |||
| 5 | read(BMP, test/yellow_man1_rgb24_in.bmp) | ||
| 6 | |||
| 7 | fillrect(0,3,6,5,0,255,0) | ||
| 8 | fillrect(2,13,7,4,0,0,255) | ||
| 9 | |||
| 10 | write(BMP, "test/yellow_man1_rgb24_out.bmp") | ||
diff --git a/ue2/imgsynth2/test/input_yellow_man1_rgb555 b/ue2/imgsynth2/test/input_yellow_man1_rgb555 new file mode 100644 index 0000000..1723489 --- /dev/null +++ b/ue2/imgsynth2/test/input_yellow_man1_rgb555 | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | #in: test/yellow_man1_rgb555_in.bmp | ||
| 2 | #out: test/yellow_man1_rgb555_out.bmp | ||
| 3 | #ref: test/yellow_man1_rgb555_ref.bmp | ||
| 4 | |||
| 5 | read(BMP, test/yellow_man1_rgb555_in.bmp) | ||
| 6 | |||
| 7 | fillrect(0,3,6,5,0,31,0) | ||
| 8 | fillrect(2,13,7,4,0,0,31) | ||
| 9 | |||
| 10 | write(BMP, "test/yellow_man1_rgb555_out.bmp") | ||
diff --git a/ue2/imgsynth2/test/input_yellow_man2_rgb24 b/ue2/imgsynth2/test/input_yellow_man2_rgb24 new file mode 100644 index 0000000..37108b8 --- /dev/null +++ b/ue2/imgsynth2/test/input_yellow_man2_rgb24 | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | #in: test/yellow_man2_rgb24_in.bmp | ||
| 2 | #out: test/yellow_man2_rgb24_out.bmp | ||
| 3 | #ref: test/yellow_man2_rgb24_ref.bmp | ||
| 4 | |||
| 5 | read(BMP, test/yellow_man2_rgb24_in.bmp) | ||
| 6 | |||
| 7 | fillrect(0,3,6,5,0,255,0) | ||
| 8 | fillrect(2,13,6,4,0,0,255) | ||
| 9 | mirror_x() | ||
| 10 | mirror_y() | ||
| 11 | #invert() | ||
| 12 | |||
| 13 | write(BMP, "test/yellow_man2_rgb24_out.bmp") | ||
diff --git a/ue2/imgsynth2/test/input_yellow_man2_rgb555 b/ue2/imgsynth2/test/input_yellow_man2_rgb555 new file mode 100644 index 0000000..3c00301 --- /dev/null +++ b/ue2/imgsynth2/test/input_yellow_man2_rgb555 | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | #in: test/yellow_man2_rgb555_in.bmp | ||
| 2 | #out: test/yellow_man2_rgb555_out.bmp | ||
| 3 | #ref: test/yellow_man2_rgb555_ref.bmp | ||
| 4 | |||
| 5 | read(BMP, test/yellow_man2_rgb555_in.bmp) | ||
| 6 | |||
| 7 | fillrect(0,3,6,5,0,24,0) | ||
| 8 | fillrect(2,13,7,4,0,0,24) | ||
| 9 | mirror_x() | ||
| 10 | mirror_y() | ||
| 11 | #invert() | ||
| 12 | |||
| 13 | write(BMP, "test/yellow_man2_rgb555_out.bmp") | ||
diff --git a/ue2/imgsynth2/test/test.sh b/ue2/imgsynth2/test/test.sh new file mode 100755 index 0000000..5d760b9 --- /dev/null +++ b/ue2/imgsynth2/test/test.sh | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | inputs=( $(ls test/input_* | sort -n) ) | ||
| 4 | |||
| 5 | for input in ${inputs[@]} | ||
| 6 | do | ||
| 7 | echo "Testing $input ..." | ||
| 8 | |||
| 9 | files=() | ||
| 10 | for tag in "#in: " "#out: " "#ref: " | ||
| 11 | do | ||
| 12 | tmp=$(grep "$tag" "$input") | ||
| 13 | if [ -z "$tmp" ] | ||
| 14 | then | ||
| 15 | echo " ERROR: Tag '$tag' missing" | ||
| 16 | exit 1 | ||
| 17 | fi | ||
| 18 | |||
| 19 | tmp=${tmp:${#tag}} | ||
| 20 | #if [ ! -e "$tmp" ] | ||
| 21 | #then | ||
| 22 | # echo " ERROR: File '$tmp' doesn't exist" | ||
| 23 | # exit 1 | ||
| 24 | #fi | ||
| 25 | |||
| 26 | files+=("$tmp") | ||
| 27 | done | ||
| 28 | |||
| 29 | rm -f "${files[1]}" | ||
| 30 | ./imgsynth2 -i "$input" | ||
| 31 | ret=$? | ||
| 32 | if [ $ret -ne 0 ] | ||
| 33 | then | ||
| 34 | echo " ERROR: Script didn't exit properly" | ||
| 35 | exit 1 | ||
| 36 | fi | ||
| 37 | |||
| 38 | md5_1=$(md5sum < "${files[1]}") | ||
| 39 | md5_2=$(md5sum < "${files[2]}") | ||
| 40 | if [ "$md5_1" != "$md5_2" ] | ||
| 41 | then | ||
| 42 | echo " ERROR: ${files[1]} and ${files[2]} differ" | ||
| 43 | exit 1 | ||
| 44 | else | ||
| 45 | echo " Test successful" | ||
| 46 | fi | ||
| 47 | done | ||
| 48 | |||
diff --git a/ue2/imgsynth2/test/yellow_man1_rgb24_in.bmp b/ue2/imgsynth2/test/yellow_man1_rgb24_in.bmp new file mode 100644 index 0000000..49372b2 --- /dev/null +++ b/ue2/imgsynth2/test/yellow_man1_rgb24_in.bmp | |||
| Binary files differ | |||
diff --git a/ue2/imgsynth2/test/yellow_man1_rgb24_out.bmp b/ue2/imgsynth2/test/yellow_man1_rgb24_out.bmp new file mode 100644 index 0000000..340eab9 --- /dev/null +++ b/ue2/imgsynth2/test/yellow_man1_rgb24_out.bmp | |||
| Binary files differ | |||
diff --git a/ue2/imgsynth2/test/yellow_man1_rgb24_ref.bmp b/ue2/imgsynth2/test/yellow_man1_rgb24_ref.bmp new file mode 100644 index 0000000..340eab9 --- /dev/null +++ b/ue2/imgsynth2/test/yellow_man1_rgb24_ref.bmp | |||
| Binary files differ | |||
diff --git a/ue2/imgsynth2/test/yellow_man1_rgb555_in.bmp b/ue2/imgsynth2/test/yellow_man1_rgb555_in.bmp new file mode 100644 index 0000000..3824922 --- /dev/null +++ b/ue2/imgsynth2/test/yellow_man1_rgb555_in.bmp | |||
| Binary files differ | |||
diff --git a/ue2/imgsynth2/test/yellow_man1_rgb555_out.bmp b/ue2/imgsynth2/test/yellow_man1_rgb555_out.bmp new file mode 100644 index 0000000..1c35ab5 --- /dev/null +++ b/ue2/imgsynth2/test/yellow_man1_rgb555_out.bmp | |||
| Binary files differ | |||
diff --git a/ue2/imgsynth2/test/yellow_man1_rgb555_ref.bmp b/ue2/imgsynth2/test/yellow_man1_rgb555_ref.bmp new file mode 100644 index 0000000..1c35ab5 --- /dev/null +++ b/ue2/imgsynth2/test/yellow_man1_rgb555_ref.bmp | |||
| Binary files differ | |||
diff --git a/ue2/imgsynth2/test/yellow_man2_rgb24_in.bmp b/ue2/imgsynth2/test/yellow_man2_rgb24_in.bmp new file mode 100644 index 0000000..39193a4 --- /dev/null +++ b/ue2/imgsynth2/test/yellow_man2_rgb24_in.bmp | |||
| Binary files differ | |||
diff --git a/ue2/imgsynth2/test/yellow_man2_rgb24_out.bmp b/ue2/imgsynth2/test/yellow_man2_rgb24_out.bmp new file mode 100644 index 0000000..c859cda --- /dev/null +++ b/ue2/imgsynth2/test/yellow_man2_rgb24_out.bmp | |||
| Binary files differ | |||
diff --git a/ue2/imgsynth2/test/yellow_man2_rgb24_ref.bmp b/ue2/imgsynth2/test/yellow_man2_rgb24_ref.bmp new file mode 100644 index 0000000..2ef73e5 --- /dev/null +++ b/ue2/imgsynth2/test/yellow_man2_rgb24_ref.bmp | |||
| Binary files differ | |||
diff --git a/ue2/imgsynth2/test/yellow_man2_rgb555_in.bmp b/ue2/imgsynth2/test/yellow_man2_rgb555_in.bmp new file mode 100644 index 0000000..812311d --- /dev/null +++ b/ue2/imgsynth2/test/yellow_man2_rgb555_in.bmp | |||
| Binary files differ | |||
diff --git a/ue2/imgsynth2/test/yellow_man2_rgb555_out.bmp b/ue2/imgsynth2/test/yellow_man2_rgb555_out.bmp new file mode 100644 index 0000000..60588e3 --- /dev/null +++ b/ue2/imgsynth2/test/yellow_man2_rgb555_out.bmp | |||
| Binary files differ | |||
diff --git a/ue2/imgsynth2/test/yellow_man2_rgb555_ref.bmp b/ue2/imgsynth2/test/yellow_man2_rgb555_ref.bmp new file mode 100644 index 0000000..1b63825 --- /dev/null +++ b/ue2/imgsynth2/test/yellow_man2_rgb555_ref.bmp | |||
| Binary files differ | |||
diff --git a/ue2/imgsynth2/x1 b/ue2/imgsynth2/x1 new file mode 100644 index 0000000..5593645 --- /dev/null +++ b/ue2/imgsynth2/x1 | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | 00000000 42 4d 8a 01 00 00 00 00 00 00 36 00 00 00 28 00 |BM........6...(.| | ||
| 2 | 00000010 00 00 09 00 00 00 11 00 00 00 01 00 10 00 00 00 |................| | ||
| 3 | 00000020 00 00 54 01 00 00 13 0b 00 00 13 0b 00 00 00 00 |..T.............| | ||
| 4 | 00000030 00 00 00 00 00 00 00 00 00 00 1f 00 1f 00 1f 00 |................| | ||
| 5 | 00000040 1f 00 1f 00 1f 00 1f 00 00 00 00 00 00 00 1f 00 |................| | ||
| 6 | 00000050 1f 00 1f 00 1f 00 1f 00 1f 00 1f 00 00 00 00 00 |................| | ||
| 7 | 00000060 00 00 1f 00 1f 00 1f 00 1f 00 1f 00 1f 00 1f 00 |................| | ||
| 8 | 00000070 00 00 00 00 00 00 1f 00 1f 00 1f 00 1f 00 1f 00 |................| | ||
| 9 | 00000080 1f 00 1f 00 00 00 00 00 00 00 00 00 a0 7f 00 00 |................| | ||
| 10 | 00000090 a0 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | ||
| 11 | 000000a0 a0 7f 00 00 a0 7f 00 00 00 00 00 00 00 00 00 00 |................| | ||
| 12 | 000000b0 a0 7f 00 00 a0 7f a0 7f a0 7f 00 00 a0 7f 00 00 |................| | ||
| 13 | 000000c0 00 00 00 00 a0 7f 00 00 a0 7f a0 7f a0 7f 00 00 |................| | ||
| 14 | 000000d0 a0 7f 00 00 00 00 00 00 a0 7f 00 00 a0 7f a0 7f |................| | ||
| 15 | 000000e0 a0 7f 00 00 a0 7f 00 00 00 00 e0 03 e0 03 e0 03 |................| | ||
| 16 | 000000f0 e0 03 e0 03 e0 03 00 00 a0 7f 00 00 00 00 e0 03 |................| | ||
| 17 | 00000100 e0 03 e0 03 e0 03 e0 03 e0 03 a0 7f 00 00 00 00 |................| | ||
| 18 | 00000110 00 00 e0 03 e0 03 e0 03 e0 03 e0 03 e0 03 00 00 |................| | ||
| 19 | 00000120 00 00 00 00 00 00 e0 03 e0 03 e0 03 e0 03 e0 03 |................| | ||
| 20 | 00000130 e0 03 00 00 00 00 00 00 00 00 e0 03 e0 03 e0 03 |................| | ||
| 21 | 00000140 e0 03 e0 03 e0 03 00 00 00 00 00 00 00 00 00 00 |................| | ||
| 22 | 00000150 00 00 00 00 a0 7f a0 7f a0 7f 00 00 00 00 00 00 |................| | ||
| 23 | 00000160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | ||
| 24 | * | ||
| 25 | 00000180 00 00 00 00 00 00 00 00 00 00 |..........| | ||
| 26 | 0000018a | ||
diff --git a/ue2/imgsynth2/x2 b/ue2/imgsynth2/x2 new file mode 100644 index 0000000..26cbf82 --- /dev/null +++ b/ue2/imgsynth2/x2 | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | 00000000 42 4d 8a 01 00 00 00 00 00 00 36 00 00 00 28 00 |BM........6...(.| | ||
| 2 | 00000010 00 00 09 00 00 00 11 00 00 00 01 00 10 00 00 00 |................| | ||
| 3 | 00000020 00 00 54 01 00 00 13 0b 00 00 13 0b 00 00 00 00 |..T.............| | ||
| 4 | 00000030 00 00 00 00 00 00 00 00 00 00 1f 00 1f 00 1f 00 |................| | ||
| 5 | 00000040 1f 00 1f 00 1f 00 1f 00 00 00 00 00 00 00 1f 00 |................| | ||
| 6 | 00000050 1f 00 1f 00 1f 00 1f 00 1f 00 1f 00 00 00 00 00 |................| | ||
| 7 | 00000060 00 00 1f 00 1f 7f 1f 00 1f 7f 1f 00 1f 00 1f 00 |................| | ||
| 8 | 00000070 00 00 00 00 00 00 1f 00 1f 7f 1f 00 1f 7f 1f 00 |................| | ||
| 9 | 00000080 1f 00 1f 00 00 00 00 00 00 00 00 00 a0 7f 00 00 |................| | ||
| 10 | 00000090 a0 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | ||
| 11 | 000000a0 a0 7f 00 00 a0 7f 00 00 00 00 00 00 00 00 00 00 |................| | ||
| 12 | 000000b0 a0 7f 00 00 a0 7f a0 7f a0 7f 00 00 a0 7f 00 00 |................| | ||
| 13 | 000000c0 00 00 00 00 a0 7f 00 00 a0 7f a0 7f a0 7f 00 00 |................| | ||
| 14 | 000000d0 a0 7f 00 00 00 00 00 00 a0 7f 00 00 a0 7f a0 7f |................| | ||
| 15 | 000000e0 a0 7f 00 00 a0 7f 00 00 00 00 00 00 00 7f 00 00 |................| | ||
| 16 | 000000f0 00 7f 00 7f 00 7f 00 00 a0 7f 00 00 00 00 00 00 |................| | ||
| 17 | 00000100 00 00 00 7f 00 7f 00 7f 00 7f a0 7f 00 00 00 00 |................| | ||
| 18 | 00000110 00 00 00 00 00 00 00 00 00 00 00 7f 00 00 00 00 |................| | ||
| 19 | 00000120 00 00 00 00 00 00 00 00 00 00 00 00 00 7f 00 7f |................| | ||
| 20 | 00000130 00 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | ||
| 21 | 00000140 00 7f 00 7f 00 7f 00 00 00 00 00 00 00 00 00 00 |................| | ||
| 22 | 00000150 00 00 00 00 a0 7f a0 7f a0 7f 00 00 00 00 00 00 |................| | ||
| 23 | 00000160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | ||
| 24 | * | ||
| 25 | 00000180 00 00 00 00 00 00 00 00 00 00 |..........| | ||
| 26 | 0000018a | ||
