summaryrefslogtreecommitdiffstats
path: root/ue2/imgsynth2/cpixmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ue2/imgsynth2/cpixmap.cpp')
-rw-r--r--ue2/imgsynth2/cpixmap.cpp29
1 files changed, 13 insertions, 16 deletions
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
39void CPixmap::read(std::ifstream& in) 36void 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;