qxpmhandler.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/image/qxpmhandler.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9static quint64 xpmHash(const QString &str)-
10{-
11 unsigned int hashValue = 0;-
12 for (int i = 0; i < str.size(); ++i) {-
13 hashValue <<= 8;-
14 hashValue += (unsigned int)str.at(i).unicode();-
15 }-
16 return hashValue;-
17}-
18static quint64 xpmHash(char *str)-
19{-
20 unsigned int hashValue = 0;-
21 while (*str != '\0') {-
22 hashValue <<= 8;-
23 hashValue += (unsigned int)*str;-
24 ++str;-
25 }-
26 return hashValue;-
27}-
28-
29-
30-
31-
32-
33-
34static const int xpmRgbTblSize = 657;-
35-
36static const struct XPMRGBData {-
37 uint value;-
38 const char name[21];-
39} xpmRgbTbl[] = {-
40 { (240*65536 + 248*256 + 255), "aliceblue" },-
41 { (250*65536 + 235*256 + 215), "antiquewhite" },-
42 { (255*65536 + 239*256 + 219), "antiquewhite1" },-
43 { (238*65536 + 223*256 + 204), "antiquewhite2" },-
44 { (205*65536 + 192*256 + 176), "antiquewhite3" },-
45 { (139*65536 + 131*256 + 120), "antiquewhite4" },-
46 { (127*65536 + 255*256 + 212), "aquamarine" },-
47 { (127*65536 + 255*256 + 212), "aquamarine1" },-
48 { (118*65536 + 238*256 + 198), "aquamarine2" },-
49 { (102*65536 + 205*256 + 170), "aquamarine3" },-
50 { (69*65536 + 139*256 + 116), "aquamarine4" },-
51 { (240*65536 + 255*256 + 255), "azure" },-
52 { (240*65536 + 255*256 + 255), "azure1" },-
53 { (224*65536 + 238*256 + 238), "azure2" },-
54 { (193*65536 + 205*256 + 205), "azure3" },-
55 { (131*65536 + 139*256 + 139), "azure4" },-
56 { (245*65536 + 245*256 + 220), "beige" },-
57 { (255*65536 + 228*256 + 196), "bisque" },-
58 { (255*65536 + 228*256 + 196), "bisque1" },-
59 { (238*65536 + 213*256 + 183), "bisque2" },-
60 { (205*65536 + 183*256 + 158), "bisque3" },-
61 { (139*65536 + 125*256 + 107), "bisque4" },-
62 { (0*65536 + 0*256 + 0), "black" },-
63 { (255*65536 + 235*256 + 205), "blanchedalmond" },-
64 { (0*65536 + 0*256 + 255), "blue" },-
65 { (0*65536 + 0*256 + 255), "blue1" },-
66 { (0*65536 + 0*256 + 238), "blue2" },-
67 { (0*65536 + 0*256 + 205), "blue3" },-
68 { (0*65536 + 0*256 + 139), "blue4" },-
69 { (138*65536 + 43*256 + 226), "blueviolet" },-
70 { (165*65536 + 42*256 + 42), "brown" },-
71 { (255*65536 + 64*256 + 64), "brown1" },-
72 { (238*65536 + 59*256 + 59), "brown2" },-
73 { (205*65536 + 51*256 + 51), "brown3" },-
74 { (139*65536 + 35*256 + 35), "brown4" },-
75 { (222*65536 + 184*256 + 135), "burlywood" },-
76 { (255*65536 + 211*256 + 155), "burlywood1" },-
77 { (238*65536 + 197*256 + 145), "burlywood2" },-
78 { (205*65536 + 170*256 + 125), "burlywood3" },-
79 { (139*65536 + 115*256 + 85), "burlywood4" },-
80 { (95*65536 + 158*256 + 160), "cadetblue" },-
81 { (152*65536 + 245*256 + 255), "cadetblue1" },-
82 { (142*65536 + 229*256 + 238), "cadetblue2" },-
83 { (122*65536 + 197*256 + 205), "cadetblue3" },-
84 { (83*65536 + 134*256 + 139), "cadetblue4" },-
85 { (127*65536 + 255*256 + 0), "chartreuse" },-
86 { (127*65536 + 255*256 + 0), "chartreuse1" },-
87 { (118*65536 + 238*256 + 0), "chartreuse2" },-
88 { (102*65536 + 205*256 + 0), "chartreuse3" },-
89 { (69*65536 + 139*256 + 0), "chartreuse4" },-
90 { (210*65536 + 105*256 + 30), "chocolate" },-
91 { (255*65536 + 127*256 + 36), "chocolate1" },-
92 { (238*65536 + 118*256 + 33), "chocolate2" },-
93 { (205*65536 + 102*256 + 29), "chocolate3" },-
94 { (139*65536 + 69*256 + 19), "chocolate4" },-
95 { (255*65536 + 127*256 + 80), "coral" },-
96 { (255*65536 + 114*256 + 86), "coral1" },-
97 { (238*65536 + 106*256 + 80), "coral2" },-
98 { (205*65536 + 91*256 + 69), "coral3" },-
99 { (139*65536 + 62*256 + 47), "coral4" },-
100 { (100*65536 + 149*256 + 237), "cornflowerblue" },-
101 { (255*65536 + 248*256 + 220), "cornsilk" },-
102 { (255*65536 + 248*256 + 220), "cornsilk1" },-
103 { (238*65536 + 232*256 + 205), "cornsilk2" },-
104 { (205*65536 + 200*256 + 177), "cornsilk3" },-
105 { (139*65536 + 136*256 + 120), "cornsilk4" },-
106 { (0*65536 + 255*256 + 255), "cyan" },-
107 { (0*65536 + 255*256 + 255), "cyan1" },-
108 { (0*65536 + 238*256 + 238), "cyan2" },-
109 { (0*65536 + 205*256 + 205), "cyan3" },-
110 { (0*65536 + 139*256 + 139), "cyan4" },-
111 { (0*65536 + 0*256 + 139), "darkblue" },-
112 { (0*65536 + 139*256 + 139), "darkcyan" },-
113 { (184*65536 + 134*256 + 11), "darkgoldenrod" },-
114 { (255*65536 + 185*256 + 15), "darkgoldenrod1" },-
115 { (238*65536 + 173*256 + 14), "darkgoldenrod2" },-
116 { (205*65536 + 149*256 + 12), "darkgoldenrod3" },-
117 { (139*65536 + 101*256 + 8), "darkgoldenrod4" },-
118 { (169*65536 + 169*256 + 169), "darkgray" },-
119 { (0*65536 + 100*256 + 0), "darkgreen" },-
120 { (169*65536 + 169*256 + 169), "darkgrey" },-
121 { (189*65536 + 183*256 + 107), "darkkhaki" },-
122 { (139*65536 + 0*256 + 139), "darkmagenta" },-
123 { (85*65536 + 107*256 + 47), "darkolivegreen" },-
124 { (202*65536 + 255*256 + 112), "darkolivegreen1" },-
125 { (188*65536 + 238*256 + 104), "darkolivegreen2" },-
126 { (162*65536 + 205*256 + 90), "darkolivegreen3" },-
127 { (110*65536 + 139*256 + 61), "darkolivegreen4" },-
128 { (255*65536 + 140*256 + 0), "darkorange" },-
129 { (255*65536 + 127*256 + 0), "darkorange1" },-
130 { (238*65536 + 118*256 + 0), "darkorange2" },-
131 { (205*65536 + 102*256 + 0), "darkorange3" },-
132 { (139*65536 + 69*256 + 0), "darkorange4" },-
133 { (153*65536 + 50*256 + 204), "darkorchid" },-
134 { (191*65536 + 62*256 + 255), "darkorchid1" },-
135 { (178*65536 + 58*256 + 238), "darkorchid2" },-
136 { (154*65536 + 50*256 + 205), "darkorchid3" },-
137 { (104*65536 + 34*256 + 139), "darkorchid4" },-
138 { (139*65536 + 0*256 + 0), "darkred" },-
139 { (233*65536 + 150*256 + 122), "darksalmon" },-
140 { (143*65536 + 188*256 + 143), "darkseagreen" },-
141 { (193*65536 + 255*256 + 193), "darkseagreen1" },-
142 { (180*65536 + 238*256 + 180), "darkseagreen2" },-
143 { (155*65536 + 205*256 + 155), "darkseagreen3" },-
144 { (105*65536 + 139*256 + 105), "darkseagreen4" },-
145 { (72*65536 + 61*256 + 139), "darkslateblue" },-
146 { (47*65536 + 79*256 + 79), "darkslategray" },-
147 { (151*65536 + 255*256 + 255), "darkslategray1" },-
148 { (141*65536 + 238*256 + 238), "darkslategray2" },-
149 { (121*65536 + 205*256 + 205), "darkslategray3" },-
150 { (82*65536 + 139*256 + 139), "darkslategray4" },-
151 { (47*65536 + 79*256 + 79), "darkslategrey" },-
152 { (0*65536 + 206*256 + 209), "darkturquoise" },-
153 { (148*65536 + 0*256 + 211), "darkviolet" },-
154 { (255*65536 + 20*256 + 147), "deeppink" },-
155 { (255*65536 + 20*256 + 147), "deeppink1" },-
156 { (238*65536 + 18*256 + 137), "deeppink2" },-
157 { (205*65536 + 16*256 + 118), "deeppink3" },-
158 { (139*65536 + 10*256 + 80), "deeppink4" },-
159 { (0*65536 + 191*256 + 255), "deepskyblue" },-
160 { (0*65536 + 191*256 + 255), "deepskyblue1" },-
161 { (0*65536 + 178*256 + 238), "deepskyblue2" },-
162 { (0*65536 + 154*256 + 205), "deepskyblue3" },-
163 { (0*65536 + 104*256 + 139), "deepskyblue4" },-
164 { (105*65536 + 105*256 + 105), "dimgray" },-
165 { (105*65536 + 105*256 + 105), "dimgrey" },-
166 { (30*65536 + 144*256 + 255), "dodgerblue" },-
167 { (30*65536 + 144*256 + 255), "dodgerblue1" },-
168 { (28*65536 + 134*256 + 238), "dodgerblue2" },-
169 { (24*65536 + 116*256 + 205), "dodgerblue3" },-
170 { (16*65536 + 78*256 + 139), "dodgerblue4" },-
171 { (178*65536 + 34*256 + 34), "firebrick" },-
172 { (255*65536 + 48*256 + 48), "firebrick1" },-
173 { (238*65536 + 44*256 + 44), "firebrick2" },-
174 { (205*65536 + 38*256 + 38), "firebrick3" },-
175 { (139*65536 + 26*256 + 26), "firebrick4" },-
176 { (255*65536 + 250*256 + 240), "floralwhite" },-
177 { (34*65536 + 139*256 + 34), "forestgreen" },-
178 { (220*65536 + 220*256 + 220), "gainsboro" },-
179 { (248*65536 + 248*256 + 255), "ghostwhite" },-
180 { (255*65536 + 215*256 + 0), "gold" },-
181 { (255*65536 + 215*256 + 0), "gold1" },-
182 { (238*65536 + 201*256 + 0), "gold2" },-
183 { (205*65536 + 173*256 + 0), "gold3" },-
184 { (139*65536 + 117*256 + 0), "gold4" },-
185 { (218*65536 + 165*256 + 32), "goldenrod" },-
186 { (255*65536 + 193*256 + 37), "goldenrod1" },-
187 { (238*65536 + 180*256 + 34), "goldenrod2" },-
188 { (205*65536 + 155*256 + 29), "goldenrod3" },-
189 { (139*65536 + 105*256 + 20), "goldenrod4" },-
190 { (190*65536 + 190*256 + 190), "gray" },-
191 { (0*65536 + 0*256 + 0), "gray0" },-
192 { (3*65536 + 3*256 + 3), "gray1" },-
193 { (26*65536 + 26*256 + 26), "gray10" },-
194 { (255*65536 + 255*256 + 255), "gray100" },-
195 { (28*65536 + 28*256 + 28), "gray11" },-
196 { (31*65536 + 31*256 + 31), "gray12" },-
197 { (33*65536 + 33*256 + 33), "gray13" },-
198 { (36*65536 + 36*256 + 36), "gray14" },-
199 { (38*65536 + 38*256 + 38), "gray15" },-
200 { (41*65536 + 41*256 + 41), "gray16" },-
201 { (43*65536 + 43*256 + 43), "gray17" },-
202 { (46*65536 + 46*256 + 46), "gray18" },-
203 { (48*65536 + 48*256 + 48), "gray19" },-
204 { (5*65536 + 5*256 + 5), "gray2" },-
205 { (51*65536 + 51*256 + 51), "gray20" },-
206 { (54*65536 + 54*256 + 54), "gray21" },-
207 { (56*65536 + 56*256 + 56), "gray22" },-
208 { (59*65536 + 59*256 + 59), "gray23" },-
209 { (61*65536 + 61*256 + 61), "gray24" },-
210 { (64*65536 + 64*256 + 64), "gray25" },-
211 { (66*65536 + 66*256 + 66), "gray26" },-
212 { (69*65536 + 69*256 + 69), "gray27" },-
213 { (71*65536 + 71*256 + 71), "gray28" },-
214 { (74*65536 + 74*256 + 74), "gray29" },-
215 { (8*65536 + 8*256 + 8), "gray3" },-
216 { (77*65536 + 77*256 + 77), "gray30" },-
217 { (79*65536 + 79*256 + 79), "gray31" },-
218 { (82*65536 + 82*256 + 82), "gray32" },-
219 { (84*65536 + 84*256 + 84), "gray33" },-
220 { (87*65536 + 87*256 + 87), "gray34" },-
221 { (89*65536 + 89*256 + 89), "gray35" },-
222 { (92*65536 + 92*256 + 92), "gray36" },-
223 { (94*65536 + 94*256 + 94), "gray37" },-
224 { (97*65536 + 97*256 + 97), "gray38" },-
225 { (99*65536 + 99*256 + 99), "gray39" },-
226 { (10*65536 + 10*256 + 10), "gray4" },-
227 { (102*65536 + 102*256 + 102), "gray40" },-
228 { (105*65536 + 105*256 + 105), "gray41" },-
229 { (107*65536 + 107*256 + 107), "gray42" },-
230 { (110*65536 + 110*256 + 110), "gray43" },-
231 { (112*65536 + 112*256 + 112), "gray44" },-
232 { (115*65536 + 115*256 + 115), "gray45" },-
233 { (117*65536 + 117*256 + 117), "gray46" },-
234 { (120*65536 + 120*256 + 120), "gray47" },-
235 { (122*65536 + 122*256 + 122), "gray48" },-
236 { (125*65536 + 125*256 + 125), "gray49" },-
237 { (13*65536 + 13*256 + 13), "gray5" },-
238 { (127*65536 + 127*256 + 127), "gray50" },-
239 { (130*65536 + 130*256 + 130), "gray51" },-
240 { (133*65536 + 133*256 + 133), "gray52" },-
241 { (135*65536 + 135*256 + 135), "gray53" },-
242 { (138*65536 + 138*256 + 138), "gray54" },-
243 { (140*65536 + 140*256 + 140), "gray55" },-
244 { (143*65536 + 143*256 + 143), "gray56" },-
245 { (145*65536 + 145*256 + 145), "gray57" },-
246 { (148*65536 + 148*256 + 148), "gray58" },-
247 { (150*65536 + 150*256 + 150), "gray59" },-
248 { (15*65536 + 15*256 + 15), "gray6" },-
249 { (153*65536 + 153*256 + 153), "gray60" },-
250 { (156*65536 + 156*256 + 156), "gray61" },-
251 { (158*65536 + 158*256 + 158), "gray62" },-
252 { (161*65536 + 161*256 + 161), "gray63" },-
253 { (163*65536 + 163*256 + 163), "gray64" },-
254 { (166*65536 + 166*256 + 166), "gray65" },-
255 { (168*65536 + 168*256 + 168), "gray66" },-
256 { (171*65536 + 171*256 + 171), "gray67" },-
257 { (173*65536 + 173*256 + 173), "gray68" },-
258 { (176*65536 + 176*256 + 176), "gray69" },-
259 { (18*65536 + 18*256 + 18), "gray7" },-
260 { (179*65536 + 179*256 + 179), "gray70" },-
261 { (181*65536 + 181*256 + 181), "gray71" },-
262 { (184*65536 + 184*256 + 184), "gray72" },-
263 { (186*65536 + 186*256 + 186), "gray73" },-
264 { (189*65536 + 189*256 + 189), "gray74" },-
265 { (191*65536 + 191*256 + 191), "gray75" },-
266 { (194*65536 + 194*256 + 194), "gray76" },-
267 { (196*65536 + 196*256 + 196), "gray77" },-
268 { (199*65536 + 199*256 + 199), "gray78" },-
269 { (201*65536 + 201*256 + 201), "gray79" },-
270 { (20*65536 + 20*256 + 20), "gray8" },-
271 { (204*65536 + 204*256 + 204), "gray80" },-
272 { (207*65536 + 207*256 + 207), "gray81" },-
273 { (209*65536 + 209*256 + 209), "gray82" },-
274 { (212*65536 + 212*256 + 212), "gray83" },-
275 { (214*65536 + 214*256 + 214), "gray84" },-
276 { (217*65536 + 217*256 + 217), "gray85" },-
277 { (219*65536 + 219*256 + 219), "gray86" },-
278 { (222*65536 + 222*256 + 222), "gray87" },-
279 { (224*65536 + 224*256 + 224), "gray88" },-
280 { (227*65536 + 227*256 + 227), "gray89" },-
281 { (23*65536 + 23*256 + 23), "gray9" },-
282 { (229*65536 + 229*256 + 229), "gray90" },-
283 { (232*65536 + 232*256 + 232), "gray91" },-
284 { (235*65536 + 235*256 + 235), "gray92" },-
285 { (237*65536 + 237*256 + 237), "gray93" },-
286 { (240*65536 + 240*256 + 240), "gray94" },-
287 { (242*65536 + 242*256 + 242), "gray95" },-
288 { (245*65536 + 245*256 + 245), "gray96" },-
289 { (247*65536 + 247*256 + 247), "gray97" },-
290 { (250*65536 + 250*256 + 250), "gray98" },-
291 { (252*65536 + 252*256 + 252), "gray99" },-
292 { (0*65536 + 255*256 + 0), "green" },-
293 { (0*65536 + 255*256 + 0), "green1" },-
294 { (0*65536 + 238*256 + 0), "green2" },-
295 { (0*65536 + 205*256 + 0), "green3" },-
296 { (0*65536 + 139*256 + 0), "green4" },-
297 { (173*65536 + 255*256 + 47), "greenyellow" },-
298 { (190*65536 + 190*256 + 190), "grey" },-
299 { (0*65536 + 0*256 + 0), "grey0" },-
300 { (3*65536 + 3*256 + 3), "grey1" },-
301 { (26*65536 + 26*256 + 26), "grey10" },-
302 { (255*65536 + 255*256 + 255), "grey100" },-
303 { (28*65536 + 28*256 + 28), "grey11" },-
304 { (31*65536 + 31*256 + 31), "grey12" },-
305 { (33*65536 + 33*256 + 33), "grey13" },-
306 { (36*65536 + 36*256 + 36), "grey14" },-
307 { (38*65536 + 38*256 + 38), "grey15" },-
308 { (41*65536 + 41*256 + 41), "grey16" },-
309 { (43*65536 + 43*256 + 43), "grey17" },-
310 { (46*65536 + 46*256 + 46), "grey18" },-
311 { (48*65536 + 48*256 + 48), "grey19" },-
312 { (5*65536 + 5*256 + 5), "grey2" },-
313 { (51*65536 + 51*256 + 51), "grey20" },-
314 { (54*65536 + 54*256 + 54), "grey21" },-
315 { (56*65536 + 56*256 + 56), "grey22" },-
316 { (59*65536 + 59*256 + 59), "grey23" },-
317 { (61*65536 + 61*256 + 61), "grey24" },-
318 { (64*65536 + 64*256 + 64), "grey25" },-
319 { (66*65536 + 66*256 + 66), "grey26" },-
320 { (69*65536 + 69*256 + 69), "grey27" },-
321 { (71*65536 + 71*256 + 71), "grey28" },-
322 { (74*65536 + 74*256 + 74), "grey29" },-
323 { (8*65536 + 8*256 + 8), "grey3" },-
324 { (77*65536 + 77*256 + 77), "grey30" },-
325 { (79*65536 + 79*256 + 79), "grey31" },-
326 { (82*65536 + 82*256 + 82), "grey32" },-
327 { (84*65536 + 84*256 + 84), "grey33" },-
328 { (87*65536 + 87*256 + 87), "grey34" },-
329 { (89*65536 + 89*256 + 89), "grey35" },-
330 { (92*65536 + 92*256 + 92), "grey36" },-
331 { (94*65536 + 94*256 + 94), "grey37" },-
332 { (97*65536 + 97*256 + 97), "grey38" },-
333 { (99*65536 + 99*256 + 99), "grey39" },-
334 { (10*65536 + 10*256 + 10), "grey4" },-
335 { (102*65536 + 102*256 + 102), "grey40" },-
336 { (105*65536 + 105*256 + 105), "grey41" },-
337 { (107*65536 + 107*256 + 107), "grey42" },-
338 { (110*65536 + 110*256 + 110), "grey43" },-
339 { (112*65536 + 112*256 + 112), "grey44" },-
340 { (115*65536 + 115*256 + 115), "grey45" },-
341 { (117*65536 + 117*256 + 117), "grey46" },-
342 { (120*65536 + 120*256 + 120), "grey47" },-
343 { (122*65536 + 122*256 + 122), "grey48" },-
344 { (125*65536 + 125*256 + 125), "grey49" },-
345 { (13*65536 + 13*256 + 13), "grey5" },-
346 { (127*65536 + 127*256 + 127), "grey50" },-
347 { (130*65536 + 130*256 + 130), "grey51" },-
348 { (133*65536 + 133*256 + 133), "grey52" },-
349 { (135*65536 + 135*256 + 135), "grey53" },-
350 { (138*65536 + 138*256 + 138), "grey54" },-
351 { (140*65536 + 140*256 + 140), "grey55" },-
352 { (143*65536 + 143*256 + 143), "grey56" },-
353 { (145*65536 + 145*256 + 145), "grey57" },-
354 { (148*65536 + 148*256 + 148), "grey58" },-
355 { (150*65536 + 150*256 + 150), "grey59" },-
356 { (15*65536 + 15*256 + 15), "grey6" },-
357 { (153*65536 + 153*256 + 153), "grey60" },-
358 { (156*65536 + 156*256 + 156), "grey61" },-
359 { (158*65536 + 158*256 + 158), "grey62" },-
360 { (161*65536 + 161*256 + 161), "grey63" },-
361 { (163*65536 + 163*256 + 163), "grey64" },-
362 { (166*65536 + 166*256 + 166), "grey65" },-
363 { (168*65536 + 168*256 + 168), "grey66" },-
364 { (171*65536 + 171*256 + 171), "grey67" },-
365 { (173*65536 + 173*256 + 173), "grey68" },-
366 { (176*65536 + 176*256 + 176), "grey69" },-
367 { (18*65536 + 18*256 + 18), "grey7" },-
368 { (179*65536 + 179*256 + 179), "grey70" },-
369 { (181*65536 + 181*256 + 181), "grey71" },-
370 { (184*65536 + 184*256 + 184), "grey72" },-
371 { (186*65536 + 186*256 + 186), "grey73" },-
372 { (189*65536 + 189*256 + 189), "grey74" },-
373 { (191*65536 + 191*256 + 191), "grey75" },-
374 { (194*65536 + 194*256 + 194), "grey76" },-
375 { (196*65536 + 196*256 + 196), "grey77" },-
376 { (199*65536 + 199*256 + 199), "grey78" },-
377 { (201*65536 + 201*256 + 201), "grey79" },-
378 { (20*65536 + 20*256 + 20), "grey8" },-
379 { (204*65536 + 204*256 + 204), "grey80" },-
380 { (207*65536 + 207*256 + 207), "grey81" },-
381 { (209*65536 + 209*256 + 209), "grey82" },-
382 { (212*65536 + 212*256 + 212), "grey83" },-
383 { (214*65536 + 214*256 + 214), "grey84" },-
384 { (217*65536 + 217*256 + 217), "grey85" },-
385 { (219*65536 + 219*256 + 219), "grey86" },-
386 { (222*65536 + 222*256 + 222), "grey87" },-
387 { (224*65536 + 224*256 + 224), "grey88" },-
388 { (227*65536 + 227*256 + 227), "grey89" },-
389 { (23*65536 + 23*256 + 23), "grey9" },-
390 { (229*65536 + 229*256 + 229), "grey90" },-
391 { (232*65536 + 232*256 + 232), "grey91" },-
392 { (235*65536 + 235*256 + 235), "grey92" },-
393 { (237*65536 + 237*256 + 237), "grey93" },-
394 { (240*65536 + 240*256 + 240), "grey94" },-
395 { (242*65536 + 242*256 + 242), "grey95" },-
396 { (245*65536 + 245*256 + 245), "grey96" },-
397 { (247*65536 + 247*256 + 247), "grey97" },-
398 { (250*65536 + 250*256 + 250), "grey98" },-
399 { (252*65536 + 252*256 + 252), "grey99" },-
400 { (240*65536 + 255*256 + 240), "honeydew" },-
401 { (240*65536 + 255*256 + 240), "honeydew1" },-
402 { (224*65536 + 238*256 + 224), "honeydew2" },-
403 { (193*65536 + 205*256 + 193), "honeydew3" },-
404 { (131*65536 + 139*256 + 131), "honeydew4" },-
405 { (255*65536 + 105*256 + 180), "hotpink" },-
406 { (255*65536 + 110*256 + 180), "hotpink1" },-
407 { (238*65536 + 106*256 + 167), "hotpink2" },-
408 { (205*65536 + 96*256 + 144), "hotpink3" },-
409 { (139*65536 + 58*256 + 98), "hotpink4" },-
410 { (205*65536 + 92*256 + 92), "indianred" },-
411 { (255*65536 + 106*256 + 106), "indianred1" },-
412 { (238*65536 + 99*256 + 99), "indianred2" },-
413 { (205*65536 + 85*256 + 85), "indianred3" },-
414 { (139*65536 + 58*256 + 58), "indianred4" },-
415 { (255*65536 + 255*256 + 240), "ivory" },-
416 { (255*65536 + 255*256 + 240), "ivory1" },-
417 { (238*65536 + 238*256 + 224), "ivory2" },-
418 { (205*65536 + 205*256 + 193), "ivory3" },-
419 { (139*65536 + 139*256 + 131), "ivory4" },-
420 { (240*65536 + 230*256 + 140), "khaki" },-
421 { (255*65536 + 246*256 + 143), "khaki1" },-
422 { (238*65536 + 230*256 + 133), "khaki2" },-
423 { (205*65536 + 198*256 + 115), "khaki3" },-
424 { (139*65536 + 134*256 + 78), "khaki4" },-
425 { (230*65536 + 230*256 + 250), "lavender" },-
426 { (255*65536 + 240*256 + 245), "lavenderblush" },-
427 { (255*65536 + 240*256 + 245), "lavenderblush1" },-
428 { (238*65536 + 224*256 + 229), "lavenderblush2" },-
429 { (205*65536 + 193*256 + 197), "lavenderblush3" },-
430 { (139*65536 + 131*256 + 134), "lavenderblush4" },-
431 { (124*65536 + 252*256 + 0), "lawngreen" },-
432 { (255*65536 + 250*256 + 205), "lemonchiffon" },-
433 { (255*65536 + 250*256 + 205), "lemonchiffon1" },-
434 { (238*65536 + 233*256 + 191), "lemonchiffon2" },-
435 { (205*65536 + 201*256 + 165), "lemonchiffon3" },-
436 { (139*65536 + 137*256 + 112), "lemonchiffon4" },-
437 { (173*65536 + 216*256 + 230), "lightblue" },-
438 { (191*65536 + 239*256 + 255), "lightblue1" },-
439 { (178*65536 + 223*256 + 238), "lightblue2" },-
440 { (154*65536 + 192*256 + 205), "lightblue3" },-
441 { (104*65536 + 131*256 + 139), "lightblue4" },-
442 { (240*65536 + 128*256 + 128), "lightcoral" },-
443 { (224*65536 + 255*256 + 255), "lightcyan" },-
444 { (224*65536 + 255*256 + 255), "lightcyan1" },-
445 { (209*65536 + 238*256 + 238), "lightcyan2" },-
446 { (180*65536 + 205*256 + 205), "lightcyan3" },-
447 { (122*65536 + 139*256 + 139), "lightcyan4" },-
448 { (238*65536 + 221*256 + 130), "lightgoldenrod" },-
449 { (255*65536 + 236*256 + 139), "lightgoldenrod1" },-
450 { (238*65536 + 220*256 + 130), "lightgoldenrod2" },-
451 { (205*65536 + 190*256 + 112), "lightgoldenrod3" },-
452 { (139*65536 + 129*256 + 76), "lightgoldenrod4" },-
453 { (250*65536 + 250*256 + 210), "lightgoldenrodyellow" },-
454 { (211*65536 + 211*256 + 211), "lightgray" },-
455 { (144*65536 + 238*256 + 144), "lightgreen" },-
456 { (211*65536 + 211*256 + 211), "lightgrey" },-
457 { (255*65536 + 182*256 + 193), "lightpink" },-
458 { (255*65536 + 174*256 + 185), "lightpink1" },-
459 { (238*65536 + 162*256 + 173), "lightpink2" },-
460 { (205*65536 + 140*256 + 149), "lightpink3" },-
461 { (139*65536 + 95*256 + 101), "lightpink4" },-
462 { (255*65536 + 160*256 + 122), "lightsalmon" },-
463 { (255*65536 + 160*256 + 122), "lightsalmon1" },-
464 { (238*65536 + 149*256 + 114), "lightsalmon2" },-
465 { (205*65536 + 129*256 + 98), "lightsalmon3" },-
466 { (139*65536 + 87*256 + 66), "lightsalmon4" },-
467 { (32*65536 + 178*256 + 170), "lightseagreen" },-
468 { (135*65536 + 206*256 + 250), "lightskyblue" },-
469 { (176*65536 + 226*256 + 255), "lightskyblue1" },-
470 { (164*65536 + 211*256 + 238), "lightskyblue2" },-
471 { (141*65536 + 182*256 + 205), "lightskyblue3" },-
472 { (96*65536 + 123*256 + 139), "lightskyblue4" },-
473 { (132*65536 + 112*256 + 255), "lightslateblue" },-
474 { (119*65536 + 136*256 + 153), "lightslategray" },-
475 { (119*65536 + 136*256 + 153), "lightslategrey" },-
476 { (176*65536 + 196*256 + 222), "lightsteelblue" },-
477 { (202*65536 + 225*256 + 255), "lightsteelblue1" },-
478 { (188*65536 + 210*256 + 238), "lightsteelblue2" },-
479 { (162*65536 + 181*256 + 205), "lightsteelblue3" },-
480 { (110*65536 + 123*256 + 139), "lightsteelblue4" },-
481 { (255*65536 + 255*256 + 224), "lightyellow" },-
482 { (255*65536 + 255*256 + 224), "lightyellow1" },-
483 { (238*65536 + 238*256 + 209), "lightyellow2" },-
484 { (205*65536 + 205*256 + 180), "lightyellow3" },-
485 { (139*65536 + 139*256 + 122), "lightyellow4" },-
486 { (50*65536 + 205*256 + 50), "limegreen" },-
487 { (250*65536 + 240*256 + 230), "linen" },-
488 { (255*65536 + 0*256 + 255), "magenta" },-
489 { (255*65536 + 0*256 + 255), "magenta1" },-
490 { (238*65536 + 0*256 + 238), "magenta2" },-
491 { (205*65536 + 0*256 + 205), "magenta3" },-
492 { (139*65536 + 0*256 + 139), "magenta4" },-
493 { (176*65536 + 48*256 + 96), "maroon" },-
494 { (255*65536 + 52*256 + 179), "maroon1" },-
495 { (238*65536 + 48*256 + 167), "maroon2" },-
496 { (205*65536 + 41*256 + 144), "maroon3" },-
497 { (139*65536 + 28*256 + 98), "maroon4" },-
498 { (102*65536 + 205*256 + 170), "mediumaquamarine" },-
499 { (0*65536 + 0*256 + 205), "mediumblue" },-
500 { (186*65536 + 85*256 + 211), "mediumorchid" },-
501 { (224*65536 + 102*256 + 255), "mediumorchid1" },-
502 { (209*65536 + 95*256 + 238), "mediumorchid2" },-
503 { (180*65536 + 82*256 + 205), "mediumorchid3" },-
504 { (122*65536 + 55*256 + 139), "mediumorchid4" },-
505 { (147*65536 + 112*256 + 219), "mediumpurple" },-
506 { (171*65536 + 130*256 + 255), "mediumpurple1" },-
507 { (159*65536 + 121*256 + 238), "mediumpurple2" },-
508 { (137*65536 + 104*256 + 205), "mediumpurple3" },-
509 { (93*65536 + 71*256 + 139), "mediumpurple4" },-
510 { (60*65536 + 179*256 + 113), "mediumseagreen" },-
511 { (123*65536 + 104*256 + 238), "mediumslateblue" },-
512 { (0*65536 + 250*256 + 154), "mediumspringgreen" },-
513 { (72*65536 + 209*256 + 204), "mediumturquoise" },-
514 { (199*65536 + 21*256 + 133), "mediumvioletred" },-
515 { (25*65536 + 25*256 + 112), "midnightblue" },-
516 { (245*65536 + 255*256 + 250), "mintcream" },-
517 { (255*65536 + 228*256 + 225), "mistyrose" },-
518 { (255*65536 + 228*256 + 225), "mistyrose1" },-
519 { (238*65536 + 213*256 + 210), "mistyrose2" },-
520 { (205*65536 + 183*256 + 181), "mistyrose3" },-
521 { (139*65536 + 125*256 + 123), "mistyrose4" },-
522 { (255*65536 + 228*256 + 181), "moccasin" },-
523 { (255*65536 + 222*256 + 173), "navajowhite" },-
524 { (255*65536 + 222*256 + 173), "navajowhite1" },-
525 { (238*65536 + 207*256 + 161), "navajowhite2" },-
526 { (205*65536 + 179*256 + 139), "navajowhite3" },-
527 { (139*65536 + 121*256 + 94), "navajowhite4" },-
528 { (0*65536 + 0*256 + 128), "navy" },-
529 { (0*65536 + 0*256 + 128), "navyblue" },-
530 { (253*65536 + 245*256 + 230), "oldlace" },-
531 { (107*65536 + 142*256 + 35), "olivedrab" },-
532 { (192*65536 + 255*256 + 62), "olivedrab1" },-
533 { (179*65536 + 238*256 + 58), "olivedrab2" },-
534 { (154*65536 + 205*256 + 50), "olivedrab3" },-
535 { (105*65536 + 139*256 + 34), "olivedrab4" },-
536 { (255*65536 + 165*256 + 0), "orange" },-
537 { (255*65536 + 165*256 + 0), "orange1" },-
538 { (238*65536 + 154*256 + 0), "orange2" },-
539 { (205*65536 + 133*256 + 0), "orange3" },-
540 { (139*65536 + 90*256 + 0), "orange4" },-
541 { (255*65536 + 69*256 + 0), "orangered" },-
542 { (255*65536 + 69*256 + 0), "orangered1" },-
543 { (238*65536 + 64*256 + 0), "orangered2" },-
544 { (205*65536 + 55*256 + 0), "orangered3" },-
545 { (139*65536 + 37*256 + 0), "orangered4" },-
546 { (218*65536 + 112*256 + 214), "orchid" },-
547 { (255*65536 + 131*256 + 250), "orchid1" },-
548 { (238*65536 + 122*256 + 233), "orchid2" },-
549 { (205*65536 + 105*256 + 201), "orchid3" },-
550 { (139*65536 + 71*256 + 137), "orchid4" },-
551 { (238*65536 + 232*256 + 170), "palegoldenrod" },-
552 { (152*65536 + 251*256 + 152), "palegreen" },-
553 { (154*65536 + 255*256 + 154), "palegreen1" },-
554 { (144*65536 + 238*256 + 144), "palegreen2" },-
555 { (124*65536 + 205*256 + 124), "palegreen3" },-
556 { (84*65536 + 139*256 + 84), "palegreen4" },-
557 { (175*65536 + 238*256 + 238), "paleturquoise" },-
558 { (187*65536 + 255*256 + 255), "paleturquoise1" },-
559 { (174*65536 + 238*256 + 238), "paleturquoise2" },-
560 { (150*65536 + 205*256 + 205), "paleturquoise3" },-
561 { (102*65536 + 139*256 + 139), "paleturquoise4" },-
562 { (219*65536 + 112*256 + 147), "palevioletred" },-
563 { (255*65536 + 130*256 + 171), "palevioletred1" },-
564 { (238*65536 + 121*256 + 159), "palevioletred2" },-
565 { (205*65536 + 104*256 + 137), "palevioletred3" },-
566 { (139*65536 + 71*256 + 93), "palevioletred4" },-
567 { (255*65536 + 239*256 + 213), "papayawhip" },-
568 { (255*65536 + 218*256 + 185), "peachpuff" },-
569 { (255*65536 + 218*256 + 185), "peachpuff1" },-
570 { (238*65536 + 203*256 + 173), "peachpuff2" },-
571 { (205*65536 + 175*256 + 149), "peachpuff3" },-
572 { (139*65536 + 119*256 + 101), "peachpuff4" },-
573 { (205*65536 + 133*256 + 63), "peru" },-
574 { (255*65536 + 192*256 + 203), "pink" },-
575 { (255*65536 + 181*256 + 197), "pink1" },-
576 { (238*65536 + 169*256 + 184), "pink2" },-
577 { (205*65536 + 145*256 + 158), "pink3" },-
578 { (139*65536 + 99*256 + 108), "pink4" },-
579 { (221*65536 + 160*256 + 221), "plum" },-
580 { (255*65536 + 187*256 + 255), "plum1" },-
581 { (238*65536 + 174*256 + 238), "plum2" },-
582 { (205*65536 + 150*256 + 205), "plum3" },-
583 { (139*65536 + 102*256 + 139), "plum4" },-
584 { (176*65536 + 224*256 + 230), "powderblue" },-
585 { (160*65536 + 32*256 + 240), "purple" },-
586 { (155*65536 + 48*256 + 255), "purple1" },-
587 { (145*65536 + 44*256 + 238), "purple2" },-
588 { (125*65536 + 38*256 + 205), "purple3" },-
589 { (85*65536 + 26*256 + 139), "purple4" },-
590 { (255*65536 + 0*256 + 0), "red" },-
591 { (255*65536 + 0*256 + 0), "red1" },-
592 { (238*65536 + 0*256 + 0), "red2" },-
593 { (205*65536 + 0*256 + 0), "red3" },-
594 { (139*65536 + 0*256 + 0), "red4" },-
595 { (188*65536 + 143*256 + 143), "rosybrown" },-
596 { (255*65536 + 193*256 + 193), "rosybrown1" },-
597 { (238*65536 + 180*256 + 180), "rosybrown2" },-
598 { (205*65536 + 155*256 + 155), "rosybrown3" },-
599 { (139*65536 + 105*256 + 105), "rosybrown4" },-
600 { (65*65536 + 105*256 + 225), "royalblue" },-
601 { (72*65536 + 118*256 + 255), "royalblue1" },-
602 { (67*65536 + 110*256 + 238), "royalblue2" },-
603 { (58*65536 + 95*256 + 205), "royalblue3" },-
604 { (39*65536 + 64*256 + 139), "royalblue4" },-
605 { (139*65536 + 69*256 + 19), "saddlebrown" },-
606 { (250*65536 + 128*256 + 114), "salmon" },-
607 { (255*65536 + 140*256 + 105), "salmon1" },-
608 { (238*65536 + 130*256 + 98), "salmon2" },-
609 { (205*65536 + 112*256 + 84), "salmon3" },-
610 { (139*65536 + 76*256 + 57), "salmon4" },-
611 { (244*65536 + 164*256 + 96), "sandybrown" },-
612 { (46*65536 + 139*256 + 87), "seagreen" },-
613 { (84*65536 + 255*256 + 159), "seagreen1" },-
614 { (78*65536 + 238*256 + 148), "seagreen2" },-
615 { (67*65536 + 205*256 + 128), "seagreen3" },-
616 { (46*65536 + 139*256 + 87), "seagreen4" },-
617 { (255*65536 + 245*256 + 238), "seashell" },-
618 { (255*65536 + 245*256 + 238), "seashell1" },-
619 { (238*65536 + 229*256 + 222), "seashell2" },-
620 { (205*65536 + 197*256 + 191), "seashell3" },-
621 { (139*65536 + 134*256 + 130), "seashell4" },-
622 { (160*65536 + 82*256 + 45), "sienna" },-
623 { (255*65536 + 130*256 + 71), "sienna1" },-
624 { (238*65536 + 121*256 + 66), "sienna2" },-
625 { (205*65536 + 104*256 + 57), "sienna3" },-
626 { (139*65536 + 71*256 + 38), "sienna4" },-
627 { (135*65536 + 206*256 + 235), "skyblue" },-
628 { (135*65536 + 206*256 + 255), "skyblue1" },-
629 { (126*65536 + 192*256 + 238), "skyblue2" },-
630 { (108*65536 + 166*256 + 205), "skyblue3" },-
631 { (74*65536 + 112*256 + 139), "skyblue4" },-
632 { (106*65536 + 90*256 + 205), "slateblue" },-
633 { (131*65536 + 111*256 + 255), "slateblue1" },-
634 { (122*65536 + 103*256 + 238), "slateblue2" },-
635 { (105*65536 + 89*256 + 205), "slateblue3" },-
636 { (71*65536 + 60*256 + 139), "slateblue4" },-
637 { (112*65536 + 128*256 + 144), "slategray" },-
638 { (198*65536 + 226*256 + 255), "slategray1" },-
639 { (185*65536 + 211*256 + 238), "slategray2" },-
640 { (159*65536 + 182*256 + 205), "slategray3" },-
641 { (108*65536 + 123*256 + 139), "slategray4" },-
642 { (112*65536 + 128*256 + 144), "slategrey" },-
643 { (255*65536 + 250*256 + 250), "snow" },-
644 { (255*65536 + 250*256 + 250), "snow1" },-
645 { (238*65536 + 233*256 + 233), "snow2" },-
646 { (205*65536 + 201*256 + 201), "snow3" },-
647 { (139*65536 + 137*256 + 137), "snow4" },-
648 { (0*65536 + 255*256 + 127), "springgreen" },-
649 { (0*65536 + 255*256 + 127), "springgreen1" },-
650 { (0*65536 + 238*256 + 118), "springgreen2" },-
651 { (0*65536 + 205*256 + 102), "springgreen3" },-
652 { (0*65536 + 139*256 + 69), "springgreen4" },-
653 { (70*65536 + 130*256 + 180), "steelblue" },-
654 { (99*65536 + 184*256 + 255), "steelblue1" },-
655 { (92*65536 + 172*256 + 238), "steelblue2" },-
656 { (79*65536 + 148*256 + 205), "steelblue3" },-
657 { (54*65536 + 100*256 + 139), "steelblue4" },-
658 { (210*65536 + 180*256 + 140), "tan" },-
659 { (255*65536 + 165*256 + 79), "tan1" },-
660 { (238*65536 + 154*256 + 73), "tan2" },-
661 { (205*65536 + 133*256 + 63), "tan3" },-
662 { (139*65536 + 90*256 + 43), "tan4" },-
663 { (216*65536 + 191*256 + 216), "thistle" },-
664 { (255*65536 + 225*256 + 255), "thistle1" },-
665 { (238*65536 + 210*256 + 238), "thistle2" },-
666 { (205*65536 + 181*256 + 205), "thistle3" },-
667 { (139*65536 + 123*256 + 139), "thistle4" },-
668 { (255*65536 + 99*256 + 71), "tomato" },-
669 { (255*65536 + 99*256 + 71), "tomato1" },-
670 { (238*65536 + 92*256 + 66), "tomato2" },-
671 { (205*65536 + 79*256 + 57), "tomato3" },-
672 { (139*65536 + 54*256 + 38), "tomato4" },-
673 { (64*65536 + 224*256 + 208), "turquoise" },-
674 { (0*65536 + 245*256 + 255), "turquoise1" },-
675 { (0*65536 + 229*256 + 238), "turquoise2" },-
676 { (0*65536 + 197*256 + 205), "turquoise3" },-
677 { (0*65536 + 134*256 + 139), "turquoise4" },-
678 { (238*65536 + 130*256 + 238), "violet" },-
679 { (208*65536 + 32*256 + 144), "violetred" },-
680 { (255*65536 + 62*256 + 150), "violetred1" },-
681 { (238*65536 + 58*256 + 140), "violetred2" },-
682 { (205*65536 + 50*256 + 120), "violetred3" },-
683 { (139*65536 + 34*256 + 82), "violetred4" },-
684 { (245*65536 + 222*256 + 179), "wheat" },-
685 { (255*65536 + 231*256 + 186), "wheat1" },-
686 { (238*65536 + 216*256 + 174), "wheat2" },-
687 { (205*65536 + 186*256 + 150), "wheat3" },-
688 { (139*65536 + 126*256 + 102), "wheat4" },-
689 { (255*65536 + 255*256 + 255), "white" },-
690 { (245*65536 + 245*256 + 245), "whitesmoke" },-
691 { (255*65536 + 255*256 + 0), "yellow" },-
692 { (255*65536 + 255*256 + 0), "yellow1" },-
693 { (238*65536 + 238*256 + 0), "yellow2" },-
694 { (205*65536 + 205*256 + 0), "yellow3" },-
695 { (139*65536 + 139*256 + 0), "yellow4" },-
696 { (154*65536 + 205*256 + 50), "yellowgreen" } };-
697-
698-
699-
700-
701-
702-
703inline bool operator<(const char *name, const XPMRGBData &data)-
704{ return qstrcmp(name, data.name) < 0; }-
705inline bool operator<(const XPMRGBData &data, const char *name)-
706{ return qstrcmp(data.name, name) < 0; }-
707-
708static inline bool qt_get_named_xpm_rgb(const char *name_no_space, QRgb *rgb)-
709{-
710 const XPMRGBData *r = std::lower_bound(xpmRgbTbl, xpmRgbTbl + xpmRgbTblSize, name_no_space);-
711 if ((r != xpmRgbTbl + xpmRgbTblSize) && !(name_no_space < *r)) {-
712 *rgb = r->value;-
713 return true;-
714 } else {-
715 return false;-
716 }-
717}-
718-
719-
720-
721-
722static QString fbname(const QString &fileName)-
723{-
724 QString s = fileName;-
725 if (!s.isEmpty()) {-
726 int i;-
727 if ((i = s.lastIndexOf(QLatin1Char('/'))) >= 0)-
728 s = s.mid(i);-
729 if ((i = s.lastIndexOf(QLatin1Char('\\'))) >= 0)-
730 s = s.mid(i);-
731 QRegExp r(QLatin1String("[a-zA-Z][a-zA-Z0-9_]*"));-
732 int p = r.indexIn(s);-
733 if (p == -1)-
734 s.clear();-
735 else-
736 s = s.mid(p, r.matchedLength());-
737 }-
738 if (s.isEmpty())-
739 s = QString::fromLatin1("dummy");-
740 return s;-
741}-
742-
743-
744-
745-
746static bool read_xpm_string(QByteArray &buf, QIODevice *d, const char * const *source, int &index,-
747 QByteArray &state)-
748{-
749 if (source) {-
750 buf = source[index++];-
751 return true;-
752 }-
753-
754 buf = "";-
755 bool gotQuote = false;-
756 int offset = 0;-
757 for(;;) {-
758 if (offset == state.size() || state.isEmpty()) {-
759 char buf[2048];-
760 qint64 bytesRead = d->read(buf, sizeof(buf));-
761 if (bytesRead <= 0)-
762 return false;-
763 state = QByteArray(buf, int(bytesRead));-
764 offset = 0;-
765 }-
766-
767 if (!gotQuote) {-
768 if (state.at(offset++) == '"')-
769 gotQuote = true;-
770 } else {-
771 char c = state.at(offset++);-
772 if (c == '"')-
773 break;-
774 buf += c;-
775 }-
776 }-
777 state.remove(0, offset);-
778 return true;-
779}-
780-
781-
782-
783static bool is_xpm_color_spec_prefix(const QByteArray& prefix)-
784{-
785 return prefix == "c" ||-
786 prefix == "g" ||-
787 prefix == "g4" ||-
788 prefix == "m" ||-
789 prefix == "s";-
790}-
791-
792-
793-
794static bool read_xpm_header(-
795 QIODevice *device, const char * const * source, int& index, QByteArray &state,-
796 int *cpp, int *ncols, int *w, int *h)-
797{-
798 QByteArray buf(200, 0);-
799-
800 if (!read_xpm_string(buf, device, source, index, state)
!read_xpm_stri... index, state)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
801 return
never executed: return false;
false;
never executed: return false;
0
802-
803-
804-
805-
806 if (sscanf(buf, "%d %d %d %d", w, h, ncols, cpp) < 4
sscanf(buf, "%...cols, cpp) < 4Description
TRUEnever evaluated
FALSEnever evaluated
)
0
807-
808 return
never executed: return false;
false;
never executed: return false;
0
809-
810 if (*w <= 0 || *w > 32767 || *h <= 0 || *h > 32767 || *ncols <= 0 || *ncols > (64 * 64 * 64 * 64) || *cpp <= 0 || *cpp > 15)0
return false;return
never executed: return true;
true;
never executed: return true;
811}-
812-
813-
814-
815static bool read_xpm_body(-
816 QIODevice *device, const char * const * source, int& index, QByteArray& state,-
817 int cpp, int ncols, int w, int h, QImage& image)-
818{-
819 QByteArray buf(200, 0);-
820 int i;-
821-
822 if (cpp < 0 || cpp > 15)-
823 return false;-
824-
825-
826-
827-
828-
829 if (ncols <= 256) {-
830 if (image.size() != QSize(w, h) || image.format() != QImage::Format_Indexed8) {-
831 image = QImage(w, h, QImage::Format_Indexed8);-
832 if (image.isNull())-
833 return false;-
834 }-
835 image.setColorCount(ncols);-
836 }-
837-
838 QMap<quint64, int> colorMap;-
839 int currentColor;-
840 bool hasTransparency = false;-
841-
842 for(currentColor=0; currentColor < ncols; ++currentColor) {-
843 if (!read_xpm_string(buf, device, source, index, state)) {-
844 QMessageLogger(__FILE__, 886889, __PRETTY_FUNCTION__).warning("QImage: XPM color specification missing");-
845 return false;-
846 }-
847 QByteArray index;-
848 index = buf.left(cpp);-
849 buf = buf.mid(cpp).simplified().trimmed().toLower();-
850 QList<QByteArray> tokens = buf.split(' ');-
851 i = tokens.indexOf("c");-
852 if (i < 0)-
853 i = tokens.indexOf("g");-
854 if (i < 0)-
855 i = tokens.indexOf("g4");-
856 if (i < 0)-
857 i = tokens.indexOf("m");-
858 if (i < 0) {-
859 QMessageLogger(__FILE__, 901904, __PRETTY_FUNCTION__).warning("QImage: XPM color specification is missing: %s", buf.constData());-
860 return false;-
861 }-
862 QByteArray color;-
863 while ((++i < tokens.size()) && !is_xpm_color_spec_prefix(tokens.at(i))) {-
864 color.append(tokens.at(i));-
865 }-
866 if (color.isEmpty()) {-
867 QMessageLogger(__FILE__, 909912, __PRETTY_FUNCTION__).warning("QImage: XPM color value is missing from specification: %s", buf.constData());-
868 return false;-
869 }-
870 buf = color;-
871 if (buf == "none") {-
872 hasTransparency = true;-
873 int transparentColor = currentColor;-
874 if (ncols <= 256) {-
875 image.setColor(transparentColor, 0);-
876 colorMap.insert(xpmHash(QLatin1String(index.constData())), transparentColor);-
877 } else {-
878 colorMap.insert(xpmHash(QLatin1String(index.constData())), 0);-
879 }-
880 } else {-
881 QRgb c_rgb;-
882 if (((buf.length()-1) % 3) && (buf[0] == '#')) {-
883 buf.truncate(((buf.length()-1) / 4 * 3) + 1);-
884 }-
885 if (buf[0] == '#') {-
886 qt_get_hex_rgb(buf, &c_rgb);-
887 } else {-
888 qt_get_named_xpm_rgb(buf, &c_rgb);-
889 }-
890 if (ncols <= 256) {-
891 image.setColor(currentColor, 0xff000000 | c_rgb);-
892 colorMap.insert(xpmHash(QLatin1String(index.constData())), currentColor);-
893 } else {-
894 colorMap.insert(xpmHash(QLatin1String(index.constData())), 0xff000000 | c_rgb);-
895 }-
896 }-
897 }-
898-
899 if (ncols > 256) {-
900-
901 QImage::Format format = hasTransparency ?-
902 QImage::Format_ARGB32 : QImage::Format_RGB32;-
903 if (image.size() != QSize(w, h) || image.format() != format) {-
904 image = QImage(w, h, format);-
905 if (image.isNull())-
906 return false;-
907 }-
908 }-
909-
910-
911 for(int y=0; y<h; y++) {-
912 if (!read_xpm_string(buf, device, source, index, state)) {-
913 QMessageLogger(__FILE__, 955958, __PRETTY_FUNCTION__).warning("QImage: XPM pixels missing on image line %d", y);-
914 return false;-
915 }-
916 if (image.depth() == 8) {-
917 uchar *p = image.scanLine(y);-
918 uchar *d = (uchar *)buf.data();-
919 uchar *end = d + buf.length();-
920 int x;-
921 if (cpp == 1) {-
922 char b[2];-
923 b[1] = '\0';-
924 for (x=0; x<w && d<end; x++) {-
925 b[0] = *d++;-
926 *p++ = (uchar)colorMap[xpmHash(b)];-
927 }-
928 } else {-
929 char b[16];-
930 b[cpp] = '\0';-
931 for (x=0; x<w && d<end; x++) {-
932 memcpy(b, (char *)d, cpp);-
933 *p++ = (uchar)colorMap[xpmHash(b)];-
934 d += cpp;-
935 }-
936 }-
937-
938 if (x < w) {-
939 QMessageLogger(__FILE__, 981984, __PRETTY_FUNCTION__).warning("QImage: XPM pixels missing on image line %d (possibly a C++ trigraph).", y);-
940 memset(p, 0, w - x);-
941 }-
942 } else {-
943 QRgb *p = (QRgb*)image.scanLine(y);-
944 uchar *d = (uchar *)buf.data();-
945 uchar *end = d + buf.length();-
946 int x;-
947 char b[16];-
948 b[cpp] = '\0';-
949 for (x=0; x<w && d<end; x++) {-
950 memcpy(b, (char *)d, cpp);-
951 *p++ = (QRgb)colorMap[xpmHash(b)];-
952 d += cpp;-
953 }-
954-
955 if (x < w) {-
956 QMessageLogger(__FILE__, 9981001, __PRETTY_FUNCTION__).warning("QImage: XPM pixels missing on image line %d (possibly a C++ trigraph).", y);-
957 memset(p, 0, (w - x)*4);-
958 }-
959 }-
960 }-
961-
962 if (device) {-
963-
964 for (int i = state.size() - 1; i >= 0; --i)-
965 device->ungetChar(state[i]);-
966 char c;-
967 while (device->getChar(&c) && c != ';') {}-
968 while (device->getChar(&c) && c != '\n') {}-
969 }-
970 return true;-
971}-
972bool qt_read_xpm_image_or_array(QIODevice *device, const char * const * source, QImage &image)-
973{-
974 if (!source)-
975 return true;-
976-
977 QByteArray buf(200, 0);-
978 QByteArray state;-
979-
980 int cpp, ncols, w, h, index = 0;-
981-
982 if (device) {-
983-
984 int readBytes;-
985 if ((readBytes = device->readLine(buf.data(), buf.size())) < 0)-
986 return false;-
987-
988 if (buf.indexOf("/* XPM") != 0) {-
989 while (readBytes > 0) {-
990 device->ungetChar(buf.at(readBytes - 1));-
991 --readBytes;-
992 }-
993 return false;-
994 }-
995 }-
996-
997 if (!read_xpm_header(device, source, index, state, &cpp, &ncols, &w, &h))-
998 return false;-
999-
1000 return read_xpm_body(device, source, index, state, cpp, ncols, w, h, image);-
1001}-
1002-
1003static const char* xpm_color_name(int cpp, int index)-
1004{-
1005 static char returnable[5];-
1006 static const char code[] = ".#abcdefghijklmnopqrstuvwxyzABCD"-
1007 "EFGHIJKLMNOPQRSTUVWXYZ0123456789";-
1008-
1009 if (cpp > 1) {-
1010 if (cpp > 2) {-
1011 if (cpp > 3) {-
1012 returnable[3] = code[index % 64];-
1013 index /= 64;-
1014 } else-
1015 returnable[3] = '\0';-
1016 returnable[2] = code[index % 64];-
1017 index /= 64;-
1018 } else-
1019 returnable[2] = '\0';-
1020-
1021 if (index == 0)-
1022 index = 64*44+21;-
1023 else if (index == 64*44+21)-
1024 index = 0;-
1025 returnable[1] = code[index % 64];-
1026 index /= 64;-
1027 } else-
1028 returnable[1] = '\0';-
1029 returnable[0] = code[index];-
1030-
1031 return returnable;-
1032}-
1033-
1034-
1035-
1036static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const QString &fileName)-
1037{-
1038 if (!device->isWritable()
!device->isWritable()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1039 return
never executed: return false;
false;
never executed: return false;
0
1040-
1041 QImage image;-
1042 if (sourceImage.format() != QImage::Format_RGB32
sourceImage.fo...::Format_RGB32Description
TRUEnever evaluated
FALSEnever evaluated
&& sourceImage.format() != QImage::Format_ARGB32
sourceImage.fo...:Format_ARGB32Description
TRUEnever evaluated
FALSEnever evaluated
&& sourceImage.format() != QImage::Format_ARGB32_Premultiplied
sourceImage.fo..._PremultipliedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1043 image = sourceImage.convertToFormat(QImage::Format_RGB32);
never executed: image = sourceImage.convertToFormat(QImage::Format_RGB32);
0
1044 else-
1045 image = sourceImage;
never executed: image = sourceImage;
0
1046-
1047 QMap<QRgb, int> colorMap;-
1048-
1049 int w = image.width(), h = image.height(), ncolors = 0;-
1050 int x, y;-
1051-
1052-
1053 for(y=0; y<h
y<hDescription
TRUEnever evaluated
FALSEnever evaluated
; y++) {
0
1054 const QRgb *yp = reinterpret_cast<const QRgb *>(image.constScanLine(y));-
1055 for(x=0; x<w
x<wDescription
TRUEnever evaluated
FALSEnever evaluated
; x++) {
0
1056 QRgb color = *(yp + x);-
1057 if (!colorMap.contains(color)
!colorMap.contains(color)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1058 colorMap.insert(color, ncolors++);
never executed: colorMap.insert(color, ncolors++);
0
1059 }
never executed: end of block
0
1060 }
never executed: end of block
0
1061-
1062-
1063 int cpp = 1;-
1064 for (int k = 64; ncolors > k
ncolors > kDescription
TRUEnever evaluated
FALSEnever evaluated
; k *= 64) {
0
1065 ++cpp;-
1066-
1067-
1068 if (cpp > 4
cpp > 4Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1069 break;
never executed: break;
0
1070 }
never executed: end of block
0
1071-
1072 QString line;-
1073-
1074-
1075 QTextStream s(device);-
1076 s << "/* XPM */" << endl-
1077 << "static char *" << fbname(fileName) << "[]={" << endl-
1078 << '\"' << w << ' ' << h << ' ' << ncolors << ' ' << cpp << '\"';-
1079-
1080-
1081 QMap<QRgb, int>::Iterator c = colorMap.begin();-
1082 while (c != colorMap.end()
c != colorMap.end()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1083 QRgb color = c.key();-
1084 if (image.format() != QImage::Format_RGB32
image.format()...::Format_RGB32Description
TRUEnever evaluated
FALSEnever evaluated
&& !qAlpha(color)
!qAlpha(color)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1085 line = QString::asprintf("\"%s c None\"",
never executed: line = QString::asprintf("\"%s c None\"", xpm_color_name(cpp, *c));
0
1086 xpm_color_name(cpp, *c));
never executed: line = QString::asprintf("\"%s c None\"", xpm_color_name(cpp, *c));
0
1087 else-
1088 line = QString::asprintf("\"%s c #%02x%02x%02x\"",
never executed: line = QString::asprintf("\"%s c #%02x%02x%02x\"", xpm_color_name(cpp, *c), qRed(color), qGreen(color), qBlue(color));
0
1089 xpm_color_name(cpp, *c),
never executed: line = QString::asprintf("\"%s c #%02x%02x%02x\"", xpm_color_name(cpp, *c), qRed(color), qGreen(color), qBlue(color));
0
1090 qRed(color),
never executed: line = QString::asprintf("\"%s c #%02x%02x%02x\"", xpm_color_name(cpp, *c), qRed(color), qGreen(color), qBlue(color));
0
1091 qGreen(color),
never executed: line = QString::asprintf("\"%s c #%02x%02x%02x\"", xpm_color_name(cpp, *c), qRed(color), qGreen(color), qBlue(color));
0
1092 qBlue(color));
never executed: line = QString::asprintf("\"%s c #%02x%02x%02x\"", xpm_color_name(cpp, *c), qRed(color), qGreen(color), qBlue(color));
0
1093 ++c;-
1094 s << ',' << endl << line;-
1095 }
never executed: end of block
0
1096-
1097-
1098 line.truncate(cpp*w);-
1099 for(y=0; y<h
y<hDescription
TRUEnever evaluated
FALSEnever evaluated
; y++) {
0
1100 const QRgb *yp = reinterpret_cast<const QRgb *>(image.constScanLine(y));-
1101 int cc = 0;-
1102 for(x=0; x<w
x<wDescription
TRUEnever evaluated
FALSEnever evaluated
; x++) {
0
1103 int color = (int)(*(yp + x));-
1104 const QByteArray chars(xpm_color_name(cpp, colorMap[color]));-
1105 line[cc++] = QLatin1Char(chars[0]);-
1106 if (cpp > 1
cpp > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1107 line[cc++] = QLatin1Char(chars[1]);-
1108 if (cpp > 2
cpp > 2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1109 line[cc++] = QLatin1Char(chars[2]);-
1110 if (cpp > 3
cpp > 3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1111 line[cc++] = QLatin1Char(chars[3]);-
1112 }
never executed: end of block
0
1113 }
never executed: end of block
0
1114 }
never executed: end of block
0
1115 }
never executed: end of block
0
1116 s << ',' << endl << '\"' << line << '\"';-
1117 }
never executed: end of block
0
1118 s << "};" << endl;-
1119 return
never executed: return (s.status() == QTextStream::Ok);
(s.status() == QTextStream::Ok);
never executed: return (s.status() == QTextStream::Ok);
0
1120}-
1121-
1122QXpmHandler::QXpmHandler()-
1123 : state(Ready), index(0)-
1124{-
1125}-
1126-
1127bool QXpmHandler::readHeader()-
1128{-
1129 state = Error;-
1130 if (!read_xpm_header(device(), 0, index, buffer, &cpp, &ncols, &width, &height))-
1131 return false;-
1132 state = ReadHeader;-
1133 return true;-
1134}-
1135-
1136bool QXpmHandler::readImage(QImage *image)-
1137{-
1138 if (state == Error)-
1139 return false;-
1140-
1141 if (state == Ready && !readHeader()) {-
1142 state = Error;-
1143 return false;-
1144 }-
1145-
1146 if (!read_xpm_body(device(), 0, index, buffer, cpp, ncols, width, height, *image)) {-
1147 state = Error;-
1148 return false;-
1149 }-
1150-
1151 state = Ready;-
1152 return true;-
1153}-
1154-
1155bool QXpmHandler::canRead() const-
1156{-
1157 if (state == Ready && !canRead(device()))-
1158 return false;-
1159-
1160 if (state != Error) {-
1161 setFormat("xpm");-
1162 return true;-
1163 }-
1164-
1165 return false;-
1166}-
1167-
1168bool QXpmHandler::canRead(QIODevice *device)-
1169{-
1170 if (!device) {-
1171 QMessageLogger(__FILE__, 12211224, __PRETTY_FUNCTION__).warning("QXpmHandler::canRead() called with no device");-
1172 return false;-
1173 }-
1174-
1175 char head[6];-
1176 if (device->peek(head, sizeof(head)) != sizeof(head))-
1177 return false;-
1178-
1179 return qstrncmp(head, "/* XPM", 6) == 0;-
1180}-
1181-
1182bool QXpmHandler::read(QImage *image)-
1183{-
1184 if (!canRead())-
1185 return false;-
1186 return readImage(image);-
1187}-
1188-
1189bool QXpmHandler::write(const QImage &image)-
1190{-
1191 return write_xpm_image(image, device(), fileName);-
1192}-
1193-
1194bool QXpmHandler::supportsOption(ImageOption option) const-
1195{-
1196 return option == Name-
1197 || option == Size-
1198 || option == ImageFormat;-
1199}-
1200-
1201QVariant QXpmHandler::option(ImageOption option) const-
1202{-
1203 if (option == Name) {-
1204 return fileName;-
1205 } else if (option == Size) {-
1206 if (state == Error)-
1207 return QVariant();-
1208 if (state == Ready && !const_cast<QXpmHandler*>(this)->readHeader())-
1209 return QVariant();-
1210 return QSize(width, height);-
1211 } else if (option == ImageFormat) {-
1212 if (state == Error)-
1213 return QVariant();-
1214 if (state == Ready && !const_cast<QXpmHandler*>(this)->readHeader())-
1215 return QVariant();-
1216-
1217-
1218-
1219-
1220 if (ncols <= 256)-
1221 return QImage::Format_Indexed8;-
1222 else-
1223 return QImage::Format_Invalid;-
1224 }-
1225-
1226 return QVariant();-
1227}-
1228-
1229void QXpmHandler::setOption(ImageOption option, const QVariant &value)-
1230{-
1231 if (option == Name)-
1232 fileName = value.toString();-
1233}-
1234-
1235QByteArray QXpmHandler::name() const-
1236{-
1237 return "xpm";-
1238}-
1239-
1240-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9