diff options
Diffstat (limited to 'ue2/imgsynth2')
20 files changed, 498 insertions, 247 deletions
diff --git a/ue2/imgsynth2/Makefile b/ue2/imgsynth2/Makefile index 8c3079d..481230c 100644 --- a/ue2/imgsynth2/Makefile +++ b/ue2/imgsynth2/Makefile | |||
| @@ -12,11 +12,11 @@ LIBS= -L/usr/local/lib -lboost_program_options | |||
| 12 | 12 | ||
| 13 | BIN= imgsynth2 | 13 | BIN= imgsynth2 |
| 14 | OBJS= cpixelformat_bgr24.o cpixelformat_bgr555.o \ | 14 | OBJS= cpixelformat_bgr24.o cpixelformat_bgr555.o \ |
| 15 | cpixelformat_indexed8.o cpixmap.o cwindowsbitmap.o \ | 15 | cpixelformat_indexed8.o cpixmap.o cwindowsbitmap.o \ |
| 16 | cbitmap.o cscriptparser.o imgsynth2.o | 16 | cbitmap.o cscriptparser.o imgsynth2.o |
| 17 | HEADERS= cpixelformat.h cpixelformat_bgr24.h cpixelformat_bgr555.h \ | 17 | HEADERS= cpixelformat.h cpixelformat_bgr24.h cpixelformat_bgr555.h \ |
| 18 | cpixelformat_indexed8.h cpixmap.h cfile.h cbitmap.h \ | 18 | cpixelformat_indexed8.h cpixmap.h cfile.h cbitmap.h \ |
| 19 | cwindowsbitmap.h cscriptparser.h | 19 | cwindowsbitmap.h cscriptparser.h |
| 20 | 20 | ||
| 21 | .SUFFIXES: .cpp .o | 21 | .SUFFIXES: .cpp .o |
| 22 | 22 | ||
diff --git a/ue2/imgsynth2/cbitmap.cpp b/ue2/imgsynth2/cbitmap.cpp index acee870..ed26600 100644 --- a/ue2/imgsynth2/cbitmap.cpp +++ b/ue2/imgsynth2/cbitmap.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | * @date 17.04.2009 | 5 | * @date 17.04.2009 |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | #include <algorithm> | ||
| 8 | #include <boost/lexical_cast.hpp> | 9 | #include <boost/lexical_cast.hpp> |
| 9 | #include <boost/numeric/conversion/cast.hpp> | 10 | #include <boost/numeric/conversion/cast.hpp> |
| 10 | #include "cbitmap.h" | 11 | #include "cbitmap.h" |
| @@ -25,14 +26,20 @@ CBitmap::~CBitmap() | |||
| 25 | for (it = m_handlers.begin(); it != m_handlers.end(); it++) | 26 | for (it = m_handlers.begin(); it != m_handlers.end(); it++) |
| 26 | delete *it; | 27 | delete *it; |
| 27 | m_pixelformat = NULL; | 28 | m_pixelformat = NULL; |
| 28 | 29 | ||
| 29 | /* delete color table */ | 30 | /* delete colortable content */ |
| 30 | map<string, map<string, uint32_t* > >::iterator it1; | 31 | //TODO |
| 31 | map<string, uint32_t* >::iterator it2; | 32 | /*map<string, CPixelFormat::RGBPIXEL *>::iterator it2; |
| 32 | for ( it1= xpmColors.begin() ; it1 != xpmColors.end(); it1++ ) | 33 | for (it2 = m_colortable.begin(); it2 != m_colortable.end(); it2++) |
| 33 | for ( it2=(*it1).second.begin() ; it2 != (*it1).second.end(); it2++ ) | 34 | delete (*it2).second;*/ |
| 34 | delete [] (*it2).second; | 35 | |
| 35 | 36 | map<string, map<string, uint32_t *> >::iterator it1; | |
| 37 | map<string, uint32_t *>::iterator it2; | ||
| 38 | for(it1 = xpmColors.begin(); it1 != xpmColors.end(); it1++) | ||
| 39 | { | ||
| 40 | for(it2 = (*it1).second.begin(); it2 != (*it1).second.end(); it2++) | ||
| 41 | delete[] (*it2).second; | ||
| 42 | } | ||
| 36 | } | 43 | } |
| 37 | 44 | ||
| 38 | /*----------------------------------------------------------------------------*/ | 45 | /*----------------------------------------------------------------------------*/ |
| @@ -44,6 +51,8 @@ void CBitmap::callFunc(const std::string& func, const std::list<std::string>& pa | |||
| 44 | 51 | ||
| 45 | if (func == "fillrect") | 52 | if (func == "fillrect") |
| 46 | fillrect(params); | 53 | fillrect(params); |
| 54 | else if (func == "brightness") | ||
| 55 | brightness(params); | ||
| 47 | else if (func == "mirror_x") | 56 | else if (func == "mirror_x") |
| 48 | mirror_x(params); | 57 | mirror_x(params); |
| 49 | else if (func == "mirror_y") | 58 | else if (func == "mirror_y") |
| @@ -88,17 +97,22 @@ void CBitmap::fillrect(std::list<std::string> params) | |||
| 88 | throw FileError("At least one x/y-parameter is out of range."); | 97 | throw FileError("At least one x/y-parameter is out of range."); |
| 89 | 98 | ||
| 90 | /* check parameter values are in range */ | 99 | /* check parameter values are in range */ |
| 91 | unsigned int max[3]; | 100 | CPixelFormat::RGBPIXEL pixel; |
| 92 | m_pixelformat->getMaxColor(&max[0], &max[1], &max[2]); | 101 | m_pixelformat->getMaxColor(pixel); |
| 93 | if (pparams[4] < 0 || pparams[4] > max[0] | 102 | if (pparams[4] < 0 || pparams[4] > pixel.red |
| 94 | || pparams[5] < 0 || pparams[5] > max[1] | 103 | || pparams[5] < 0 || pparams[5] > pixel.green |
| 95 | || pparams[6] < 0 || pparams[6] > max[2]) | 104 | || pparams[6] < 0 || pparams[6] > pixel.blue) |
| 96 | throw FileError("At least one pixel color parameter is out of range."); | 105 | throw FileError("At least one pixel color parameter is out of range."); |
| 97 | 106 | ||
| 98 | if (pparams[2] < 0 || pparams[2] + pparams[0] > getWidth() | 107 | if (pparams[2] < 0 || pparams[2] + pparams[0] > getWidth() |
| 99 | || pparams[3] < 0 || pparams[3] + pparams[1] > getHeight()) | 108 | || pparams[3] < 0 || pparams[3] + pparams[1] > getHeight()) |
| 100 | throw FileError("At least one w/h-parameter is out of range."); | 109 | throw FileError("At least one w/h-parameter is out of range."); |
| 101 | 110 | ||
| 111 | /* new pixel data */ | ||
| 112 | pixel.red = pparams[4]; | ||
| 113 | pixel.green = pparams[5]; | ||
| 114 | pixel.blue = pparams[6]; | ||
| 115 | |||
| 102 | /* call setPixel for every pixel in the rectangel */ | 116 | /* call setPixel for every pixel in the rectangel */ |
| 103 | for(uint32_t i = pparams[0]; i < pparams[2] + pparams[0]; i++) | 117 | for(uint32_t i = pparams[0]; i < pparams[2] + pparams[0]; i++) |
| 104 | { | 118 | { |
| @@ -106,7 +120,7 @@ void CBitmap::fillrect(std::list<std::string> params) | |||
| 106 | { | 120 | { |
| 107 | try | 121 | try |
| 108 | { | 122 | { |
| 109 | m_pixelformat->setPixel(&pparams[4], i, j); | 123 | m_pixelformat->setPixel(pixel, i, j); |
| 110 | } | 124 | } |
| 111 | catch(CPixelFormat::PixelFormatError& ex) | 125 | catch(CPixelFormat::PixelFormatError& ex) |
| 112 | { | 126 | { |
| @@ -122,7 +136,6 @@ void CBitmap::fillrect(std::list<std::string> params) | |||
| 122 | 136 | ||
| 123 | /*----------------------------------------------------------------------------*/ | 137 | /*----------------------------------------------------------------------------*/ |
| 124 | 138 | ||
| 125 | /* TODO */ | ||
| 126 | void CBitmap::invert(std::list<std::string> params) | 139 | void CBitmap::invert(std::list<std::string> params) |
| 127 | { | 140 | { |
| 128 | /* check prerequirements */ | 141 | /* check prerequirements */ |
| @@ -133,49 +146,116 @@ void CBitmap::invert(std::list<std::string> params) | |||
| 133 | if (m_pixeldata == NULL || m_pixelformat == NULL) | 146 | if (m_pixeldata == NULL || m_pixelformat == NULL) |
| 134 | return; | 147 | return; |
| 135 | 148 | ||
| 136 | /* TODO pixelwidth */ | 149 | CPixelFormat::RGBPIXEL pixel; |
| 137 | unsigned int pixelwidth = m_pixelformat->getBitCount()/8; | 150 | CPixelFormat::RGBPIXEL max; |
| 138 | 151 | m_pixelformat->getMaxColor(max); | |
| 139 | /* calc rowsize - boundary is 32 */ | 152 | if (hasColorTable()) |
| 140 | uint32_t rowsize = 4 * static_cast<uint32_t>( | ||
| 141 | ((m_pixelformat->getBitCount() * getWidth()) + 31) / 32 | ||
| 142 | ); | ||
| 143 | |||
| 144 | for(uint32_t i = 0; i < getHeight(); i++) | ||
| 145 | { | 153 | { |
| 146 | for(uint32_t j = 0; j <= getWidth(); j++) | 154 | /* invert every entry in the colortable */ |
| 155 | map<string, CPixelFormat::RGBPIXEL *>::iterator it; | ||
| 156 | //TODO | ||
| 157 | /*for (it = m_colortable.begin(); it != m_colortable.end(); it++) | ||
| 147 | { | 158 | { |
| 148 | /*TODO cout << j << endl;*/ | 159 | (*it).second->red = max.red - (*it).second->red; |
| 149 | break; | 160 | (*it).second->green = max.green - (*it).second->green; |
| 150 | } | 161 | (*it).second->blue = max.blue - (*it).second->blue; |
| 162 | }*/ | ||
| 151 | } | 163 | } |
| 152 | 164 | else | |
| 153 | #if 0 | 165 | { |
| 154 | uint32_t offset = i * rowsize; | 166 | /* invert per pixel */ |
| 155 | 167 | for(uint32_t y = 0; y < getHeight(); y++) | |
| 156 | for(uint32_t j = 0; j <= getWidth()/2; j++) | ||
| 157 | { | 168 | { |
| 158 | uint32_t poffset = offset + j * pixelwidth; | 169 | for(uint32_t x = 0; x < getWidth(); x++) |
| 159 | uint32_t pbackset = offset + getWidth() * pixelwidth - j * pixelwidth; | 170 | { |
| 160 | 171 | try | |
| 161 | /* boundary check */ | 172 | { |
| 162 | if (pbackset > m_infoheader.biSizeImage) | 173 | m_pixelformat->getPixel(pixel, x, y); |
| 163 | throw FileError("Mirrored pixel position is out of range."); | 174 | pixel.red = max.red - pixel.red; |
| 164 | 175 | pixel.green = max.green - pixel.green; | |
| 165 | /* mirroring, backup right data first */ | 176 | pixel.blue = max.blue - pixel.blue; |
| 166 | copy(m_pixeldata + pbackset - pixelwidth, m_pixeldata + pbackset, buf); | 177 | m_pixelformat->setPixel(pixel, x, y); |
| 167 | copy(m_pixeldata + poffset, m_pixeldata + poffset + pixelwidth, m_pixeldata + pbackset - pixelwidth); | 178 | } |
| 168 | copy(buf, buf + pixelwidth, m_pixeldata + poffset); | 179 | catch(CPixelFormat::PixelFormatError& ex) |
| 180 | { | ||
| 181 | stringstream errstr; | ||
| 182 | errstr << "Can't invert pixel (pos=[" << x << "," << y << "]): " | ||
| 183 | << ex.what(); | ||
| 184 | throw FileError(errstr.str()); | ||
| 185 | } | ||
| 186 | } | ||
| 169 | } | 187 | } |
| 170 | } | 188 | } |
| 171 | #endif | ||
| 172 | } | 189 | } |
| 173 | 190 | ||
| 174 | /*----------------------------------------------------------------------------*/ | 191 | /*----------------------------------------------------------------------------*/ |
| 175 | 192 | ||
| 176 | /* TODO */ | ||
| 177 | void CBitmap::brightness(std::list<std::string> params) | 193 | void CBitmap::brightness(std::list<std::string> params) |
| 178 | { | 194 | { |
| 195 | /* check prerequirements */ | ||
| 196 | if (params.size() != 1) | ||
| 197 | throw FileError("Invalid number of function parameters (must be 1)."); | ||
| 198 | |||
| 199 | /* do nothing if no pixel exists */ | ||
| 200 | if (m_pixeldata == NULL || m_pixelformat == NULL) | ||
| 201 | return; | ||
| 202 | |||
| 203 | /* convert parameters */ | ||
| 204 | float factor; | ||
| 205 | try | ||
| 206 | { | ||
| 207 | factor = boost::lexical_cast<float>(params.front()); | ||
| 208 | params.pop_front(); | ||
| 209 | } | ||
| 210 | catch(boost::bad_lexical_cast& ex) | ||
| 211 | { | ||
| 212 | throw FileError("Invalid parameter (" + params.front() + ")."); | ||
| 213 | } | ||
| 214 | |||
| 215 | /* negative factor doesn't make sense */ | ||
| 216 | if (factor < 0) | ||
| 217 | throw FileError("Brightness parameter must be positive."); | ||
| 218 | |||
| 219 | CPixelFormat::RGBPIXEL pixel; | ||
| 220 | CPixelFormat::RGBPIXEL max; | ||
| 221 | m_pixelformat->getMaxColor(max); | ||
| 222 | if (hasColorTable()) | ||
| 223 | { | ||
| 224 | /* invert every entry in the colortable */ | ||
| 225 | map<string, CPixelFormat::RGBPIXEL *>::iterator it; | ||
| 226 | //TODO | ||
| 227 | /*for (it = m_colortable.begin(); it != m_colortable.end(); it++) | ||
| 228 | { | ||
| 229 | (*it).second->red = min(max.red, static_cast<uint32_t>((*it).second->red * factor)); | ||
| 230 | (*it).second->green = min(max.green, static_cast<uint32_t>((*it).second->green * factor)); | ||
| 231 | (*it).second->blue = min(max.blue, static_cast<uint32_t>((*it).second->blue * factor)); | ||
| 232 | }*/ | ||
| 233 | } | ||
| 234 | else | ||
| 235 | { | ||
| 236 | /* invert per pixel */ | ||
| 237 | for(uint32_t y = 0; y < getHeight(); y++) | ||
| 238 | { | ||
| 239 | for(uint32_t x = 0; x < getWidth(); x++) | ||
| 240 | { | ||
| 241 | try | ||
| 242 | { | ||
| 243 | m_pixelformat->getPixel(pixel, x, y); | ||
| 244 | pixel.red = min(max.red, static_cast<uint32_t>(pixel.red * factor)); | ||
| 245 | pixel.green = min(max.green, static_cast<uint32_t>(pixel.green * factor)); | ||
| 246 | pixel.blue = min(max.blue, static_cast<uint32_t>(pixel.blue * factor)); | ||
| 247 | m_pixelformat->setPixel(pixel, x, y); | ||
| 248 | } | ||
| 249 | catch(CPixelFormat::PixelFormatError& ex) | ||
| 250 | { | ||
| 251 | stringstream errstr; | ||
| 252 | errstr << "Can't invert pixel (pos=[" << x << "," << y << "]): " | ||
| 253 | << ex.what(); | ||
| 254 | throw FileError(errstr.str()); | ||
| 255 | } | ||
| 256 | } | ||
| 257 | } | ||
| 258 | } | ||
| 179 | } | 259 | } |
| 180 | 260 | ||
| 181 | /*----------------------------------------------------------------------------*/ | 261 | /*----------------------------------------------------------------------------*/ |
diff --git a/ue2/imgsynth2/cbitmap.h b/ue2/imgsynth2/cbitmap.h index f521bcc..c8d4dfb 100644 --- a/ue2/imgsynth2/cbitmap.h +++ b/ue2/imgsynth2/cbitmap.h | |||
| @@ -10,10 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #include <stdint.h> | 11 | #include <stdint.h> |
| 12 | #include <map> | 12 | #include <map> |
| 13 | #include <string> | ||
| 14 | #include "cfile.h" | 13 | #include "cfile.h" |
| 15 | |||
| 16 | class CPixelFormat; | ||
| 17 | #include "cpixelformat.h" | 14 | #include "cpixelformat.h" |
| 18 | 15 | ||
| 19 | /** | 16 | /** |
| @@ -55,12 +52,28 @@ class CBitmap : public CFile | |||
| 55 | virtual ~CBitmap(); | 52 | virtual ~CBitmap(); |
| 56 | 53 | ||
| 57 | /** | 54 | /** |
| 58 | * TODO | 55 | * @method read |
| 56 | * @brief Reads Windows Bitmap from filestream. | ||
| 57 | * On error an exception is thrown. | ||
| 58 | * @param in filestream to read data from | ||
| 59 | * @return - | ||
| 60 | * @globalvars none | ||
| 61 | * @exception CFile::FileError | ||
| 62 | * @exception bad_alloc | ||
| 63 | * @conditions none | ||
| 59 | */ | 64 | */ |
| 60 | virtual void read(std::ifstream& in) = 0; | 65 | virtual void read(std::ifstream& in) = 0; |
| 61 | 66 | ||
| 62 | /** | 67 | /** |
| 63 | * TODO | 68 | * @method write |
| 69 | * @brief Writes Windows Bitmap to filestream. | ||
| 70 | * @param out filestream to read data from | ||
| 71 | * @param filename filename (maybe useful for some handlers) | ||
| 72 | * @return - | ||
| 73 | * @globalvars none | ||
| 74 | * @exception FileError | ||
| 75 | * @exception bad_alloc | ||
| 76 | * @conditions none | ||
| 64 | */ | 77 | */ |
| 65 | virtual void write(std::ofstream& out, std::string& filename) = 0; | 78 | virtual void write(std::ofstream& out, std::string& filename) = 0; |
| 66 | 79 | ||
| @@ -78,15 +91,62 @@ class CBitmap : public CFile | |||
| 78 | return m_pixeldata; | 91 | return m_pixeldata; |
| 79 | } | 92 | } |
| 80 | 93 | ||
| 81 | /* TODO */ | 94 | /** |
| 95 | * @method getPixelDataSize | ||
| 96 | * @brief Return size of pixelbuffer | ||
| 97 | * @param - | ||
| 98 | * @return size of pixelbuffer | ||
| 99 | * @globalvars none | ||
| 100 | * @exception none | ||
| 101 | * @conditions none | ||
| 102 | */ | ||
| 82 | virtual const uint32_t getPixelDataSize() = 0; | 103 | virtual const uint32_t getPixelDataSize() = 0; |
| 83 | /* TODO */ | 104 | |
| 105 | /** | ||
| 106 | * @method getHeight | ||
| 107 | * @brief Return height of bitmap in pixel | ||
| 108 | * @param - | ||
| 109 | * @return height of bitmap in pixel | ||
| 110 | * @globalvars none | ||
| 111 | * @exception none | ||
| 112 | * @conditions none | ||
| 113 | */ | ||
| 84 | virtual const uint32_t getHeight() = 0; | 114 | virtual const uint32_t getHeight() = 0; |
| 85 | /* TODO */ | 115 | |
| 116 | /** | ||
| 117 | * @method getWidth | ||
| 118 | * @brief Return width of bitmap in pixel | ||
| 119 | * @param - | ||
| 120 | * @return width of bitmap in pixel | ||
| 121 | * @globalvars none | ||
| 122 | * @exception none | ||
| 123 | * @conditions none | ||
| 124 | */ | ||
| 86 | virtual const uint32_t getWidth() = 0; | 125 | virtual const uint32_t getWidth() = 0; |
| 87 | /* TODO */ | 126 | |
| 127 | /** | ||
| 128 | * @method isMirrored | ||
| 129 | * @brief Windows Bitmaps can be stored upside down | ||
| 130 | * @param - | ||
| 131 | * @return true if bitmap is stored upside down. false otherwise | ||
| 132 | * @globalvars none | ||
| 133 | * @exception none | ||
| 134 | * @conditions none | ||
| 135 | */ | ||
| 88 | virtual const bool isMirrored() = 0; | 136 | virtual const bool isMirrored() = 0; |
| 89 | 137 | ||
| 138 | /** | ||
| 139 | * @method hasColorTable | ||
| 140 | * @brief Check if bitmap has a colortable | ||
| 141 | * (we don't support this yet for windows bitmaps) | ||
| 142 | * @param - | ||
| 143 | * @return true if bitmap has a colortable. false otherwise | ||
| 144 | * @globalvars none | ||
| 145 | * @exception none | ||
| 146 | * @conditions none | ||
| 147 | */ | ||
| 148 | virtual const bool hasColorTable() = 0; | ||
| 149 | |||
| 90 | protected: | 150 | protected: |
| 91 | /** | 151 | /** |
| 92 | * @method callFunc | 152 | * @method callFunc |
| @@ -101,7 +161,7 @@ class CBitmap : public CFile | |||
| 101 | */ | 161 | */ |
| 102 | void callFunc(const std::string& func, const std::list<std::string>& params); | 162 | void callFunc(const std::string& func, const std::list<std::string>& params); |
| 103 | 163 | ||
| 104 | /** | 164 | /** |
| 105 | * @method fillrect | 165 | * @method fillrect |
| 106 | * @brief Fills rectangle in image starting on position x, y | 166 | * @brief Fills rectangle in image starting on position x, y |
| 107 | * width size width, height and color red, green, blue. | 167 | * width size width, height and color red, green, blue. |
| @@ -115,28 +175,68 @@ class CBitmap : public CFile | |||
| 115 | */ | 175 | */ |
| 116 | void fillrect(std::list<std::string> params); | 176 | void fillrect(std::list<std::string> params); |
| 117 | 177 | ||
| 118 | /* TODO */ | 178 | /** |
| 179 | * @method invert | ||
| 180 | * @brief Invert image | ||
| 181 | * @param params function parameters as list | ||
| 182 | * @return - | ||
| 183 | * @globalvars none | ||
| 184 | * @exception FileError | ||
| 185 | * @conditions none | ||
| 186 | * | ||
| 187 | * Scriptfile syntax: invert() | ||
| 188 | */ | ||
| 119 | void invert(std::list<std::string> params); | 189 | void invert(std::list<std::string> params); |
| 120 | 190 | ||
| 121 | /* TODO */ | 191 | /** |
| 192 | * @method brightness | ||
| 193 | * @brief Increase/decrease brightness of image | ||
| 194 | * @param params function parameters as list | ||
| 195 | * @return - | ||
| 196 | * @globalvars none | ||
| 197 | * @exception FileError | ||
| 198 | * @conditions none | ||
| 199 | * | ||
| 200 | * Scriptfile syntax: brightness(factor) | ||
| 201 | */ | ||
| 122 | void brightness(std::list<std::string> params); | 202 | void brightness(std::list<std::string> params); |
| 123 | 203 | ||
| 124 | /* TODO */ | 204 | /** |
| 205 | * @method mirror_y | ||
| 206 | * @brief Mirror image around the y-axis | ||
| 207 | * @param params function parameters as list | ||
| 208 | * @return - | ||
| 209 | * @globalvars none | ||
| 210 | * @exception FileError | ||
| 211 | * @conditions none | ||
| 212 | * | ||
| 213 | * Scriptfile syntax: mirror_y() | ||
| 214 | */ | ||
| 125 | void mirror_y(std::list<std::string> params); | 215 | void mirror_y(std::list<std::string> params); |
| 126 | 216 | ||
| 127 | /* TODO */ | 217 | /** |
| 218 | * @method mirror_x | ||
| 219 | * @brief Mirror image around the x-axis | ||
| 220 | * @param params function parameters as list | ||
| 221 | * @return - | ||
| 222 | * @globalvars none | ||
| 223 | * @exception FileError | ||
| 224 | * @conditions none | ||
| 225 | * | ||
| 226 | * Scriptfile syntax: mirror_y() | ||
| 227 | */ | ||
| 128 | void mirror_x(std::list<std::string> params); | 228 | void mirror_x(std::list<std::string> params); |
| 129 | 229 | ||
| 130 | /* members */ | 230 | /* members */ |
| 131 | /** pointer to pixelbuffer */ | 231 | /** pointer to pixelbuffer */ |
| 132 | uint8_t *m_pixeldata; | 232 | uint8_t *m_pixeldata; |
| 233 | /** colortable map */ | ||
| 234 | //TODO std::map<std::string, CPixelFormat::RGBPIXEL *> m_colortable; | ||
| 235 | std::map<std::string, std::map< std::string, uint32_t* > > xpmColors; | ||
| 133 | /** set of supported PixelFormat handlers */ | 236 | /** set of supported PixelFormat handlers */ |
| 134 | std::set<CPixelFormat *> m_handlers; | 237 | std::set<CPixelFormat *> m_handlers; |
| 135 | /** pointer to CPixelFormat implementation */ | 238 | /** pointer to CPixelFormat implementation */ |
| 136 | CPixelFormat *m_pixelformat; | 239 | CPixelFormat *m_pixelformat; |
| 137 | /* color table */ | ||
| 138 | std::map<std::string, std::map< std::string, uint32_t* > > xpmColors; | ||
| 139 | |||
| 140 | }; | 240 | }; |
| 141 | 241 | ||
| 142 | #endif | 242 | #endif |
diff --git a/ue2/imgsynth2/cpixelformat.h b/ue2/imgsynth2/cpixelformat.h index 2300f2f..18d1a7d 100644 --- a/ue2/imgsynth2/cpixelformat.h +++ b/ue2/imgsynth2/cpixelformat.h | |||
| @@ -10,11 +10,9 @@ | |||
| 10 | #define CPIXELFORMAT_H | 10 | #define CPIXELFORMAT_H |
| 11 | 11 | ||
| 12 | #include <fstream> | 12 | #include <fstream> |
| 13 | #include <string> | ||
| 14 | #include <stdexcept> | 13 | #include <stdexcept> |
| 15 | 14 | ||
| 16 | class CBitmap; | 15 | class CBitmap; |
| 17 | #include "cbitmap.h" | ||
| 18 | 16 | ||
| 19 | /** | 17 | /** |
| 20 | * @class CPixelFormat | 18 | * @class CPixelFormat |
| @@ -73,9 +71,22 @@ class CPixelFormat | |||
| 73 | {}; | 71 | {}; |
| 74 | 72 | ||
| 75 | /** | 73 | /** |
| 76 | * @method setPixel | 74 | * @brief RGB Pixel structure |
| 77 | * @brief Modifies pixel at coordinates x, y | 75 | */ |
| 78 | * @param pixel pointer to new pixel data | 76 | typedef struct |
| 77 | { | ||
| 78 | /** red */ | ||
| 79 | uint32_t red; | ||
| 80 | /** green */ | ||
| 81 | uint32_t green; | ||
| 82 | /** blue */ | ||
| 83 | uint32_t blue; | ||
| 84 | } RGBPIXEL; | ||
| 85 | |||
| 86 | /** | ||
| 87 | * @method getPixel | ||
| 88 | * @brief Get pixel at coordinates x, y | ||
| 89 | * @param pixel reference to pixel data | ||
| 79 | * @param x x-coordinate | 90 | * @param x x-coordinate |
| 80 | * @param y y-coordinate | 91 | * @param y y-coordinate |
| 81 | * @return - | 92 | * @return - |
| @@ -83,12 +94,12 @@ class CPixelFormat | |||
| 83 | * @exception PixelFormatError | 94 | * @exception PixelFormatError |
| 84 | * @conditions none | 95 | * @conditions none |
| 85 | */ | 96 | */ |
| 86 | virtual void setPixel(const uint32_t *pixel, const uint32_t x, const uint32_t y) = 0; | 97 | virtual void getPixel(RGBPIXEL& pixel, const uint32_t x, const uint32_t y) = 0; |
| 87 | 98 | ||
| 88 | /** | 99 | /** |
| 89 | * @method getPixel | 100 | * @method setPixel |
| 90 | * @brief Get pixel at coordinates x, y | 101 | * @brief Modifies pixel at coordinates x, y |
| 91 | * @param pixel pointer to pixel data | 102 | * @param pixel reference to new pixel data |
| 92 | * @param x x-coordinate | 103 | * @param x x-coordinate |
| 93 | * @param y y-coordinate | 104 | * @param y y-coordinate |
| 94 | * @return - | 105 | * @return - |
| @@ -96,7 +107,7 @@ class CPixelFormat | |||
| 96 | * @exception PixelFormatError | 107 | * @exception PixelFormatError |
| 97 | * @conditions none | 108 | * @conditions none |
| 98 | */ | 109 | */ |
| 99 | virtual void getPixel(uint32_t *pixel, const uint32_t x, const uint32_t y) = 0; | 110 | virtual void setPixel(const RGBPIXEL& pixel, const uint32_t x, const uint32_t y) = 0; |
| 100 | 111 | ||
| 101 | /** | 112 | /** |
| 102 | * @method getBitCount | 113 | * @method getBitCount |
| @@ -109,20 +120,16 @@ class CPixelFormat | |||
| 109 | */ | 120 | */ |
| 110 | virtual uint32_t getBitCount() = 0; | 121 | virtual uint32_t getBitCount() = 0; |
| 111 | 122 | ||
| 112 | /** | 123 | /** |
| 113 | * @method getColorMode | 124 | * @method getMaxColor |
| 114 | * @brief returns the color mode supported by this class | 125 | * @brief Get maximum values for RGB pixel |
| 115 | * @param - | 126 | * @param pixel reference to pixel struct |
| 116 | * @return color mode supported by this class | 127 | * @return - |
| 117 | * @globalvars none | 128 | * @globalvars none |
| 118 | * @exception none | 129 | * @exception none |
| 119 | * @conditions none | 130 | * @conditions none |
| 120 | */ | 131 | */ |
| 121 | virtual std::string getColorMode() = 0; | 132 | virtual void getMaxColor(RGBPIXEL& pixel) = 0; |
| 122 | /* | ||
| 123 | * TODO | ||
| 124 | */ | ||
| 125 | virtual void getMaxColor(unsigned int *red, unsigned int *green, unsigned int *blue) = 0; | ||
| 126 | 133 | ||
| 127 | protected: | 134 | protected: |
| 128 | /* members */ | 135 | /* members */ |
diff --git a/ue2/imgsynth2/cpixelformat_bgr24.cpp b/ue2/imgsynth2/cpixelformat_bgr24.cpp index 4567ce6..e7476d7 100644 --- a/ue2/imgsynth2/cpixelformat_bgr24.cpp +++ b/ue2/imgsynth2/cpixelformat_bgr24.cpp | |||
| @@ -7,17 +7,12 @@ | |||
| 7 | 7 | ||
| 8 | #include <boost/numeric/conversion/cast.hpp> | 8 | #include <boost/numeric/conversion/cast.hpp> |
| 9 | #include "cpixelformat_bgr24.h" | 9 | #include "cpixelformat_bgr24.h" |
| 10 | #include "cbitmap.h" | ||
| 10 | 11 | ||
| 11 | using namespace std; | 12 | using namespace std; |
| 12 | 13 | ||
| 13 | /* TODO */ | 14 | void CPixelFormat_BGR24::getPixel(RGBPIXEL& pixel, uint32_t x, uint32_t y) |
| 14 | void CPixelFormat_BGR24::getPixel(uint32_t *pixel, uint32_t x, uint32_t y) | ||
| 15 | { | 15 | { |
| 16 | /* | ||
| 17 | * pixel[0] ... red | ||
| 18 | * pixel[1] ... green | ||
| 19 | * pixel[2] ... blue | ||
| 20 | */ | ||
| 21 | if (m_bitmap->getPixelData() == NULL) | 16 | if (m_bitmap->getPixelData() == NULL) |
| 22 | throw PixelFormatError("No pixelbuffer allocated."); | 17 | throw PixelFormatError("No pixelbuffer allocated."); |
| 23 | 18 | ||
| @@ -36,25 +31,15 @@ void CPixelFormat_BGR24::getPixel(uint32_t *pixel, uint32_t x, uint32_t y) | |||
| 36 | throw PixelFormatError("Pixel position is out of range."); | 31 | throw PixelFormatError("Pixel position is out of range."); |
| 37 | 32 | ||
| 38 | /* get pixel */ | 33 | /* get pixel */ |
| 39 | try | 34 | pixel.red = *(m_bitmap->getPixelData() + offset + 2); |
| 40 | { | 35 | pixel.green = *(m_bitmap->getPixelData() + offset + 1); |
| 41 | pixel[0] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset + 2)); | 36 | pixel.blue = *(m_bitmap->getPixelData() + offset); |
| 42 | pixel[1] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset + 1)); | ||
| 43 | pixel[2] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset)); | ||
| 44 | } | ||
| 45 | catch(boost::numeric::bad_numeric_cast& ex) | ||
| 46 | { | ||
| 47 | throw PixelFormatError("Unable to convert pixelcolor to correct size: " + string(ex.what())); | ||
| 48 | } | ||
| 49 | } | 37 | } |
| 50 | 38 | ||
| 51 | void CPixelFormat_BGR24::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y) | 39 | /*----------------------------------------------------------------------------*/ |
| 40 | |||
| 41 | void CPixelFormat_BGR24::setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t y) | ||
| 52 | { | 42 | { |
| 53 | /* | ||
| 54 | * pixel[0] ... red | ||
| 55 | * pixel[1] ... green | ||
| 56 | * pixel[2] ... blue | ||
| 57 | */ | ||
| 58 | if (m_bitmap->getPixelData() == NULL) | 43 | if (m_bitmap->getPixelData() == NULL) |
| 59 | throw PixelFormatError("No pixelbuffer allocated."); | 44 | throw PixelFormatError("No pixelbuffer allocated."); |
| 60 | 45 | ||
| @@ -76,9 +61,9 @@ void CPixelFormat_BGR24::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y) | |||
| 76 | uint8_t data[3]; | 61 | uint8_t data[3]; |
| 77 | try | 62 | try |
| 78 | { | 63 | { |
| 79 | data[0] = boost::numeric_cast<uint8_t>(pixel[2]); | 64 | data[0] = boost::numeric_cast<uint8_t>(pixel.blue); |
| 80 | data[1] = boost::numeric_cast<uint8_t>(pixel[1]); | 65 | data[1] = boost::numeric_cast<uint8_t>(pixel.green); |
| 81 | data[2] = boost::numeric_cast<uint8_t>(pixel[0]); | 66 | data[2] = boost::numeric_cast<uint8_t>(pixel.red); |
| 82 | } | 67 | } |
| 83 | catch(boost::numeric::bad_numeric_cast& ex) | 68 | catch(boost::numeric::bad_numeric_cast& ex) |
| 84 | { | 69 | { |
diff --git a/ue2/imgsynth2/cpixelformat_bgr24.h b/ue2/imgsynth2/cpixelformat_bgr24.h index da1592b..242eadf 100644 --- a/ue2/imgsynth2/cpixelformat_bgr24.h +++ b/ue2/imgsynth2/cpixelformat_bgr24.h | |||
| @@ -45,13 +45,23 @@ class CPixelFormat_BGR24 : public CPixelFormat | |||
| 45 | ~CPixelFormat_BGR24() | 45 | ~CPixelFormat_BGR24() |
| 46 | {} | 46 | {} |
| 47 | 47 | ||
| 48 | /* TODO */ | 48 | /** |
| 49 | void getPixel(uint32_t *pixel, uint32_t x, uint32_t y); | 49 | * @method getPixel |
| 50 | * @brief Get pixel at coordinates x, y | ||
| 51 | * @param pixel reference to 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 getPixel(RGBPIXEL& pixel, uint32_t x, uint32_t y); | ||
| 50 | 60 | ||
| 51 | /** | 61 | /** |
| 52 | * @method setPixel | 62 | * @method setPixel |
| 53 | * @brief Modifies pixel at coordinates x, y | 63 | * @brief Modifies pixel at coordinates x, y |
| 54 | * @param pixel pointer to new pixel data | 64 | * @param pixel reference to new pixel data |
| 55 | * @param x x-coordinate | 65 | * @param x x-coordinate |
| 56 | * @param y y-coordinate | 66 | * @param y y-coordinate |
| 57 | * @return - | 67 | * @return - |
| @@ -59,7 +69,7 @@ class CPixelFormat_BGR24 : public CPixelFormat | |||
| 59 | * @exception PixelFormatError | 69 | * @exception PixelFormatError |
| 60 | * @conditions none | 70 | * @conditions none |
| 61 | */ | 71 | */ |
| 62 | void setPixel(const uint32_t *pixel, uint32_t x, uint32_t y); | 72 | void setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t y); |
| 63 | 73 | ||
| 64 | /** | 74 | /** |
| 65 | * @method getBitCount | 75 | * @method getBitCount |
| @@ -74,26 +84,20 @@ class CPixelFormat_BGR24 : public CPixelFormat | |||
| 74 | { | 84 | { |
| 75 | return 24; | 85 | return 24; |
| 76 | } | 86 | } |
| 77 | 87 | ||
| 78 | /** | 88 | /** |
| 79 | * @method getColorMode | 89 | * @method getMaxColor |
| 80 | * @brief returns the color mode supported by this class | 90 | * @brief Get maximum values for RGB pixel |
| 81 | * @param - | 91 | * @param pixel reference to pixel struct |
| 82 | * @return color mode supported by this class | 92 | * @return - |
| 83 | * @globalvars none | 93 | * @globalvars none |
| 84 | * @exception none | 94 | * @exception none |
| 85 | * @conditions none | 95 | * @conditions none |
| 86 | */ | 96 | */ |
| 87 | std::string getColorMode() | 97 | void getMaxColor(RGBPIXEL& pixel) |
| 88 | { | ||
| 89 | return "c"; | ||
| 90 | } | ||
| 91 | /* | ||
| 92 | * TODO | ||
| 93 | */ | ||
| 94 | void getMaxColor(unsigned int *red, unsigned int *green, unsigned int *blue) | ||
| 95 | { | 98 | { |
| 96 | *red = *green = *blue = 255; /* 2^8 - 1 */ | 99 | /* value = 2^8 - 1 */ |
| 100 | pixel.red = pixel.green = pixel.blue = 255; | ||
| 97 | } | 101 | } |
| 98 | }; | 102 | }; |
| 99 | 103 | ||
diff --git a/ue2/imgsynth2/cpixelformat_bgr555.cpp b/ue2/imgsynth2/cpixelformat_bgr555.cpp index 19c98a8..2f98cc7 100644 --- a/ue2/imgsynth2/cpixelformat_bgr555.cpp +++ b/ue2/imgsynth2/cpixelformat_bgr555.cpp | |||
| @@ -8,33 +8,40 @@ | |||
| 8 | 8 | ||
| 9 | #include <boost/numeric/conversion/cast.hpp> | 9 | #include <boost/numeric/conversion/cast.hpp> |
| 10 | #include "cpixelformat_bgr555.h" | 10 | #include "cpixelformat_bgr555.h" |
| 11 | #include "cbitmap.h" | ||
| 11 | 12 | ||
| 12 | using namespace std; | 13 | using namespace std; |
| 13 | 14 | ||
| 14 | /* TODO */ | 15 | void CPixelFormat_BGR555::getPixel(RGBPIXEL& pixel, uint32_t x, uint32_t y) |
| 15 | void CPixelFormat_BGR555::getPixel(uint32_t *pixel, uint32_t x, uint32_t y) | ||
| 16 | { | 16 | { |
| 17 | /* | ||
| 18 | * pixel[0] ... red | ||
| 19 | * pixel[1] ... green | ||
| 20 | * pixel[2] ... blue | ||
| 21 | */ | ||
| 22 | if (m_bitmap->getPixelData() == NULL) | 17 | if (m_bitmap->getPixelData() == NULL) |
| 23 | throw PixelFormatError("No pixelbuffer allocated."); | 18 | throw PixelFormatError("No pixelbuffer allocated."); |
| 24 | 19 | ||
| 25 | throw PixelFormatError("NOT IMPLEMENTED"); | 20 | /* calc rowsize - boundary is 32 */ |
| 21 | uint32_t rowsize = 4 * static_cast<uint32_t>( | ||
| 22 | ((getBitCount() * m_bitmap->getWidth()) + 31) / 32 | ||
| 23 | ); | ||
| 24 | |||
| 25 | /* if the y-coordinates are mirrored */ | ||
| 26 | if (m_bitmap->isMirrored()) | ||
| 27 | y = m_bitmap->getHeight() - y - 1; | ||
| 28 | uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); | ||
| 29 | |||
| 30 | /* boundary check */ | ||
| 31 | if (offset + getBitCount()/8 > m_bitmap->getPixelDataSize()) | ||
| 32 | throw PixelFormatError("Pixel position is out of range."); | ||
| 33 | |||
| 34 | /* get pixel */ | ||
| 35 | uint8_t *o = m_bitmap->getPixelData() + offset; | ||
| 36 | pixel.blue = (*(uint16_t *)o & BGR555_BLUE_MASK) >> BGR555_BLUE_SHIFT; | ||
| 37 | pixel.green = (*(uint16_t *)o & BGR555_GREEN_MASK) >> BGR555_GREEN_SHIFT; | ||
| 38 | pixel.red = (*(uint16_t *)o & BGR555_RED_MASK) >> BGR555_RED_SHIFT; | ||
| 26 | } | 39 | } |
| 27 | 40 | ||
| 28 | /*----------------------------------------------------------------------------*/ | 41 | /*----------------------------------------------------------------------------*/ |
| 29 | 42 | ||
| 30 | void CPixelFormat_BGR555::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y) | 43 | void CPixelFormat_BGR555::setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t y) |
| 31 | { | 44 | { |
| 32 | /* | ||
| 33 | * pixel[0] ... red | ||
| 34 | * pixel[1] ... green | ||
| 35 | * pixel[2] ... blue | ||
| 36 | */ | ||
| 37 | |||
| 38 | if (m_bitmap->getPixelData() == NULL) | 45 | if (m_bitmap->getPixelData() == NULL) |
| 39 | throw PixelFormatError("No pixelbuffer allocated."); | 46 | throw PixelFormatError("No pixelbuffer allocated."); |
| 40 | 47 | ||
| @@ -54,9 +61,9 @@ void CPixelFormat_BGR555::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y | |||
| 54 | 61 | ||
| 55 | /* convert color values to correct types */ | 62 | /* convert color values to correct types */ |
| 56 | uint8_t *o = m_bitmap->getPixelData() + offset; | 63 | uint8_t *o = m_bitmap->getPixelData() + offset; |
| 57 | *(uint16_t *)o = (uint16_t)(((pixel[2] << BGR555_BLUE_SHIFT) & BGR555_BLUE_MASK) | | 64 | *(uint16_t *)o = (uint16_t)(((pixel.blue << BGR555_BLUE_SHIFT) & BGR555_BLUE_MASK) | |
| 58 | ((pixel[1] << BGR555_GREEN_SHIFT) & BGR555_GREEN_MASK) | | 65 | ((pixel.green << BGR555_GREEN_SHIFT) & BGR555_GREEN_MASK) | |
| 59 | ((pixel[0] << BGR555_RED_SHIFT) & BGR555_RED_MASK)); | 66 | ((pixel.red << BGR555_RED_SHIFT) & BGR555_RED_MASK)); |
| 60 | } | 67 | } |
| 61 | 68 | ||
| 62 | /* vim: set et sw=2 ts=2: */ | 69 | /* vim: set et sw=2 ts=2: */ |
diff --git a/ue2/imgsynth2/cpixelformat_bgr555.h b/ue2/imgsynth2/cpixelformat_bgr555.h index 890b744..f131214 100644 --- a/ue2/imgsynth2/cpixelformat_bgr555.h +++ b/ue2/imgsynth2/cpixelformat_bgr555.h | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #include <fstream> | 12 | #include <fstream> |
| 13 | #include "cpixelformat.h" | 13 | #include "cpixelformat.h" |
| 14 | 14 | ||
| 15 | /* TODO */ | 15 | /* to (un-)pack pixel values */ |
| 16 | #define BGR555_RED_SHIFT 10 | 16 | #define BGR555_RED_SHIFT 10 |
| 17 | #define BGR555_GREEN_SHIFT 5 | 17 | #define BGR555_GREEN_SHIFT 5 |
| 18 | #define BGR555_BLUE_SHIFT 0 | 18 | #define BGR555_BLUE_SHIFT 0 |
| @@ -55,13 +55,23 @@ class CPixelFormat_BGR555 : public CPixelFormat | |||
| 55 | ~CPixelFormat_BGR555() | 55 | ~CPixelFormat_BGR555() |
| 56 | {} | 56 | {} |
| 57 | 57 | ||
| 58 | /* TODO */ | 58 | /** |
| 59 | void getPixel(uint32_t *pixel, uint32_t x, uint32_t y); | 59 | * @method getPixel |
| 60 | * @brief Get pixel at coordinates x, y | ||
| 61 | * @param pixel reference to 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 getPixel(RGBPIXEL& pixel, uint32_t x, uint32_t y); | ||
| 60 | 70 | ||
| 61 | /** | 71 | /** |
| 62 | * @method setPixel | 72 | * @method setPixel |
| 63 | * @brief Modifies pixel at coordinates x, y | 73 | * @brief Modifies pixel at coordinates x, y |
| 64 | * @param pixel pointer to new pixel data | 74 | * @param pixel reference to new pixel data |
| 65 | * @param x x-coordinate | 75 | * @param x x-coordinate |
| 66 | * @param y y-coordinate | 76 | * @param y y-coordinate |
| 67 | * @return - | 77 | * @return - |
| @@ -69,7 +79,7 @@ class CPixelFormat_BGR555 : public CPixelFormat | |||
| 69 | * @exception PixelFormatError | 79 | * @exception PixelFormatError |
| 70 | * @conditions none | 80 | * @conditions none |
| 71 | */ | 81 | */ |
| 72 | void setPixel(const uint32_t *pixel, uint32_t x, uint32_t y); | 82 | void setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t y); |
| 73 | 83 | ||
| 74 | /** | 84 | /** |
| 75 | * @method getBitCount | 85 | * @method getBitCount |
| @@ -85,26 +95,19 @@ class CPixelFormat_BGR555 : public CPixelFormat | |||
| 85 | return 16; | 95 | return 16; |
| 86 | } | 96 | } |
| 87 | 97 | ||
| 88 | /** | 98 | /** |
| 89 | * @method getColorMode | 99 | * @method getMaxColor |
| 90 | * @brief returns the color mode supported by this class | 100 | * @brief Get maximum values for RGB pixel |
| 91 | * @param - | 101 | * @param pixel reference to pixel struct |
| 92 | * @return color mode supported by this class | 102 | * @return - |
| 93 | * @globalvars none | 103 | * @globalvars none |
| 94 | * @exception none | 104 | * @exception none |
| 95 | * @conditions none | 105 | * @conditions none |
| 96 | */ | 106 | */ |
| 97 | std::string getColorMode() | 107 | void getMaxColor(RGBPIXEL& pixel) |
| 98 | { | ||
| 99 | return "c"; | ||
| 100 | } | ||
| 101 | |||
| 102 | /* | ||
| 103 | * TODO | ||
| 104 | */ | ||
| 105 | void getMaxColor(unsigned int *red, unsigned int *green, unsigned int *blue) | ||
| 106 | { | 108 | { |
| 107 | *red = *green = *blue = 31; /* 2^5 -1 */ | 109 | /* value = 2^5 - 1 */ |
| 110 | pixel.red = pixel.green = pixel.blue = 31; | ||
| 108 | } | 111 | } |
| 109 | }; | 112 | }; |
| 110 | 113 | ||
diff --git a/ue2/imgsynth2/cpixelformat_indexed8.cpp b/ue2/imgsynth2/cpixelformat_indexed8.cpp index c62a1ba..546daaf 100644 --- a/ue2/imgsynth2/cpixelformat_indexed8.cpp +++ b/ue2/imgsynth2/cpixelformat_indexed8.cpp | |||
| @@ -10,32 +10,28 @@ | |||
| 10 | 10 | ||
| 11 | using namespace std; | 11 | using namespace std; |
| 12 | 12 | ||
| 13 | void CPixelFormat_Indexed8::getPixel(uint32_t *pixel, uint32_t x, uint32_t y) | 13 | void CPixelFormat_Indexed8::getPixel(RGBPIXEL& pixel, uint32_t x, uint32_t y) |
| 14 | { | 14 | { |
| 15 | /* | 15 | #if 0 |
| 16 | * pixel[0] ... red | 16 | if (m_bitmap->getPixelData() == NULL) |
| 17 | * pixel[1] ... green | 17 | throw PixelFormatError("No pixelbuffer allocated."); |
| 18 | * pixel[2] ... blue | ||
| 19 | */ | ||
| 20 | // if (m_bitmap->getPixelData() == NULL) | ||
| 21 | // throw PixelFormatError("No pixelbuffer allocated."); | ||
| 22 | 18 | ||
| 23 | /* calc rowsize - boundary is 32 */ | 19 | /* calc rowsize - boundary is 32 */ |
| 24 | /* uint32_t rowsize = 4 * static_cast<uint32_t>( | 20 | uint32_t rowsize = 4 * static_cast<uint32_t>( |
| 25 | ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32 | 21 | ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32 |
| 26 | );*/ | 22 | );*/ |
| 27 | 23 | ||
| 28 | /* if height is positive the y-coordinates are mirrored */ | 24 | /* if height is positive the y-coordinates are mirrored */ |
| 29 | /* if (m_bitmap->getInfoHeader().biHeight > 0) | 25 | if (m_bitmap->getInfoHeader().biHeight > 0) |
| 30 | y = m_bitmap->getInfoHeader().biHeight - y - 1; | 26 | y = m_bitmap->getInfoHeader().biHeight - y - 1; |
| 31 | uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); | 27 | uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); |
| 32 | 28 | ||
| 33 | /* boundary check */ | 29 | /* boundary check */ |
| 34 | /* if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) | 30 | if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) |
| 35 | throw PixelFormatError("Pixel position is out of range."); | 31 | throw PixelFormatError("Pixel position is out of range."); |
| 36 | 32 | ||
| 37 | /* get pixel */ | 33 | /* get pixel */ |
| 38 | /* try | 34 | try |
| 39 | { | 35 | { |
| 40 | pixel[0] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset + 2)); | 36 | 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)); | 37 | pixel[1] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset + 1)); |
| @@ -44,35 +40,32 @@ void CPixelFormat_Indexed8::getPixel(uint32_t *pixel, uint32_t x, uint32_t y) | |||
| 44 | catch(boost::numeric::bad_numeric_cast& ex) | 40 | catch(boost::numeric::bad_numeric_cast& ex) |
| 45 | { | 41 | { |
| 46 | throw PixelFormatError("Unable to convert pixelcolor to correct size: " + string(ex.what())); | 42 | throw PixelFormatError("Unable to convert pixelcolor to correct size: " + string(ex.what())); |
| 47 | }*/ | 43 | } |
| 44 | #endif | ||
| 48 | } | 45 | } |
| 49 | 46 | ||
| 50 | void CPixelFormat_Indexed8::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y) | 47 | void CPixelFormat_Indexed8::setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t y) |
| 51 | { | 48 | { |
| 52 | /* | 49 | #if 0 |
| 53 | * pixel[0] ... red | 50 | if (m_bitmap->getPixelData() == NULL) |
| 54 | * pixel[1] ... green | ||
| 55 | * pixel[2] ... blue | ||
| 56 | */ | ||
| 57 | /* if (m_bitmap->getPixelData() == NULL) | ||
| 58 | throw PixelFormatError("No pixelbuffer allocated."); | 51 | throw PixelFormatError("No pixelbuffer allocated."); |
| 59 | 52 | ||
| 60 | /* calc rowsize - boundary is 32 */ | 53 | /* calc rowsize - boundary is 32 */ |
| 61 | /* uint32_t rowsize = 4 * static_cast<uint32_t>( | 54 | uint32_t rowsize = 4 * static_cast<uint32_t>( |
| 62 | ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32 | 55 | ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32 |
| 63 | ); | 56 | ); |
| 64 | 57 | ||
| 65 | /* if height is positive the y-coordinates are mirrored */ | 58 | /* if height is positive the y-coordinates are mirrored */ |
| 66 | /* if (m_bitmap->getInfoHeader().biHeight > 0) | 59 | if (m_bitmap->getInfoHeader().biHeight > 0) |
| 67 | y = m_bitmap->getInfoHeader().biHeight - y - 1; | 60 | y = m_bitmap->getInfoHeader().biHeight - y - 1; |
| 68 | uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); | 61 | uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); |
| 69 | 62 | ||
| 70 | /* boundary check */ | 63 | /* boundary check */ |
| 71 | /* if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) | 64 | if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) |
| 72 | throw PixelFormatError("Pixel position is out of range."); | 65 | throw PixelFormatError("Pixel position is out of range."); |
| 73 | 66 | ||
| 74 | /* convert color values to correct types */ | 67 | /* convert color values to correct types */ |
| 75 | /*uint8_t data[3]; | 68 | uint8_t data[3]; |
| 76 | try | 69 | try |
| 77 | { | 70 | { |
| 78 | data[0] = boost::numeric_cast<uint8_t>(pixel[2]); | 71 | data[0] = boost::numeric_cast<uint8_t>(pixel[2]); |
| @@ -85,6 +78,7 @@ void CPixelFormat_Indexed8::setPixel(const uint32_t *pixel, uint32_t x, uint32_t | |||
| 85 | } | 78 | } |
| 86 | 79 | ||
| 87 | copy(data, data + 3, m_bitmap->getPixelData() + offset); | 80 | copy(data, data + 3, m_bitmap->getPixelData() + offset); |
| 88 | */} | 81 | #endif |
| 82 | } | ||
| 89 | 83 | ||
| 90 | /* vim: set et sw=2 ts=2: */ | 84 | /* vim: set et sw=2 ts=2: */ |
diff --git a/ue2/imgsynth2/cpixelformat_indexed8.h b/ue2/imgsynth2/cpixelformat_indexed8.h index ff95840..2e2fc01 100644 --- a/ue2/imgsynth2/cpixelformat_indexed8.h +++ b/ue2/imgsynth2/cpixelformat_indexed8.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <fstream> | 11 | #include <fstream> |
| 12 | #include "cpixelformat.h" | 12 | #include "cpixelformat.h" |
| 13 | #include "cpixmap.h" | 13 | #include "cpixmap.h" |
| 14 | |||
| 14 | /** | 15 | /** |
| 15 | * @class CPixelFormat_Indexed8 | 16 | * @class CPixelFormat_Indexed8 |
| 16 | * @brief Implementation of CPixelFormat handling 24bit color Windows Bitmaps. | 17 | * @brief Implementation of CPixelFormat handling 24bit color Windows Bitmaps. |
| @@ -46,9 +47,22 @@ class CPixelFormat_Indexed8 : public CPixelFormat | |||
| 46 | {} | 47 | {} |
| 47 | 48 | ||
| 48 | /** | 49 | /** |
| 50 | * @method getPixel | ||
| 51 | * @brief Get pixel at coordinates x, y | ||
| 52 | * @param pixel reference to pixel data | ||
| 53 | * @param x x-coordinate | ||
| 54 | * @param y y-coordinate | ||
| 55 | * @return - | ||
| 56 | * @globalvars none | ||
| 57 | * @exception PixelFormatError | ||
| 58 | * @conditions none | ||
| 59 | */ | ||
| 60 | void getPixel(RGBPIXEL& pixel, uint32_t x, uint32_t y); | ||
| 61 | |||
| 62 | /** | ||
| 49 | * @method setPixel | 63 | * @method setPixel |
| 50 | * @brief Modifies pixel at coordinates x, y | 64 | * @brief Modifies pixel at coordinates x, y |
| 51 | * @param pixel pointer to new pixel data | 65 | * @param pixel reference to new pixel data |
| 52 | * @param x x-coordinate | 66 | * @param x x-coordinate |
| 53 | * @param y y-coordinate | 67 | * @param y y-coordinate |
| 54 | * @return - | 68 | * @return - |
| @@ -56,10 +70,7 @@ class CPixelFormat_Indexed8 : public CPixelFormat | |||
| 56 | * @exception PixelFormatError | 70 | * @exception PixelFormatError |
| 57 | * @conditions none | 71 | * @conditions none |
| 58 | */ | 72 | */ |
| 59 | void setPixel(const uint32_t *pixel, uint32_t x, uint32_t y); | 73 | void setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t y); |
| 60 | |||
| 61 | /* TODO */ | ||
| 62 | void getPixel(uint32_t *pixel, uint32_t x, uint32_t y); | ||
| 63 | 74 | ||
| 64 | /** | 75 | /** |
| 65 | * @method getBitCount | 76 | * @method getBitCount |
| @@ -74,7 +85,7 @@ class CPixelFormat_Indexed8 : public CPixelFormat | |||
| 74 | { | 85 | { |
| 75 | return 8; | 86 | return 8; |
| 76 | } | 87 | } |
| 77 | 88 | ||
| 78 | /** | 89 | /** |
| 79 | * @method getColorMode | 90 | * @method getColorMode |
| 80 | * @brief returns the color mode supported by this class | 91 | * @brief returns the color mode supported by this class |
| @@ -84,16 +95,24 @@ class CPixelFormat_Indexed8 : public CPixelFormat | |||
| 84 | * @exception none | 95 | * @exception none |
| 85 | * @conditions none | 96 | * @conditions none |
| 86 | */ | 97 | */ |
| 87 | std::string getColorMode() | 98 | const std::string getColorMode() |
| 88 | { | 99 | { |
| 89 | return "c"; | 100 | return "c"; |
| 90 | } | 101 | } |
| 91 | /* | 102 | |
| 92 | * TODO | 103 | /** |
| 104 | * @method getMaxColor | ||
| 105 | * @brief Get maximum values for RGB pixel | ||
| 106 | * @param pixel reference to pixel struct | ||
| 107 | * @return - | ||
| 108 | * @globalvars none | ||
| 109 | * @exception none | ||
| 110 | * @conditions none | ||
| 93 | */ | 111 | */ |
| 94 | void getMaxColor(unsigned int *red, unsigned int *green, unsigned int *blue) | 112 | void getMaxColor(RGBPIXEL& pixel) |
| 95 | { | 113 | { |
| 96 | *red = *green = *blue = 255; /* 2^8 - 1 */ | 114 | /* value = 2^8 - 1 */ |
| 115 | pixel.red = pixel.green = pixel.blue = 255; | ||
| 97 | } | 116 | } |
| 98 | }; | 117 | }; |
| 99 | 118 | ||
diff --git a/ue2/imgsynth2/cpixmap.cpp b/ue2/imgsynth2/cpixmap.cpp index 91419b6..6f8c8d6 100644 --- a/ue2/imgsynth2/cpixmap.cpp +++ b/ue2/imgsynth2/cpixmap.cpp | |||
| @@ -29,30 +29,27 @@ CPixmap::CPixmap() | |||
| 29 | 29 | ||
| 30 | /* add our handlers */ | 30 | /* add our handlers */ |
| 31 | m_handlers.insert(new CPixelFormat_Indexed8(this)); | 31 | m_handlers.insert(new CPixelFormat_Indexed8(this)); |
| 32 | |||
| 33 | } | 32 | } |
| 34 | 33 | ||
| 35 | |||
| 36 | |||
| 37 | /*----------------------------------------------------------------------------*/ | 34 | /*----------------------------------------------------------------------------*/ |
| 38 | 35 | ||
| 39 | void CPixmap::read(std::ifstream& in) | 36 | void CPixmap::read(std::ifstream& in) |
| 40 | { | 37 | { |
| 41 | 38 | ||
| 42 | string str; | 39 | string str; |
| 43 | m_fileheader._XPMEXT = false; | 40 | m_fileheader._XPMEXT = false; |
| 44 | m_fileheader._HOTSPOT = false; | 41 | m_fileheader._HOTSPOT = false; |
| 45 | 42 | ||
| 46 | /* parse the values section */ | 43 | /* parse the values section */ |
| 47 | getline( in, str, '"'); | 44 | getline( in, str, '"'); |
| 48 | getline( in, str, '"'); | 45 | getline( in, str, '"'); |
| 49 | stringstream istr (str ); | 46 | stringstream istr (str ); |
| 50 | 47 | ||
| 51 | istr >> m_fileheader.xpmWidth ; | 48 | istr >> m_fileheader.xpmWidth ; |
| 52 | istr >> m_fileheader.xpmHeight ; | 49 | istr >> m_fileheader.xpmHeight ; |
| 53 | istr >> m_fileheader.nColor ; | 50 | istr >> m_fileheader.nColor ; |
| 54 | istr >> m_fileheader.nChar ; | 51 | istr >> m_fileheader.nChar ; |
| 55 | 52 | ||
| 56 | /*optional values */ | 53 | /*optional values */ |
| 57 | if (istr.good()) | 54 | if (istr.good()) |
| 58 | { | 55 | { |
| @@ -63,8 +60,7 @@ void CPixmap::read(std::ifstream& in) | |||
| 63 | else | 60 | else |
| 64 | { | 61 | { |
| 65 | m_fileheader._HOTSPOT = true; | 62 | m_fileheader._HOTSPOT = true; |
| 66 | m_fileheader.xHotspot = | 63 | m_fileheader.xHotspot = static_cast<unsigned int>(strtoul(tmp.c_str(), NULL, 16)); |
| 67 | static_cast<unsigned int>(strtoul(tmp.c_str(), NULL, 16)); | ||
| 68 | istr >> m_fileheader.yHotspot; | 64 | istr >> m_fileheader.yHotspot; |
| 69 | } | 65 | } |
| 70 | if (istr.good()) | 66 | if (istr.good()) |
| @@ -74,9 +70,9 @@ void CPixmap::read(std::ifstream& in) | |||
| 74 | m_fileheader._XPMEXT = true; | 70 | m_fileheader._XPMEXT = true; |
| 75 | } | 71 | } |
| 76 | } | 72 | } |
| 77 | 73 | ||
| 78 | 74 | ||
| 79 | 75 | ||
| 80 | /* parse color table*/ | 76 | /* parse color table*/ |
| 81 | getline( in, str, '"'); | 77 | getline( in, str, '"'); |
| 82 | string character, mode, colors; | 78 | string character, mode, colors; |
| @@ -84,16 +80,16 @@ void CPixmap::read(std::ifstream& in) | |||
| 84 | { | 80 | { |
| 85 | getline( in, str, '"' ); | 81 | getline( in, str, '"' ); |
| 86 | stringstream istr2 (str ); | 82 | stringstream istr2 (str ); |
| 87 | 83 | ||
| 88 | istr2 >> character; | 84 | istr2 >> character; |
| 89 | istr2 >> mode; | 85 | istr2 >> mode; |
| 90 | istr2 >> colors; | 86 | istr2 >> colors; |
| 91 | 87 | ||
| 92 | if ( colors.size() != 7) | 88 | if ( colors.size() != 7) |
| 93 | throw FileError("Pixmap color tabel is invalid."); | 89 | throw FileError("Pixmap color tabel is invalid."); |
| 94 | if ( colors.at(0) != '#') | 90 | if ( colors.at(0) != '#') |
| 95 | throw FileError("Pixmap color tabel value is not hexadecimal."); | 91 | throw FileError("Pixmap color tabel value is not hexadecimal."); |
| 96 | 92 | ||
| 97 | xpmColors[character][mode] = new (nothrow) unsigned int[3]; | 93 | xpmColors[character][mode] = new (nothrow) unsigned int[3]; |
| 98 | if (xpmColors[character][mode] == 0) | 94 | if (xpmColors[character][mode] == 0) |
| 99 | throw FileError("Bad color table allocation."); | 95 | throw FileError("Bad color table allocation."); |
| @@ -144,7 +140,8 @@ void CPixmap::read(std::ifstream& in) | |||
| 144 | for (it = m_handlers.begin(); it != m_handlers.end(); it++) | 140 | for (it = m_handlers.begin(); it != m_handlers.end(); it++) |
| 145 | { | 141 | { |
| 146 | /* check color mode */ | 142 | /* check color mode */ |
| 147 | if (mode.compare((*it)->getColorMode()) == 0) | 143 | //TODO if (mode.compare((*it)->getColorMode()) == 0) |
| 144 | if (mode == "c") | ||
| 148 | { | 145 | { |
| 149 | m_pixelformat = *it; | 146 | m_pixelformat = *it; |
| 150 | break; | 147 | break; |
diff --git a/ue2/imgsynth2/cpixmap.h b/ue2/imgsynth2/cpixmap.h index 863cbd4..eb219aa 100644 --- a/ue2/imgsynth2/cpixmap.h +++ b/ue2/imgsynth2/cpixmap.h | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | #include <stdint.h> | 11 | #include <stdint.h> |
| 12 | #include "cbitmap.h" | 12 | #include "cbitmap.h" |
| 13 | 13 | ||
| 14 | |||
| 15 | /** | 14 | /** |
| 16 | * @class CPixmap | 15 | * @class CPixmap |
| 17 | * @brief Implementation of CFile handling Pixmap file format. | 16 | * @brief Implementation of CFile handling Pixmap file format. |
| @@ -48,7 +47,7 @@ class CPixmap : public CBitmap | |||
| 48 | ~CPixmap() | 47 | ~CPixmap() |
| 49 | {} | 48 | {} |
| 50 | 49 | ||
| 51 | /** | 50 | /** |
| 52 | * @method read | 51 | * @method read |
| 53 | * @brief Reads Pixmap from filestream. | 52 | * @brief Reads Pixmap from filestream. |
| 54 | * On error an exception is thrown. | 53 | * On error an exception is thrown. |
| @@ -71,8 +70,8 @@ class CPixmap : public CBitmap | |||
| 71 | * @exception bad_alloc | 70 | * @exception bad_alloc |
| 72 | * @conditions none | 71 | * @conditions none |
| 73 | */ | 72 | */ |
| 74 | |||
| 75 | void write(std::ofstream& out, std::string& filename); | 73 | void write(std::ofstream& out, std::string& filename); |
| 74 | |||
| 76 | #ifdef DEBUG | 75 | #ifdef DEBUG |
| 77 | /** | 76 | /** |
| 78 | * @method dump | 77 | * @method dump |
| @@ -86,8 +85,6 @@ class CPixmap : public CBitmap | |||
| 86 | void dump(std::ostream& out); | 85 | void dump(std::ostream& out); |
| 87 | #endif | 86 | #endif |
| 88 | 87 | ||
| 89 | |||
| 90 | |||
| 91 | /** | 88 | /** |
| 92 | * @brief Pixmap Header structure | 89 | * @brief Pixmap Header structure |
| 93 | */ | 90 | */ |
| @@ -112,45 +109,56 @@ class CPixmap : public CBitmap | |||
| 112 | bool _XPMEXT; | 109 | bool _XPMEXT; |
| 113 | /* unchanged extension */ | 110 | /* unchanged extension */ |
| 114 | std::string extension; | 111 | std::string extension; |
| 115 | |||
| 116 | } PIXMAP_FILEHEADER; | 112 | } PIXMAP_FILEHEADER; |
| 117 | #pragma pack(pop) | 113 | #pragma pack(pop) |
| 118 | 114 | ||
| 119 | 115 | /* TODO */ | |
| 120 | const uint32_t getPixelDataSize() | 116 | const uint32_t getPixelDataSize() |
| 121 | { | 117 | { |
| 122 | return m_fileheader.xpmWidth * | 118 | return m_fileheader.xpmWidth * m_fileheader.xpmHeight * m_fileheader.nChar; |
| 123 | m_fileheader.xpmHeight * | ||
| 124 | m_fileheader.nChar; | ||
| 125 | } | 119 | } |
| 126 | 120 | ||
| 127 | 121 | /* TODO */ | |
| 128 | const uint32_t getHeight() | 122 | const uint32_t getHeight() |
| 129 | { | 123 | { |
| 130 | /* width and height can be negativ */ | 124 | /* width and height can be negativ */ |
| 131 | return m_fileheader.xpmHeight; | 125 | return m_fileheader.xpmHeight; |
| 132 | } | 126 | } |
| 133 | 127 | ||
| 128 | /* TODO */ | ||
| 134 | const uint32_t getWidth() | 129 | const uint32_t getWidth() |
| 135 | { | 130 | { |
| 136 | /* width and height can be negativ */ | 131 | /* width and height can be negativ */ |
| 137 | return m_fileheader.xpmWidth; | 132 | return m_fileheader.xpmWidth; |
| 138 | } | 133 | } |
| 139 | 134 | ||
| 135 | /** | ||
| 136 | * @method hasColorTable | ||
| 137 | * @brief Check if bitmap has a colortable | ||
| 138 | * (we don't support this yet for windows bitmaps) | ||
| 139 | * @param - | ||
| 140 | * @return true if bitmap has a colortable. false otherwise | ||
| 141 | * @globalvars none | ||
| 142 | * @exception none | ||
| 143 | * @conditions none | ||
| 144 | */ | ||
| 145 | const bool hasColorTable() | ||
| 146 | { | ||
| 147 | return true; | ||
| 148 | } | ||
| 140 | 149 | ||
| 150 | /* TODO */ | ||
| 141 | const bool isMirrored() | 151 | const bool isMirrored() |
| 142 | { | 152 | { |
| 143 | /* pixmap is never mirrored */ | 153 | /* pixmap is never mirrored */ |
| 144 | return false; | 154 | return false; |
| 145 | } | 155 | } |
| 146 | 156 | ||
| 147 | protected: | 157 | protected: |
| 148 | /* members */ | 158 | /* members */ |
| 149 | /** fileheader */ | 159 | /** fileheader */ |
| 150 | PIXMAP_FILEHEADER m_fileheader; | 160 | PIXMAP_FILEHEADER m_fileheader; |
| 151 | /** infoheader */ | 161 | /** infoheader */ |
| 152 | |||
| 153 | |||
| 154 | }; | 162 | }; |
| 155 | 163 | ||
| 156 | #endif | 164 | #endif |
diff --git a/ue2/imgsynth2/cscriptparser.cpp b/ue2/imgsynth2/cscriptparser.cpp index 6b886a3..17ff5a4 100644 --- a/ue2/imgsynth2/cscriptparser.cpp +++ b/ue2/imgsynth2/cscriptparser.cpp | |||
| @@ -9,8 +9,8 @@ | |||
| 9 | #include <boost/tokenizer.hpp> | 9 | #include <boost/tokenizer.hpp> |
| 10 | #include <boost/algorithm/string.hpp> | 10 | #include <boost/algorithm/string.hpp> |
| 11 | #include "cscriptparser.h" | 11 | #include "cscriptparser.h" |
| 12 | #include "cpixmap.h" | ||
| 13 | #include "cwindowsbitmap.h" | 12 | #include "cwindowsbitmap.h" |
| 13 | #include "cpixmap.h" | ||
| 14 | 14 | ||
| 15 | using namespace std; | 15 | using namespace std; |
| 16 | using namespace boost; | 16 | using namespace boost; |
diff --git a/ue2/imgsynth2/cwindowsbitmap.h b/ue2/imgsynth2/cwindowsbitmap.h index 28ad010..9fb40db 100644 --- a/ue2/imgsynth2/cwindowsbitmap.h +++ b/ue2/imgsynth2/cwindowsbitmap.h | |||
| @@ -159,33 +159,80 @@ class CWindowsBitmap : public CBitmap | |||
| 159 | return m_infoheader; | 159 | return m_infoheader; |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | /* TODO */ | 162 | /** |
| 163 | * @method getPixelDataSize | ||
| 164 | * @brief Return size of pixelbuffer | ||
| 165 | * @param - | ||
| 166 | * @return size of pixelbuffer | ||
| 167 | * @globalvars none | ||
| 168 | * @exception none | ||
| 169 | * @conditions none | ||
| 170 | */ | ||
| 163 | const uint32_t getPixelDataSize() | 171 | const uint32_t getPixelDataSize() |
| 164 | { | 172 | { |
| 165 | return m_infoheader.biSizeImage; | 173 | return m_infoheader.biSizeImage; |
| 166 | } | 174 | } |
| 167 | 175 | ||
| 168 | /* TODO */ | 176 | /** |
| 177 | * @method getHeight | ||
| 178 | * @brief Return height of bitmap in pixel | ||
| 179 | * @param - | ||
| 180 | * @return height of bitmap in pixel | ||
| 181 | * @globalvars none | ||
| 182 | * @exception none | ||
| 183 | * @conditions none | ||
| 184 | */ | ||
| 169 | const uint32_t getHeight() | 185 | const uint32_t getHeight() |
| 170 | { | 186 | { |
| 171 | /* width and height can be negativ */ | 187 | /* width and height can be negativ */ |
| 172 | return static_cast<uint32_t>(abs(m_infoheader.biHeight)); | 188 | return static_cast<uint32_t>(abs(m_infoheader.biHeight)); |
| 173 | } | 189 | } |
| 174 | 190 | ||
| 175 | /* TODO */ | 191 | /** |
| 192 | * @method getWidth | ||
| 193 | * @brief Return width of bitmap in pixel | ||
| 194 | * @param - | ||
| 195 | * @return width of bitmap in pixel | ||
| 196 | * @globalvars none | ||
| 197 | * @exception none | ||
| 198 | * @conditions none | ||
| 199 | */ | ||
| 176 | const uint32_t getWidth() | 200 | const uint32_t getWidth() |
| 177 | { | 201 | { |
| 178 | /* width and height can be negativ */ | 202 | /* width and height can be negativ */ |
| 179 | return static_cast<uint32_t>(abs(m_infoheader.biWidth)); | 203 | return static_cast<uint32_t>(abs(m_infoheader.biWidth)); |
| 180 | } | 204 | } |
| 181 | 205 | ||
| 182 | /* TODO */ | 206 | /** |
| 207 | * @method isMirrored | ||
| 208 | * @brief Windows Bitmaps can be stored upside down | ||
| 209 | * @param - | ||
| 210 | * @return true if bitmap is stored upside down. false otherwise | ||
| 211 | * @globalvars none | ||
| 212 | * @exception none | ||
| 213 | * @conditions none | ||
| 214 | */ | ||
| 183 | const bool isMirrored() | 215 | const bool isMirrored() |
| 184 | { | 216 | { |
| 185 | /* if height is positive the y-coordinates are mirrored */ | 217 | /* if height is positive the y-coordinates are mirrored */ |
| 186 | return (m_infoheader.biHeight > 0) ? true : false; | 218 | return (m_infoheader.biHeight > 0) ? true : false; |
| 187 | } | 219 | } |
| 188 | 220 | ||
| 221 | /** | ||
| 222 | * @method hasColorTable | ||
| 223 | * @brief Check if bitmap has a colortable | ||
| 224 | * (we don't support this yet for windows bitmaps) | ||
| 225 | * @param - | ||
| 226 | * @return true if bitmap has a colortable. false otherwise | ||
| 227 | * @globalvars none | ||
| 228 | * @exception none | ||
| 229 | * @conditions none | ||
| 230 | */ | ||
| 231 | const bool hasColorTable() | ||
| 232 | { | ||
| 233 | return false; | ||
| 234 | } | ||
| 235 | |||
| 189 | protected: | 236 | protected: |
| 190 | /* members */ | 237 | /* members */ |
| 191 | /** fileheader */ | 238 | /** fileheader */ |
diff --git a/ue2/imgsynth2/test/input_yellow_man2_rgb24 b/ue2/imgsynth2/test/input_yellow_man2_rgb24 index 37108b8..7c3253c 100644 --- a/ue2/imgsynth2/test/input_yellow_man2_rgb24 +++ b/ue2/imgsynth2/test/input_yellow_man2_rgb24 | |||
| @@ -5,9 +5,9 @@ | |||
| 5 | read(BMP, test/yellow_man2_rgb24_in.bmp) | 5 | read(BMP, test/yellow_man2_rgb24_in.bmp) |
| 6 | 6 | ||
| 7 | fillrect(0,3,6,5,0,255,0) | 7 | fillrect(0,3,6,5,0,255,0) |
| 8 | fillrect(2,13,6,4,0,0,255) | 8 | fillrect(2,13,7,4,0,0,255) |
| 9 | mirror_x() | 9 | mirror_x() |
| 10 | mirror_y() | 10 | mirror_y() |
| 11 | #invert() | 11 | invert() |
| 12 | 12 | ||
| 13 | write(BMP, "test/yellow_man2_rgb24_out.bmp") | 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 index 3c00301..0fdcbc4 100644 --- a/ue2/imgsynth2/test/input_yellow_man2_rgb555 +++ b/ue2/imgsynth2/test/input_yellow_man2_rgb555 | |||
| @@ -4,10 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | read(BMP, test/yellow_man2_rgb555_in.bmp) | 5 | read(BMP, test/yellow_man2_rgb555_in.bmp) |
| 6 | 6 | ||
| 7 | fillrect(0,3,6,5,0,24,0) | 7 | fillrect(0,3,6,5,0,31,0) |
| 8 | fillrect(2,13,7,4,0,0,24) | 8 | fillrect(2,13,7,4,0,0,31) |
| 9 | mirror_x() | 9 | mirror_x() |
| 10 | mirror_y() | 10 | mirror_y() |
| 11 | #invert() | 11 | invert() |
| 12 | 12 | ||
| 13 | write(BMP, "test/yellow_man2_rgb555_out.bmp") | 13 | write(BMP, "test/yellow_man2_rgb555_out.bmp") |
diff --git a/ue2/imgsynth2/test/yellow_man1_rgb24_out.bmp b/ue2/imgsynth2/test/yellow_man1_rgb24_out.bmp deleted file mode 100644 index 340eab9..0000000 --- a/ue2/imgsynth2/test/yellow_man1_rgb24_out.bmp +++ /dev/null | |||
| Binary files differ | |||
diff --git a/ue2/imgsynth2/test/yellow_man1_rgb555_out.bmp b/ue2/imgsynth2/test/yellow_man1_rgb555_out.bmp deleted file mode 100644 index 1c35ab5..0000000 --- a/ue2/imgsynth2/test/yellow_man1_rgb555_out.bmp +++ /dev/null | |||
| Binary files differ | |||
diff --git a/ue2/imgsynth2/test/yellow_man2_rgb24_out.bmp b/ue2/imgsynth2/test/yellow_man2_rgb24_out.bmp deleted file mode 100644 index c859cda..0000000 --- a/ue2/imgsynth2/test/yellow_man2_rgb24_out.bmp +++ /dev/null | |||
| Binary files differ | |||
diff --git a/ue2/imgsynth2/test/yellow_man2_rgb555_out.bmp b/ue2/imgsynth2/test/yellow_man2_rgb555_out.bmp deleted file mode 100644 index 60588e3..0000000 --- a/ue2/imgsynth2/test/yellow_man2_rgb555_out.bmp +++ /dev/null | |||
| Binary files differ | |||
