summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormanuel <manuel@nc8430.lan>2009-05-02 16:44:53 +0200
committermanuel <manuel@nc8430.lan>2009-05-02 16:44:53 +0200
commitbcadfa267f976fe9f29afa50a635cbe3ea174e38 (patch)
treeb069a34c9d100dcc9229311b47cbfa0697ee7fc9
parentbca08c6de2b156cbec90944c809e5e7faecd231d (diff)
downloadooprog-bcadfa267f976fe9f29afa50a635cbe3ea174e38.tar.gz
ooprog-bcadfa267f976fe9f29afa50a635cbe3ea174e38.tar.bz2
ooprog-bcadfa267f976fe9f29afa50a635cbe3ea174e38.zip
- colortable now uses uint32_t as identifier
- rewrote xpm colortable parsing to convert their identifiers to our own and vica vi - implemented indexed8::setpixel/getpixel - moved rowsize to member variable in cbitmap - added second test for xpm/indexed8
-rw-r--r--ue2/imgsynth2/cbitmap.cpp41
-rw-r--r--ue2/imgsynth2/cbitmap.h34
-rw-r--r--ue2/imgsynth2/cpixelformat_bgr24.cpp14
-rw-r--r--ue2/imgsynth2/cpixelformat_bgr555.cpp14
-rw-r--r--ue2/imgsynth2/cpixelformat_indexed8.cpp88
-rw-r--r--ue2/imgsynth2/cpixelformat_indexed8.h8
-rw-r--r--ue2/imgsynth2/cpixmap.cpp125
-rw-r--r--ue2/imgsynth2/cpixmap.h85
-rw-r--r--ue2/imgsynth2/cwindowsbitmap.cpp5
-rw-r--r--ue2/imgsynth2/test/input_yellow_man1_indexed84
-rw-r--r--ue2/imgsynth2/test/input_yellow_man2_indexed813
-rw-r--r--ue2/imgsynth2/test/yellow_man1_indexed8_ref.xpm27
-rw-r--r--ue2/imgsynth2/test/yellow_man2_indexed8_in.xpm27
-rw-r--r--ue2/imgsynth2/test/yellow_man2_indexed8_ref.xpm29
14 files changed, 345 insertions, 169 deletions
diff --git a/ue2/imgsynth2/cbitmap.cpp b/ue2/imgsynth2/cbitmap.cpp
index 2e135db..3d206f5 100644
--- a/ue2/imgsynth2/cbitmap.cpp
+++ b/ue2/imgsynth2/cbitmap.cpp
@@ -28,7 +28,8 @@ CBitmap::~CBitmap()
28 m_pixelformat = NULL; 28 m_pixelformat = NULL;
29 29
30 /* delete colortable content */ 30 /* delete colortable content */
31 map<string, CPixelFormat::RGBPIXEL *>::iterator it2; 31 //map<string, CPixelFormat::RGBPIXEL *>::iterator it2;
32 map<uint32_t, CPixelFormat::RGBPIXEL *>::iterator it2;
32 for(it2 = m_colortable.begin(); it2 != m_colortable.end(); it2++) 33 for(it2 = m_colortable.begin(); it2 != m_colortable.end(); it2++)
33 delete (*it2).second; 34 delete (*it2).second;
34} 35}
@@ -144,7 +145,7 @@ void CBitmap::invert(std::list<std::string> params)
144 if (hasColorTable()) 145 if (hasColorTable())
145 { 146 {
146 /* invert every entry in the colortable */ 147 /* invert every entry in the colortable */
147 map<string, CPixelFormat::RGBPIXEL *>::iterator it; 148 map<uint32_t, CPixelFormat::RGBPIXEL *>::iterator it;
148 for (it = m_colortable.begin(); it != m_colortable.end(); it++) 149 for (it = m_colortable.begin(); it != m_colortable.end(); it++)
149 { 150 {
150 (*it).second->red = max.red - (*it).second->red; 151 (*it).second->red = max.red - (*it).second->red;
@@ -212,8 +213,8 @@ void CBitmap::brightness(std::list<std::string> params)
212 m_pixelformat->getMaxColor(max); 213 m_pixelformat->getMaxColor(max);
213 if (hasColorTable()) 214 if (hasColorTable())
214 { 215 {
215 /* invert every entry in the colortable */ 216 /* change every entry in the colortable */
216 map<string, CPixelFormat::RGBPIXEL *>::iterator it; 217 map<uint32_t, CPixelFormat::RGBPIXEL *>::iterator it;
217 for (it = m_colortable.begin(); it != m_colortable.end(); it++) 218 for (it = m_colortable.begin(); it != m_colortable.end(); it++)
218 { 219 {
219 (*it).second->red = min(max.red, static_cast<uint32_t>((*it).second->red * factor)); 220 (*it).second->red = min(max.red, static_cast<uint32_t>((*it).second->red * factor));
@@ -223,7 +224,7 @@ void CBitmap::brightness(std::list<std::string> params)
223 } 224 }
224 else 225 else
225 { 226 {
226 /* invert per pixel */ 227 /* change per pixel */
227 for(uint32_t y = 0; y < getHeight(); y++) 228 for(uint32_t y = 0; y < getHeight(); y++)
228 { 229 {
229 for(uint32_t x = 0; x < getWidth(); x++) 230 for(uint32_t x = 0; x < getWidth(); x++)
@@ -260,27 +261,22 @@ void CBitmap::mirror_y(std::list<std::string> params)
260 if (m_pixeldata == NULL || m_pixelformat == NULL) 261 if (m_pixeldata == NULL || m_pixelformat == NULL)
261 return; 262 return;
262 263
263 /* calc rowsize - boundary is 32 */ 264 uint8_t *buf = new uint8_t[m_rowsize];
264 uint32_t rowsize = 4 * static_cast<uint32_t>(
265 ((m_pixelformat->getBitCount() * getWidth()) + 31) / 32
266 );
267
268 uint8_t *buf = new uint8_t[rowsize];
269 for(uint32_t i = 0; i < getHeight()/2; i++) 265 for(uint32_t i = 0; i < getHeight()/2; i++)
270 { 266 {
271 uint32_t j = getHeight() - i - 1; 267 uint32_t j = getHeight() - i - 1;
272 uint32_t offset = i * rowsize; 268 uint32_t offset = i * m_rowsize;
273 uint32_t backset = j * rowsize; 269 uint32_t backset = j * m_rowsize;
274 270
275 /* boundary check */ 271 /* boundary check */
276 if (offset + rowsize > getPixelDataSize() 272 if (offset + m_rowsize > getPixelDataSize()
277 || backset + rowsize > getPixelDataSize()) 273 || backset + m_rowsize > getPixelDataSize())
278 throw FileError("Mirrored pixel position is out of range."); 274 throw FileError("Mirrored pixel position is out of range.");
279 275
280 /* mirroring, backup lower data first */ 276 /* mirroring, backup lower data first */
281 copy(m_pixeldata + backset, m_pixeldata + backset + rowsize, buf); 277 copy(m_pixeldata + backset, m_pixeldata + backset + m_rowsize, buf);
282 copy(m_pixeldata + offset, m_pixeldata + offset + rowsize, m_pixeldata + backset); 278 copy(m_pixeldata + offset, m_pixeldata + offset + m_rowsize, m_pixeldata + backset);
283 copy(buf, buf + rowsize, m_pixeldata + offset); 279 copy(buf, buf + m_rowsize, m_pixeldata + offset);
284 } 280 }
285 delete[] buf; 281 delete[] buf;
286} 282}
@@ -297,18 +293,13 @@ void CBitmap::mirror_x(std::list<std::string> params)
297 if (m_pixeldata == NULL || m_pixelformat == NULL) 293 if (m_pixeldata == NULL || m_pixelformat == NULL)
298 return; 294 return;
299 295
300 /* calc rowsize - boundary is 32 */
301 uint32_t rowsize = 4 * static_cast<uint32_t>(
302 ((m_pixelformat->getBitCount() * getWidth()) + 31) / 32
303 );
304
305 /* calc pixelwidth */ 296 /* calc pixelwidth */
306 unsigned int pixelwidth = m_pixelformat->getBitCount()/8; 297 unsigned int pixelwidth = (hasColorTable()) ? sizeof(uint32_t) : m_pixelformat->getBitCount()/8;
307 298
308 uint8_t *buf = new uint8_t[pixelwidth]; 299 uint8_t *buf = new uint8_t[pixelwidth];
309 for(uint32_t i = 0; i < getHeight(); i++) 300 for(uint32_t i = 0; i < getHeight(); i++)
310 { 301 {
311 uint32_t offset = i * rowsize; 302 uint32_t offset = i * m_rowsize;
312 303
313 for(uint32_t j = 0; j <= getWidth()/2; j++) 304 for(uint32_t j = 0; j <= getWidth()/2; j++)
314 { 305 {
diff --git a/ue2/imgsynth2/cbitmap.h b/ue2/imgsynth2/cbitmap.h
index f48ada7..785e2f1 100644
--- a/ue2/imgsynth2/cbitmap.h
+++ b/ue2/imgsynth2/cbitmap.h
@@ -36,7 +36,7 @@ class CBitmap : public CFile
36 * @conditions none 36 * @conditions none
37 */ 37 */
38 CBitmap() 38 CBitmap()
39 : m_pixeldata(NULL), m_pixelformat(NULL) 39 : m_pixeldata(NULL), m_pixelformat(NULL), m_rowsize(0)
40 {} 40 {}
41 41
42 42
@@ -91,6 +91,34 @@ class CBitmap : public CFile
91 } 91 }
92 92
93 /** 93 /**
94 * @method getColorTable
95 * @brief Returns reference to colortable
96 * @param -
97 * @return reference to colortable
98 * @globalvars none
99 * @exception none
100 * @conditions none
101 */
102 std::map<uint32_t, CPixelFormat::RGBPIXEL *>& getColorTable()
103 {
104 return m_colortable;
105 }
106
107 /**
108 * @method getRowSize
109 * @brief Returns number of bytes of one row
110 * @param -
111 * @return number of bytes of one row
112 * @globalvars none
113 * @exception none
114 * @conditions none
115 */
116 uint32_t getRowSize()
117 {
118 return m_rowsize;
119 }
120
121 /**
94 * @method getPixelDataSize 122 * @method getPixelDataSize
95 * @brief Return size of pixelbuffer 123 * @brief Return size of pixelbuffer
96 * @param - 124 * @param -
@@ -230,11 +258,13 @@ class CBitmap : public CFile
230 /** pointer to pixelbuffer */ 258 /** pointer to pixelbuffer */
231 uint8_t *m_pixeldata; 259 uint8_t *m_pixeldata;
232 /** colortable map */ 260 /** colortable map */
233 std::map<std::string, CPixelFormat::RGBPIXEL *> m_colortable; 261 std::map<uint32_t, CPixelFormat::RGBPIXEL *> m_colortable;
234 /** set of supported PixelFormat handlers */ 262 /** set of supported PixelFormat handlers */
235 std::set<CPixelFormat *> m_handlers; 263 std::set<CPixelFormat *> m_handlers;
236 /** pointer to CPixelFormat implementation */ 264 /** pointer to CPixelFormat implementation */
237 CPixelFormat *m_pixelformat; 265 CPixelFormat *m_pixelformat;
266 /** number of bytes of one row in the image */
267 uint32_t m_rowsize;
238}; 268};
239 269
240#endif 270#endif
diff --git a/ue2/imgsynth2/cpixelformat_bgr24.cpp b/ue2/imgsynth2/cpixelformat_bgr24.cpp
index e7476d7..bc95ab9 100644
--- a/ue2/imgsynth2/cpixelformat_bgr24.cpp
+++ b/ue2/imgsynth2/cpixelformat_bgr24.cpp
@@ -16,15 +16,10 @@ void CPixelFormat_BGR24::getPixel(RGBPIXEL& pixel, uint32_t x, uint32_t y)
16 if (m_bitmap->getPixelData() == NULL) 16 if (m_bitmap->getPixelData() == NULL)
17 throw PixelFormatError("No pixelbuffer allocated."); 17 throw PixelFormatError("No pixelbuffer allocated.");
18 18
19 /* calc rowsize - boundary is 32 */
20 uint32_t rowsize = 4 * static_cast<uint32_t>(
21 ((getBitCount() * m_bitmap->getWidth()) + 31) / 32
22 );
23
24 /* if the y-coordinates are mirrored */ 19 /* if the y-coordinates are mirrored */
25 if (m_bitmap->isMirrored()) 20 if (m_bitmap->isMirrored())
26 y = m_bitmap->getHeight() - y - 1; 21 y = m_bitmap->getHeight() - y - 1;
27 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); 22 uint32_t offset = y * m_bitmap->getRowSize() + x * (4 * getBitCount() / 32);
28 23
29 /* boundary check */ 24 /* boundary check */
30 if (offset + getBitCount()/8 > m_bitmap->getPixelDataSize()) 25 if (offset + getBitCount()/8 > m_bitmap->getPixelDataSize())
@@ -43,15 +38,10 @@ void CPixelFormat_BGR24::setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t y)
43 if (m_bitmap->getPixelData() == NULL) 38 if (m_bitmap->getPixelData() == NULL)
44 throw PixelFormatError("No pixelbuffer allocated."); 39 throw PixelFormatError("No pixelbuffer allocated.");
45 40
46 /* calc rowsize - boundary is 32 */
47 uint32_t rowsize = 4 * static_cast<uint32_t>(
48 ((getBitCount() * m_bitmap->getWidth()) + 31) / 32
49 );
50
51 /* if the y-coordinates are mirrored */ 41 /* if the y-coordinates are mirrored */
52 if (m_bitmap->isMirrored()) 42 if (m_bitmap->isMirrored())
53 y = m_bitmap->getHeight() - y - 1; 43 y = m_bitmap->getHeight() - y - 1;
54 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); 44 uint32_t offset = y * m_bitmap->getRowSize() + x * (4 * getBitCount() / 32);
55 45
56 /* boundary check */ 46 /* boundary check */
57 if (offset + getBitCount()/8 > m_bitmap->getPixelDataSize()) 47 if (offset + getBitCount()/8 > m_bitmap->getPixelDataSize())
diff --git a/ue2/imgsynth2/cpixelformat_bgr555.cpp b/ue2/imgsynth2/cpixelformat_bgr555.cpp
index 2f98cc7..657c148 100644
--- a/ue2/imgsynth2/cpixelformat_bgr555.cpp
+++ b/ue2/imgsynth2/cpixelformat_bgr555.cpp
@@ -17,15 +17,10 @@ void CPixelFormat_BGR555::getPixel(RGBPIXEL& pixel, uint32_t x, uint32_t y)
17 if (m_bitmap->getPixelData() == NULL) 17 if (m_bitmap->getPixelData() == NULL)
18 throw PixelFormatError("No pixelbuffer allocated."); 18 throw PixelFormatError("No pixelbuffer allocated.");
19 19
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 */ 20 /* if the y-coordinates are mirrored */
26 if (m_bitmap->isMirrored()) 21 if (m_bitmap->isMirrored())
27 y = m_bitmap->getHeight() - y - 1; 22 y = m_bitmap->getHeight() - y - 1;
28 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); 23 uint32_t offset = y * m_bitmap->getRowSize() + x * (4 * getBitCount() / 32);
29 24
30 /* boundary check */ 25 /* boundary check */
31 if (offset + getBitCount()/8 > m_bitmap->getPixelDataSize()) 26 if (offset + getBitCount()/8 > m_bitmap->getPixelDataSize())
@@ -45,15 +40,10 @@ void CPixelFormat_BGR555::setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t y
45 if (m_bitmap->getPixelData() == NULL) 40 if (m_bitmap->getPixelData() == NULL)
46 throw PixelFormatError("No pixelbuffer allocated."); 41 throw PixelFormatError("No pixelbuffer allocated.");
47 42
48 /* calc rowsize - boundary is 32 */
49 uint32_t rowsize = 4 * static_cast<uint32_t>(
50 ((getBitCount() * m_bitmap->getWidth()) + 31) / 32
51 );
52
53 /* if the y-coordinates are mirrored */ 43 /* if the y-coordinates are mirrored */
54 if (m_bitmap->isMirrored()) 44 if (m_bitmap->isMirrored())
55 y = m_bitmap->getHeight() - y - 1; 45 y = m_bitmap->getHeight() - y - 1;
56 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); 46 uint32_t offset = y * m_bitmap->getRowSize() + x * (4 * getBitCount() / 32);
57 47
58 /* boundary check */ 48 /* boundary check */
59 if (offset + getBitCount()/8 > m_bitmap->getPixelDataSize()) 49 if (offset + getBitCount()/8 > m_bitmap->getPixelDataSize())
diff --git a/ue2/imgsynth2/cpixelformat_indexed8.cpp b/ue2/imgsynth2/cpixelformat_indexed8.cpp
index 6453fad..21b0988 100644
--- a/ue2/imgsynth2/cpixelformat_indexed8.cpp
+++ b/ue2/imgsynth2/cpixelformat_indexed8.cpp
@@ -1,8 +1,8 @@
1/** 1/**
2 * @module CPixelFormat_Indexed8 2 * @module CPixelFormat_Indexed8
3 * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) 3 * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348)
4 * @brief Implementation of CPixelFormat handling 24bit color Windows Bitmaps TODO. 4 * @brief Implementation of CPixelFormat handling 24bit indexed bitmaps.
5 * @date 18.04.2009 5 * @date 02.05.2009
6 */ 6 */
7 7
8#include <boost/numeric/conversion/cast.hpp> 8#include <boost/numeric/conversion/cast.hpp>
@@ -12,73 +12,67 @@ using namespace std;
12 12
13void CPixelFormat_Indexed8::getPixel(RGBPIXEL& pixel, uint32_t x, uint32_t y) 13void CPixelFormat_Indexed8::getPixel(RGBPIXEL& pixel, uint32_t x, uint32_t y)
14{ 14{
15#if 0
16 if (m_bitmap->getPixelData() == NULL) 15 if (m_bitmap->getPixelData() == NULL)
17 throw PixelFormatError("No pixelbuffer allocated."); 16 throw PixelFormatError("No pixelbuffer allocated.");
17 if (m_bitmap->getColorTable().size() == 0)
18 return;
18 19
19 /* calc rowsize - boundary is 32 */ 20 uint32_t offset = y * m_bitmap->getWidth() + x;
20 uint32_t rowsize = 4 * static_cast<uint32_t>(
21 ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32
22 );*/
23
24 /* if height is positive the y-coordinates are mirrored */
25 if (m_bitmap->getInfoHeader().biHeight > 0)
26 y = m_bitmap->getInfoHeader().biHeight - y - 1;
27 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32);
28 21
29 /* boundary check */ 22 /* boundary check */
30 if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) 23 if (offset * sizeof(uint32_t) + sizeof(uint32_t) > m_bitmap->getPixelDataSize())
31 throw PixelFormatError("Pixel position is out of range."); 24 throw PixelFormatError("Pixel position is out of range.");
32 25
33 /* get pixel */ 26 uint32_t color = *((uint32_t *)m_bitmap->getPixelData() + offset);
34 try 27
35 { 28 map<uint32_t, RGBPIXEL *>::iterator it;
36 pixel[0] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset + 2)); 29 if ((it = m_bitmap->getColorTable().find(color)) == m_bitmap->getColorTable().end())
37 pixel[1] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset + 1)); 30 throw PixelFormatError("Pixel has no reference in colortable.");
38 pixel[2] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset)); 31
39 } 32 pixel.red = (*it).second->red;
40 catch(boost::numeric::bad_numeric_cast& ex) 33 pixel.green = (*it).second->green;
41 { 34 pixel.blue = (*it).second->blue;
42 throw PixelFormatError("Unable to convert pixelcolor to correct size: " + string(ex.what()));
43 }
44#endif
45} 35}
46 36
37/*----------------------------------------------------------------------------*/
38
47void CPixelFormat_Indexed8::setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t y) 39void CPixelFormat_Indexed8::setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t y)
48{ 40{
49#if 0 41 if (m_bitmap->getPixelData() == NULL)
50 if (m_bitmap->getPixelData() == NULL)
51 throw PixelFormatError("No pixelbuffer allocated."); 42 throw PixelFormatError("No pixelbuffer allocated.");
43 if (m_bitmap->getColorTable().size() == 0)
44 return;
52 45
53 /* calc rowsize - boundary is 32 */ 46 uint32_t offset = y * m_bitmap->getWidth() + x;
54 uint32_t rowsize = 4 * static_cast<uint32_t>(
55 ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32
56 );
57
58 /* if height is positive the y-coordinates are mirrored */
59 if (m_bitmap->getInfoHeader().biHeight > 0)
60 y = m_bitmap->getInfoHeader().biHeight - y - 1;
61 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32);
62 47
63 /* boundary check */ 48 /* boundary check */
64 if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) 49 if (offset * sizeof(uint32_t) + sizeof(uint32_t) > m_bitmap->getPixelDataSize())
65 throw PixelFormatError("Pixel position is out of range."); 50 throw PixelFormatError("Pixel position is out of range.");
66 51
67 /* convert color values to correct types */ 52 /* try to look up color in colortable */
68 uint8_t data[3]; 53 map<uint32_t, RGBPIXEL *>::iterator it;
69 try 54 for(it = m_bitmap->getColorTable().begin(); it != m_bitmap->getColorTable().end(); it++)
70 { 55 {
71 data[0] = boost::numeric_cast<uint8_t>(pixel[2]); 56 if ((*it).second->red == pixel.red &&
72 data[1] = boost::numeric_cast<uint8_t>(pixel[1]); 57 (*it).second->green == pixel.green &&
73 data[2] = boost::numeric_cast<uint8_t>(pixel[0]); 58 (*it).second->blue == pixel.blue)
59 break;
74 } 60 }
75 catch(boost::numeric::bad_numeric_cast& ex) 61
62 uint32_t index = (*it).first;
63 /* need to get a new character for our color */
64 if (it == m_bitmap->getColorTable().end())
76 { 65 {
77 throw PixelFormatError("Unable to convert pixelcolor to correct size: " + string(ex.what())); 66 index = (*it).first + 1;
67 RGBPIXEL *pixelptr = new RGBPIXEL;
68 pixelptr->red = pixel.red;
69 pixelptr->green = pixel.green;
70 pixelptr->blue = pixel.blue;
71 m_bitmap->getColorTable()[ index ] = pixelptr;
78 } 72 }
79 73
80 copy(data, data + 3, m_bitmap->getPixelData() + offset); 74 /* set color */
81#endif 75 *((uint32_t *)m_bitmap->getPixelData() + offset) = index;
82} 76}
83 77
84/* vim: set et sw=2 ts=2: */ 78/* vim: set et sw=2 ts=2: */
diff --git a/ue2/imgsynth2/cpixelformat_indexed8.h b/ue2/imgsynth2/cpixelformat_indexed8.h
index f1bb0f0..331d423 100644
--- a/ue2/imgsynth2/cpixelformat_indexed8.h
+++ b/ue2/imgsynth2/cpixelformat_indexed8.h
@@ -1,8 +1,8 @@
1/** 1/**
2 * @module cpixelformat_bgr24 2 * @module cpixelformat_bgr24
3 * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) 3 * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348)
4 * @brief Implementation of CPixelFormat handling 24bit color Windows Bitmaps TODO. 4 * @brief Implementation of CPixelFormat handling 24bit indexed bitmaps.
5 * @date 18.04.2009 5 * @date 02.05.2009
6 */ 6 */
7 7
8#ifndef CPixelFormat_Indexed8_H 8#ifndef CPixelFormat_Indexed8_H
@@ -14,7 +14,7 @@
14 14
15/** 15/**
16 * @class CPixelFormat_Indexed8 16 * @class CPixelFormat_Indexed8
17 * @brief Implementation of CPixelFormat handling 24bit color Windows Bitmaps TODO. 17 * @brief Implementation of CPixelFormat handling 24bit indexed bitmaps.
18 * 18 *
19 * On error CPixelFormat::PixelFormatError is thrown. 19 * On error CPixelFormat::PixelFormatError is thrown.
20 */ 20 */
@@ -83,7 +83,7 @@ class CPixelFormat_Indexed8 : public CPixelFormat
83 */ 83 */
84 uint32_t getBitCount() 84 uint32_t getBitCount()
85 { 85 {
86 return 8; 86 return 24;
87 } 87 }
88 88
89 /** 89 /**
diff --git a/ue2/imgsynth2/cpixmap.cpp b/ue2/imgsynth2/cpixmap.cpp
index 9e03d86..94f0310 100644
--- a/ue2/imgsynth2/cpixmap.cpp
+++ b/ue2/imgsynth2/cpixmap.cpp
@@ -49,9 +49,9 @@ std::string CPixmap::getLine(std::ifstream& in, bool ignore_comments)
49 49
50/*----------------------------------------------------------------------------*/ 50/*----------------------------------------------------------------------------*/
51 51
52std::string CPixmap::getArrayLine(std::ifstream& in, bool ignore_comments) 52std::string CPixmap::getCArrayLine(std::ifstream& in)
53{ 53{
54 string line = getLine(in, ignore_comments); 54 string line = getLine(in, true);
55 if (line.empty()) 55 if (line.empty())
56 return line; 56 return line;
57 57
@@ -87,6 +87,18 @@ void CPixmap::read(std::ifstream& in)
87 m_fileheader._XPMEXT = false; 87 m_fileheader._XPMEXT = false;
88 m_fileheader._HOTSPOT = false; 88 m_fileheader._HOTSPOT = false;
89 89
90 /* get pixelformat instance first */
91 m_pixelformat = NULL;
92 set<CPixelFormat *>::iterator it;
93 for (it = m_handlers.begin(); it != m_handlers.end(); it++)
94 {
95 /* we only have one! */
96 m_pixelformat = *it;
97 break;
98 }
99 if (m_pixelformat == NULL)
100 throw FileError("Pixmap color mode is not supported.");
101
90 /* first line has to be PIXMAP_IDENTIFIER */ 102 /* first line has to be PIXMAP_IDENTIFIER */
91 line = getLine(in, false); 103 line = getLine(in, false);
92 if (line != PIXMAP_IDENTIFIER) 104 if (line != PIXMAP_IDENTIFIER)
@@ -115,7 +127,7 @@ void CPixmap::read(std::ifstream& in)
115 throw FileError("Pixmap array has no opening bracket."); 127 throw FileError("Pixmap array has no opening bracket.");
116 128
117 /* parse <Values>-section */ 129 /* parse <Values>-section */
118 line = getArrayLine(in); 130 line = getCArrayLine(in);
119 if (line.empty()) 131 if (line.empty())
120 throw FileError("Pixmap has no Values-section."); 132 throw FileError("Pixmap has no Values-section.");
121 algorithm::split(list, line, is_any_of(" \t")); 133 algorithm::split(list, line, is_any_of(" \t"));
@@ -152,10 +164,14 @@ void CPixmap::read(std::ifstream& in)
152 164
153 /* parse <Colors>-table */ 165 /* parse <Colors>-table */
154 string character; 166 string character;
155 map<string, CPixelFormat::RGBPIXEL *> colors; 167 /* map[id][colortype] = color */
168 map<string, map<string, CPixelFormat::RGBPIXEL *> > colors;
169 /* map[id] = indices */
170 map<string, uint32_t> colornr;
171 uint32_t index = 0;
156 for(uint32_t i = 0; i < m_fileheader.nColor; i++) 172 for(uint32_t i = 0; i < m_fileheader.nColor; i++)
157 { 173 {
158 line = getArrayLine(in); 174 line = getCArrayLine(in);
159 if (line.empty()) 175 if (line.empty())
160 throw FileError("Pixmap has missing colortable-entry."); 176 throw FileError("Pixmap has missing colortable-entry.");
161 algorithm::split(list, line, is_any_of(" \t")); 177 algorithm::split(list, line, is_any_of(" \t"));
@@ -166,19 +182,21 @@ void CPixmap::read(std::ifstream& in)
166 character = list[0]; 182 character = list[0];
167 if (character.length() != m_fileheader.nChar) 183 if (character.length() != m_fileheader.nChar)
168 throw FileError("Pixmap colorcharacter is invalid."); 184 throw FileError("Pixmap colorcharacter is invalid.");
185 if (colors.find(character) != colors.end())
186 throw FileError("Duplicate colorcharacter found.");
169 187
170 /* read colors */ 188 /* read colors */
171 string color("");
172 if ((list.size() - 1) % 2 != 0) 189 if ((list.size() - 1) % 2 != 0)
173 throw FileError("Pixmap color entrys are invalid."); 190 throw FileError("Pixmap color entrys are invalid.");
174 for(uint32_t j = 1; j < list.size(); j = j + 2) 191 for(uint32_t j = 1; j < list.size(); j = j + 2)
175 { 192 {
193 /* we only support hex-color notations */
176 if (list[j + 1].length() != 7) 194 if (list[j + 1].length() != 7)
177 throw FileError("Pixmap color value is invalid."); 195 throw FileError("Pixmap color value is invalid.");
178 if (list[j + 1].at(0) != '#') 196 if (list[j + 1].at(0) != '#')
179 throw FileError("Pixmap color table value is not hexadecimal."); 197 throw FileError("Pixmap color table value is not hexadecimal.");
180 198
181 /* we only support c-colors! */ 199 /* we only support c-colors! - remove only if you free the pixels */
182 if (list[j] != "c") 200 if (list[j] != "c")
183 continue; 201 continue;
184 202
@@ -186,15 +204,17 @@ void CPixmap::read(std::ifstream& in)
186 pixel->red = strtoul(list[j + 1].substr(1, 2).c_str(), NULL, 16); 204 pixel->red = strtoul(list[j + 1].substr(1, 2).c_str(), NULL, 16);
187 pixel->green = strtoul(list[j + 1].substr(3, 2).c_str(), NULL, 16); 205 pixel->green = strtoul(list[j + 1].substr(3, 2).c_str(), NULL, 16);
188 pixel->blue = strtoul(list[j + 1].substr(5, 2).c_str(), NULL, 16); 206 pixel->blue = strtoul(list[j + 1].substr(5, 2).c_str(), NULL, 16);
189 colors[ list[j] ] = pixel; 207 colors[ character ][ list[j] ] = pixel;
190 } 208 }
191 209
192 /* we only support c-colors! */ 210 /* we only support c-colors! */
193 if (colors.find("c") == colors.end()) 211 if (colors[ character ].find("c") == colors[ character ].end())
194 throw FileError("Pixmap color entry has missing c-value."); 212 throw FileError("Pixmap color entry has missing c-value.");
195 213
196 /* add pixel to colortable */ 214 /* add pixel to colortable */
197 m_colortable[character] = colors["c"]; 215 colornr[ character ] = index;
216 m_colortable[ index ] = colors[ character ]["c"];
217 index++;
198 } 218 }
199 219
200 /* read pixel data */ 220 /* read pixel data */
@@ -206,12 +226,27 @@ void CPixmap::read(std::ifstream& in)
206 226
207 for (uint32_t y = 0; y < getHeight(); y++) 227 for (uint32_t y = 0; y < getHeight(); y++)
208 { 228 {
209 line = getArrayLine(in); 229 line = getCArrayLine(in);
210 if (line.empty()) 230 if (line.empty())
211 throw FileError("Pixmap has no pixel data."); 231 throw FileError("Pixmap has no pixel data.");
212 if (line.length() != getWidth()) 232 if (line.length() != getWidth())
213 throw FileError("Pixmap pixeldata width is larger than header width."); 233 throw FileError("Pixmap pixeldata width is larger than header width.");
214 copy(line.c_str(), line.c_str() + line.length(), m_pixeldata + y * getWidth()); 234
235 /* convert color identifier to our own identifiers */
236 for(uint32_t x = 0; x < getWidth(); x++)
237 {
238 character = line.substr(x * m_fileheader.nChar, m_fileheader.nChar);
239 if (colornr.find(character) == colornr.end())
240 throw FileError("Pixel has no reference in colortable.");
241
242 uint32_t offset = y * getWidth() + x;
243
244 /* boundary check */
245 if (offset * sizeof(uint32_t) + sizeof(uint32_t) > getPixelDataSize())
246 throw FileError("Pixel position is out of range.");
247
248 *((uint32_t *)m_pixeldata + offset) = colornr[ character ];
249 }
215 } 250 }
216 } 251 }
217 252
@@ -221,28 +256,32 @@ void CPixmap::read(std::ifstream& in)
221 if (!in.good()) 256 if (!in.good())
222 throw FileError("Pixmap array isn't closed properly."); 257 throw FileError("Pixmap array isn't closed properly.");
223 258
224 /* get pixelformat instance */ 259 /* set rowsize */
225 m_pixelformat = NULL; 260 m_rowsize = sizeof(uint32_t) * getWidth();
226 set<CPixelFormat *>::iterator it; 261}
227 for (it = m_handlers.begin(); it != m_handlers.end(); it++) 262
263/*----------------------------------------------------------------------------*/
264
265const std::string CPixmap::getXPMColorID(unsigned int index, unsigned int length)
266{
267 static const char code[] = PIXMAP_COLORCHARS;
268 string str("");
269 for(unsigned int i = length - 1; i > 0; i--)
228 { 270 {
229 /* we only have one! */ 271 str += code[index % strlen(code)];
230 m_pixelformat = *it; 272 index /= strlen(code);
231 break;
232 } 273 }
233 if (m_pixelformat == NULL) 274 str += code[index];
234 throw FileError("Pixmap color mode is not supported."); 275 return str;
235
236#ifdef DEBUG
237 /* debug*/
238 CPixmap::dump(cout);
239#endif
240} 276}
241 277
242/*----------------------------------------------------------------------------*/ 278/*----------------------------------------------------------------------------*/
243 279
244void CPixmap::write(std::ofstream& out) 280void CPixmap::write(std::ofstream& out)
245{ 281{
282 m_fileheader.nColor = m_colortable.size();
283 m_fileheader.nChar = m_fileheader.nColor / strlen(PIXMAP_COLORCHARS) + 1;
284
246 /* header comment */ 285 /* header comment */
247 out << PIXMAP_IDENTIFIER << endl; 286 out << PIXMAP_IDENTIFIER << endl;
248 287
@@ -259,10 +298,10 @@ void CPixmap::write(std::ofstream& out)
259 out << "\"," << endl; 298 out << "\"," << endl;
260 299
261 /* color table */ 300 /* color table */
262 map<string, CPixelFormat::RGBPIXEL *>::iterator it; 301 map<uint32_t, CPixelFormat::RGBPIXEL *>::iterator it;
263 for (it = m_colortable.begin(); it != m_colortable.end(); it++) 302 for (it = m_colortable.begin(); it != m_colortable.end(); it++)
264 { 303 {
265 out << "\"" << (*it).first; 304 out << "\"" << getXPMColorID((*it).first, m_fileheader.nChar);
266 /* we only support c-colors! */ 305 /* we only support c-colors! */
267 out << "\tc #"; 306 out << "\tc #";
268 out << setfill('0') << setw(2) << hex << uppercase << (*it).second->red 307 out << setfill('0') << setw(2) << hex << uppercase << (*it).second->red
@@ -275,8 +314,20 @@ void CPixmap::write(std::ofstream& out)
275 for (uint32_t y = 0; y < getHeight(); y++) 314 for (uint32_t y = 0; y < getHeight(); y++)
276 { 315 {
277 out << "\""; 316 out << "\"";
278 uint32_t offset = y * getWidth(); 317 for(uint32_t x = 0; x < getWidth(); x++)
279 copy(m_pixeldata + offset, m_pixeldata + offset + getWidth(), ostream_iterator<uint8_t>(out)); 318 {
319 uint32_t offset = y * getWidth() + x;
320
321 /* boundary check */
322 if (offset * sizeof(uint32_t) + sizeof(uint32_t) > getPixelDataSize())
323 throw FileError("Pixel position is out of range.");
324
325 uint32_t color = *((uint32_t *)m_pixeldata + offset);
326
327 if ((it = m_colortable.find(color)) == m_colortable.end())
328 throw FileError("Pixel has no reference in colortable.");
329 out << getXPMColorID((*it).first, m_fileheader.nChar);
330 }
280 out << "\"," << endl; 331 out << "\"," << endl;
281 } 332 }
282 333
@@ -292,16 +343,6 @@ void CPixmap::write(std::ofstream& out)
292#ifdef DEBUG 343#ifdef DEBUG
293void CPixmap::dump(std::ostream& out) 344void CPixmap::dump(std::ostream& out)
294{ 345{
295 /* pixeldata */
296 cout << "[XPM Pixel Data]" << endl;
297 for (uint32_t y = 0; y < getHeight(); y++)
298 {
299 uint32_t offset = y * getWidth();
300 copy(m_pixeldata + offset, m_pixeldata + offset + getWidth(), ostream_iterator<uint8_t>(cout));
301 out << endl;
302 }
303 out << endl;
304
305 /* values*/ 346 /* values*/
306 cout << "[XPM Header Values]" << endl 347 cout << "[XPM Header Values]" << endl
307 << "width=" << m_fileheader.width << endl 348 << "width=" << m_fileheader.width << endl
@@ -316,11 +357,11 @@ void CPixmap::dump(std::ostream& out)
316 << endl; 357 << endl;
317 358
318 /* colors*/ 359 /* colors*/
319 map<string, CPixelFormat::RGBPIXEL *>::iterator it; 360 map<uint32_t, CPixelFormat::RGBPIXEL *>::iterator it;
320 cout << "[Color Table]" << endl; 361 cout << "[Color Table]" << endl;
321 for (it = m_colortable.begin(); it != m_colortable.end(); it++) 362 for (it = m_colortable.begin(); it != m_colortable.end(); it++)
322 { 363 {
323 out << (*it).first << " " 364 out << (*it).first << ": "
324 << setfill('0') << setw(3) << (*it).second->red << " " 365 << setfill('0') << setw(3) << (*it).second->red << " "
325 << setfill('0') << setw(3) << (*it).second->green << " " 366 << setfill('0') << setw(3) << (*it).second->green << " "
326 << setfill('0') << setw(3) << (*it).second->blue << " " 367 << setfill('0') << setw(3) << (*it).second->blue << " "
diff --git a/ue2/imgsynth2/cpixmap.h b/ue2/imgsynth2/cpixmap.h
index 66aa1c1..10f2b33 100644
--- a/ue2/imgsynth2/cpixmap.h
+++ b/ue2/imgsynth2/cpixmap.h
@@ -12,6 +12,8 @@
12#include "cbitmap.h" 12#include "cbitmap.h"
13 13
14#define PIXMAP_IDENTIFIER "/* XPM */" 14#define PIXMAP_IDENTIFIER "/* XPM */"
15#define PIXMAP_COLORCHARS ".#abcdefghijklmnopqrstuvwxyzABCD" \
16 "EFGHIJKLMNOPQRSTUVWXYZ0123456789"
15 17
16/** 18/**
17 * @class CPixmap 19 * @class CPixmap
@@ -87,23 +89,45 @@ class CPixmap : public CBitmap
87 void dump(std::ostream& out); 89 void dump(std::ostream& out);
88#endif 90#endif
89 91
90 /* TODO */ 92 /**
93 * @method getPixelDataSize
94 * @brief Return size of pixelbuffer
95 * @param -
96 * @return size of pixelbuffer
97 * @globalvars none
98 * @exception none
99 * @conditions none
100 */
91 const uint32_t getPixelDataSize() 101 const uint32_t getPixelDataSize()
92 { 102 {
93 return m_fileheader.width * m_fileheader.height * m_fileheader.nChar; 103 return m_fileheader.width * m_fileheader.height * sizeof(uint32_t);
94 } 104 }
95 105
96 /* TODO */ 106 /**
107 * @method getHeight
108 * @brief Return height of bitmap in pixel
109 * @param -
110 * @return height of bitmap in pixel
111 * @globalvars none
112 * @exception none
113 * @conditions none
114 */
97 const uint32_t getHeight() 115 const uint32_t getHeight()
98 { 116 {
99 /* width and height can be negativ */
100 return m_fileheader.height; 117 return m_fileheader.height;
101 } 118 }
102 119
103 /* TODO */ 120 /**
121 * @method getWidth
122 * @brief Return width of bitmap in pixel
123 * @param -
124 * @return width of bitmap in pixel
125 * @globalvars none
126 * @exception none
127 * @conditions none
128 */
104 const uint32_t getWidth() 129 const uint32_t getWidth()
105 { 130 {
106 /* width and height can be negativ */
107 return m_fileheader.width; 131 return m_fileheader.width;
108 } 132 }
109 133
@@ -122,7 +146,15 @@ class CPixmap : public CBitmap
122 return true; 146 return true;
123 } 147 }
124 148
125 /* TODO */ 149 /**
150 * @method isMirrored
151 * @brief Windows Bitmaps can be stored upside down
152 * @param -
153 * @return true if bitmap is stored upside down. false otherwise
154 * @globalvars none
155 * @exception none
156 * @conditions none
157 */
126 const bool isMirrored() 158 const bool isMirrored()
127 { 159 {
128 /* pixmap is never mirrored */ 160 /* pixmap is never mirrored */
@@ -130,10 +162,40 @@ class CPixmap : public CBitmap
130 } 162 }
131 163
132 protected: 164 protected:
133 /** TODO */ 165 /**
166 * @method getLine
167 * @brief read trimmed line (terminated by \n) from filestream
168 * @param in filestream to read data from
169 * @param ignore_comments true: ignore c-like comments
170 * @return return trimmed line from filestream
171 * @globalvars none
172 * @exception none
173 * @conditions none
174 */
134 std::string getLine(std::ifstream& in, bool ignore_comments = true); 175 std::string getLine(std::ifstream& in, bool ignore_comments = true);
135 /** TODO */ 176
136 std::string getArrayLine(std::ifstream& in, bool ignore_comments = true); 177 /**
178 * @method getArrayLine
179 * @brief read trimmed c-arrayline from filestream
180 * @param in filestream to read data from
181 * @return return trimmed c-arrayline from filestream
182 * @globalvars none
183 * @exception FileError
184 * @conditions none
185 */
186 std::string getCArrayLine(std::ifstream& in);
187
188 /**
189 * @method getXPMColorID
190 * @brief get xpm color identifier, generated using an index
191 * @param index index used to generate the xpm color identifier
192 * @param length length of xpm color identifier
193 * @return return xpm color identifier, generated using index
194 * @globalvars none
195 * @exception FileError
196 * @conditions none
197 */
198 const std::string getXPMColorID(unsigned int index, unsigned int length);
137 199
138 /** 200 /**
139 * @brief Pixmap Header structure 201 * @brief Pixmap Header structure
@@ -163,9 +225,8 @@ class CPixmap : public CBitmap
163 /* members */ 225 /* members */
164 /** fileheader */ 226 /** fileheader */
165 PIXMAP_FILEHEADER m_fileheader; 227 PIXMAP_FILEHEADER m_fileheader;
166 /** TODO */ 228 /** name of image/c-array */
167 std::string m_imagename; 229 std::string m_imagename;
168 /** TODO convert PIXMAP_FILEHEADER to member variables */
169}; 230};
170 231
171#endif 232#endif
diff --git a/ue2/imgsynth2/cwindowsbitmap.cpp b/ue2/imgsynth2/cwindowsbitmap.cpp
index ddacab9..d561465 100644
--- a/ue2/imgsynth2/cwindowsbitmap.cpp
+++ b/ue2/imgsynth2/cwindowsbitmap.cpp
@@ -75,6 +75,11 @@ void CWindowsBitmap::read(std::ifstream& in)
75 } 75 }
76 if (m_pixelformat == NULL) 76 if (m_pixelformat == NULL)
77 throw FileError("Bitmap bitcount is not supported."); 77 throw FileError("Bitmap bitcount is not supported.");
78
79 /* calc rowsize - boundary is 32 */
80 m_rowsize = 4 * static_cast<uint32_t>(
81 ((m_pixelformat->getBitCount() * m_infoheader.biWidth) + 31) / 32
82 );
78} 83}
79 84
80/*----------------------------------------------------------------------------*/ 85/*----------------------------------------------------------------------------*/
diff --git a/ue2/imgsynth2/test/input_yellow_man1_indexed8 b/ue2/imgsynth2/test/input_yellow_man1_indexed8
index c0385c3..84c4604 100644
--- a/ue2/imgsynth2/test/input_yellow_man1_indexed8
+++ b/ue2/imgsynth2/test/input_yellow_man1_indexed8
@@ -4,7 +4,7 @@
4 4
5read(XPM, test/yellow_man1_indexed8_in.xpm) 5read(XPM, test/yellow_man1_indexed8_in.xpm)
6 6
7#fillrect(0,3,6,5,0,255,0) 7fillrect(0,3,6,5,0,255,0)
8#fillrect(2,13,7,4,0,0,255) 8fillrect(2,13,7,4,0,0,255)
9 9
10write(XPM, test/yellow_man1_indexed8_out.xpm) 10write(XPM, test/yellow_man1_indexed8_out.xpm)
diff --git a/ue2/imgsynth2/test/input_yellow_man2_indexed8 b/ue2/imgsynth2/test/input_yellow_man2_indexed8
new file mode 100644
index 0000000..440c653
--- /dev/null
+++ b/ue2/imgsynth2/test/input_yellow_man2_indexed8
@@ -0,0 +1,13 @@
1#in: test/yellow_man2_indexed8_in.xpm
2#out: test/yellow_man2_indexed8_out.xpm
3#ref: test/yellow_man2_indexed8_ref.xpm
4
5read(XPM, test/yellow_man2_indexed8_in.xpm)
6
7fillrect(0,3,6,5,0,255,0)
8fillrect(2,13,7,4,0,0,255)
9mirror_x()
10mirror_y()
11invert()
12
13write(XPM, test/yellow_man2_indexed8_out.xpm)
diff --git a/ue2/imgsynth2/test/yellow_man1_indexed8_ref.xpm b/ue2/imgsynth2/test/yellow_man1_indexed8_ref.xpm
index bd3beb4..7526656 100644
--- a/ue2/imgsynth2/test/yellow_man1_indexed8_ref.xpm
+++ b/ue2/imgsynth2/test/yellow_man1_indexed8_ref.xpm
@@ -3,22 +3,27 @@ static char * yellow_man1_default_xpm[] = {
3"9 17 4 1 0 0 XPMEXT", 3"9 17 4 1 0 0 XPMEXT",
4". c #000000", 4". c #000000",
5"# c #FFF200", 5"# c #FFF200",
6"+ c #00FF00", 6"b c #00FF00",
7"@ c #0000FF", 7"c c #0000FF",
8".........", 8".........",
9".........", 9".........",
10"...###...", 10"...###...",
11"++++++...", 11"bbbbbb...",
12"++++++...", 12"bbbbbb...",
13"++++++...", 13"bbbbbb...",
14"++++++#..", 14"bbbbbb#..",
15"++++++.#.", 15"bbbbbb.#.",
16".#.###.#.", 16".#.###.#.",
17".#.###.#.", 17".#.###.#.",
18".#.###.#.", 18".#.###.#.",
19"...#.#...", 19"...#.#...",
20"...#.#...", 20"...#.#...",
21"..@@@@@@@", 21"..ccccccc",
22"..@@@@@@@", 22"..ccccccc",
23"..@@@@@@@", 23"..ccccccc",
24"..@@@@@@@"}; 24"..ccccccc",
25"XPMEXT ext1 data1",
26"XPMEXT ext2",
27"data2_1",
28"data2_2",
29"XPMENDEXT"}; \ No newline at end of file
diff --git a/ue2/imgsynth2/test/yellow_man2_indexed8_in.xpm b/ue2/imgsynth2/test/yellow_man2_indexed8_in.xpm
new file mode 100644
index 0000000..bd11b48
--- /dev/null
+++ b/ue2/imgsynth2/test/yellow_man2_indexed8_in.xpm
@@ -0,0 +1,27 @@
1/* XPM */
2static char * yellow_man1_default_xpm[] = {
3"9 17 2 1 0 0 XPMEXT",
4". c #000000 g4 #000000",
5"# c #FFF200",
6".........",
7".........",
8"...###...",
9"...###...",
10"...###...",
11"....#....",
12"..#####..",
13".#.###.#.",
14".#.###.#.",
15".#.###.#.",
16".#.###.#.",
17"...#.#...",
18"...#.#...",
19"...#.#...",
20"...#.#...",
21".........",
22".........",
23"XPMEXT ext1 data1",
24"XPMEXT ext2",
25"data2_1",
26"data2_2",
27"XPMENDEXT"};
diff --git a/ue2/imgsynth2/test/yellow_man2_indexed8_ref.xpm b/ue2/imgsynth2/test/yellow_man2_indexed8_ref.xpm
new file mode 100644
index 0000000..5ff048f
--- /dev/null
+++ b/ue2/imgsynth2/test/yellow_man2_indexed8_ref.xpm
@@ -0,0 +1,29 @@
1/* XPM */
2static char * yellow_man1_default_xpm[] = {
3"9 17 4 1 0 0 XPMEXT",
4". c #FFFFFF",
5"# c #000DFF",
6"b c #FF00FF",
7"c c #FFFF00",
8"ccccccc..",
9"ccccccc..",
10"ccccccc..",
11"ccccccc..",
12"...#.#...",
13"...#.#...",
14".#.###.#.",
15".#.###.#.",
16".#.###.#.",
17".#.bbbbbb",
18"..#bbbbbb",
19"...bbbbbb",
20"...bbbbbb",
21"...bbbbbb",
22"...###...",
23".........",
24".........",
25"XPMEXT ext1 data1",
26"XPMEXT ext2",
27"data2_1",
28"data2_2",
29"XPMENDEXT"}; \ No newline at end of file