image/qbmphandler.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7static void swapPixel01(QImage *image) -
8{ -
9 int i; -
10 if (image->depth() == 1 && image->colorCount() == 2) {
never evaluated: image->depth() == 1
never evaluated: image->colorCount() == 2
0
11 register uint *p = (uint *)image->bits(); -
12 int nbytes = image->byteCount(); -
13 for (i=0; i<nbytes/4; i++) {
never evaluated: i<nbytes/4
0
14 *p = ~*p; -
15 p++; -
16 }
never executed: }
0
17 uchar *p2 = (uchar *)p; -
18 for (i=0; i<(nbytes&3); i++) {
never evaluated: i<(nbytes&3)
0
19 *p2 = ~*p2; -
20 p2++; -
21 }
never executed: }
0
22 QRgb t = image->color(0); -
23 image->setColor(0, image->color(1)); -
24 image->setColor(1, t); -
25 }
never executed: }
0
26}
never executed: }
0
27const int BMP_FILEHDR_SIZE = 14; -
28 -
29static QDataStream &operator>>(QDataStream &s, BMP_FILEHDR &bf) -
30{ -
31 s.readRawData(bf.bfType, 2); -
32 s >> bf.bfSize >> bf.bfReserved1 >> bf.bfReserved2 >> bf.bfOffBits; -
33 return s;
executed: return s;
Execution Count:341
341
34} -
35 -
36static QDataStream &operator<<(QDataStream &s, const BMP_FILEHDR &bf) -
37{ -
38 s.writeRawData(bf.bfType, 2); -
39 s << bf.bfSize << bf.bfReserved1 << bf.bfReserved2 << bf.bfOffBits; -
40 return s;
executed: return s;
Execution Count:32
32
41} -
42 -
43 -
44const int BMP_OLD = 12; -
45const int BMP_WIN = 40; -
46const int BMP_OS2 = 64; -
47const int BMP_WIN4 = 108; -
48const int BMP_WIN5 = 124; -
49 -
50const int BMP_RGB = 0; -
51const int BMP_RLE8 = 1; -
52const int BMP_RLE4 = 2; -
53const int BMP_BITFIELDS = 3; -
54 -
55 -
56static QDataStream &operator>>(QDataStream &s, BMP_INFOHDR &bi) -
57{ -
58 s >> bi.biSize; -
59 if (bi.biSize == BMP_WIN || bi.biSize == BMP_OS2 || bi.biSize == BMP_WIN4 || bi.biSize == BMP_WIN5) {
evaluated: bi.biSize == BMP_WIN
TRUEFALSE
yes
Evaluation Count:247
yes
Evaluation Count:74
partially evaluated: bi.biSize == BMP_OS2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:74
evaluated: bi.biSize == BMP_WIN4
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:37
partially evaluated: bi.biSize == BMP_WIN5
TRUEFALSE
yes
Evaluation Count:37
no
Evaluation Count:0
0-247
60 s >> bi.biWidth >> bi.biHeight >> bi.biPlanes >> bi.biBitCount; -
61 s >> bi.biCompression >> bi.biSizeImage; -
62 s >> bi.biXPelsPerMeter >> bi.biYPelsPerMeter; -
63 s >> bi.biClrUsed >> bi.biClrImportant; -
64 }
executed: }
Execution Count:321
321
65 else { -
66 qint16 w, h; -
67 s >> w >> h >> bi.biPlanes >> bi.biBitCount; -
68 bi.biWidth = w; -
69 bi.biHeight = h; -
70 bi.biCompression = BMP_RGB; -
71 bi.biSizeImage = 0; -
72 bi.biXPelsPerMeter = bi.biYPelsPerMeter = 0; -
73 bi.biClrUsed = bi.biClrImportant = 0; -
74 }
never executed: }
0
75 return s;
executed: return s;
Execution Count:321
321
76} -
77 -
78static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi) -
79{ -
80 s << bi.biSize; -
81 s << bi.biWidth << bi.biHeight; -
82 s << bi.biPlanes; -
83 s << bi.biBitCount; -
84 s << bi.biCompression; -
85 s << bi.biSizeImage; -
86 s << bi.biXPelsPerMeter << bi.biYPelsPerMeter; -
87 s << bi.biClrUsed << bi.biClrImportant; -
88 return s;
executed: return s;
Execution Count:32
32
89} -
90 -
91static int calc_shift(uint mask) -
92{ -
93 int result = 0; -
94 while (mask && !(mask & 1)) {
partially evaluated: mask
TRUEFALSE
yes
Evaluation Count:1321
no
Evaluation Count:0
evaluated: !(mask & 1)
TRUEFALSE
yes
Evaluation Count:1192
yes
Evaluation Count:129
0-1321
95 result++; -
96 mask >>= 1; -
97 }
executed: }
Execution Count:1192
1192
98 return result;
executed: return result;
Execution Count:129
129
99} -
100 -
101static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf) -
102{ -
103 -
104 s >> bf; -
105 if (s.status() != QDataStream::Ok)
evaluated: s.status() != QDataStream::Ok
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:321
20-321
106 return false;
executed: return false;
Execution Count:20
20
107 -
108 -
109 if (qstrncmp(bf.bfType,"BM",2) != 0)
partially evaluated: qstrncmp(bf.bfType,"BM",2) != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:321
0-321
110 return false;
never executed: return false;
0
111 -
112 return true;
executed: return true;
Execution Count:321
321
113} -
114 -
115static bool read_dib_infoheader(QDataStream &s, BMP_INFOHDR &bi) -
116{ -
117 s >> bi; -
118 if (s.status() != QDataStream::Ok)
partially evaluated: s.status() != QDataStream::Ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:321
0-321
119 return false;
never executed: return false;
0
120 -
121 int nbits = bi.biBitCount; -
122 int comp = bi.biCompression; -
123 if (!(nbits == 1 || nbits == 4 || nbits == 8 || nbits == 16 || nbits == 24 || nbits == 32) ||
evaluated: nbits == 1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:319
evaluated: nbits == 4
TRUEFALSE
yes
Evaluation Count:88
yes
Evaluation Count:231
evaluated: nbits == 8
TRUEFALSE
yes
Evaluation Count:88
yes
Evaluation Count:143
evaluated: nbits == 16
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:123
evaluated: nbits == 24
TRUEFALSE
yes
Evaluation Count:78
yes
Evaluation Count:45
partially evaluated: nbits == 32
TRUEFALSE
yes
Evaluation Count:45
no
Evaluation Count:0
0-319
124 bi.biPlanes != 1 || comp > BMP_BITFIELDS)
partially evaluated: bi.biPlanes != 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:321
partially evaluated: comp > BMP_BITFIELDS
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:321
0-321
125 return false;
never executed: return false;
0
126 if (!(comp == BMP_RGB || (nbits == 4 && comp == BMP_RLE4) ||
evaluated: comp == BMP_RGB
TRUEFALSE
yes
Evaluation Count:223
yes
Evaluation Count:98
evaluated: nbits == 4
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:65
partially evaluated: comp == BMP_RLE4
TRUEFALSE
yes
Evaluation Count:33
no
Evaluation Count:0
0-223
127 (nbits == 8 && comp == BMP_RLE8) || ((nbits == 16 || nbits == 32) && comp == BMP_BITFIELDS)))
evaluated: nbits == 8
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:45
partially evaluated: comp == BMP_RLE8
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
partially evaluated: nbits == 16
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:45
partially evaluated: nbits == 32
TRUEFALSE
yes
Evaluation Count:45
no
Evaluation Count:0
partially evaluated: comp == BMP_BITFIELDS
TRUEFALSE
yes
Evaluation Count:45
no
Evaluation Count:0
0-45
128 return false;
never executed: return false;
0
129 -
130 return true;
executed: return true;
Execution Count:321
321
131} -
132 -
133static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int startpos, QImage &image) -
134{ -
135 QIODevice* d = s.device(); -
136 if (d->atEnd())
partially evaluated: d->atEnd()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:313
0-313
137 return false;
never executed: return false;
0
138 int w = bi.biWidth, h = bi.biHeight, nbits = bi.biBitCount; -
139 int t = bi.biSize, comp = bi.biCompression; -
140 uint red_mask = 0; -
141 uint green_mask = 0; -
142 uint blue_mask = 0; -
143 int red_shift = 0; -
144 int green_shift = 0; -
145 int blue_shift = 0; -
146 int red_scale = 0; -
147 int green_scale = 0; -
148 int blue_scale = 0; -
149 -
150 int ncols = 0; -
151 int depth = 0; -
152 QImage::Format format; -
153 switch (nbits) { -
154 case 32: -
155 case 24: -
156 case 16: -
157 depth = 32; -
158 format = QImage::Format_RGB32; -
159 break;
executed: break;
Execution Count:139
139
160 case 8: -
161 case 4: -
162 depth = 8; -
163 format = QImage::Format_Indexed8; -
164 break;
executed: break;
Execution Count:172
172
165 default: -
166 depth = 1; -
167 format = QImage::Format_Mono; -
168 }
executed: }
Execution Count:2
2
169 -
170 if (bi.biHeight < 0)
evaluated: bi.biHeight < 0
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:293
20-293
171 h = -h;
executed: h = -h;
Execution Count:20
20
172 -
173 if (image.size() != QSize(w, h) || image.format() != format) {
partially evaluated: image.size() != QSize(w, h)
TRUEFALSE
yes
Evaluation Count:313
no
Evaluation Count:0
never evaluated: image.format() != format
0-313
174 image = QImage(w, h, format); -
175 if (image.isNull())
partially evaluated: image.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:313
0-313
176 return false;
never executed: return false;
0
177 }
executed: }
Execution Count:313
313
178 -
179 if (depth != 32) {
evaluated: depth != 32
TRUEFALSE
yes
Evaluation Count:174
yes
Evaluation Count:139
139-174
180 ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits;
evaluated: bi.biClrUsed
TRUEFALSE
yes
Evaluation Count:163
yes
Evaluation Count:11
11-163
181 if (ncols > 256)
partially evaluated: ncols > 256
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:174
0-174
182 return false;
never executed: return false;
0
183 image.setColorCount(ncols); -
184 }
executed: }
Execution Count:174
174
185 -
186 image.setDotsPerMeterX(bi.biXPelsPerMeter); -
187 image.setDotsPerMeterY(bi.biYPelsPerMeter); -
188 -
189 if (!d->isSequential())
evaluated: !d->isSequential()
TRUEFALSE
yes
Evaluation Count:309
yes
Evaluation Count:4
4-309
190 d->seek(startpos + BMP_FILEHDR_SIZE + (bi.biSize >= BMP_WIN4? BMP_WIN : bi.biSize));
executed: d->seek(startpos + BMP_FILEHDR_SIZE + (bi.biSize >= BMP_WIN4? BMP_WIN : bi.biSize));
Execution Count:309
309
191 -
192 if (bi.biSize >= BMP_WIN4 || (comp == BMP_BITFIELDS && (nbits == 16 || nbits == 32))) {
evaluated: bi.biSize >= BMP_WIN4
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:243
evaluated: comp == BMP_BITFIELDS
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:235
partially evaluated: nbits == 16
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
partially evaluated: nbits == 32
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-243
193 if (d->read((char *)&red_mask, sizeof(red_mask)) != sizeof(red_mask))
partially evaluated: d->read((char *)&red_mask, sizeof(red_mask)) != sizeof(red_mask)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:78
0-78
194 return false;
never executed: return false;
0
195 if (d->read((char *)&green_mask, sizeof(green_mask)) != sizeof(green_mask))
partially evaluated: d->read((char *)&green_mask, sizeof(green_mask)) != sizeof(green_mask)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:78
0-78
196 return false;
never executed: return false;
0
197 if (d->read((char *)&blue_mask, sizeof(blue_mask)) != sizeof(blue_mask))
partially evaluated: d->read((char *)&blue_mask, sizeof(blue_mask)) != sizeof(blue_mask)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:78
0-78
198 return false;
never executed: return false;
0
199 -
200 -
201 if (bi.biSize >= BMP_WIN4) {
evaluated: bi.biSize >= BMP_WIN4
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:8
8-70
202 int alpha_mask = 0; -
203 int CSType = 0; -
204 int gamma_red = 0; -
205 int gamma_green = 0; -
206 int gamma_blue = 0; -
207 int endpoints[9]; -
208 -
209 if (d->read((char *)&alpha_mask, sizeof(alpha_mask)) != sizeof(alpha_mask))
partially evaluated: d->read((char *)&alpha_mask, sizeof(alpha_mask)) != sizeof(alpha_mask)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:70
0-70
210 return false;
never executed: return false;
0
211 if (d->read((char *)&CSType, sizeof(CSType)) != sizeof(CSType))
partially evaluated: d->read((char *)&CSType, sizeof(CSType)) != sizeof(CSType)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:70
0-70
212 return false;
never executed: return false;
0
213 if (d->read((char *)&endpoints, sizeof(endpoints)) != sizeof(endpoints))
partially evaluated: d->read((char *)&endpoints, sizeof(endpoints)) != sizeof(endpoints)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:70
0-70
214 return false;
never executed: return false;
0
215 if (d->read((char *)&gamma_red, sizeof(gamma_red)) != sizeof(gamma_red))
partially evaluated: d->read((char *)&gamma_red, sizeof(gamma_red)) != sizeof(gamma_red)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:70
0-70
216 return false;
never executed: return false;
0
217 if (d->read((char *)&gamma_green, sizeof(gamma_green)) != sizeof(gamma_green))
partially evaluated: d->read((char *)&gamma_green, sizeof(gamma_green)) != sizeof(gamma_green)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:70
0-70
218 return false;
never executed: return false;
0
219 if (d->read((char *)&gamma_blue, sizeof(gamma_blue)) != sizeof(gamma_blue))
partially evaluated: d->read((char *)&gamma_blue, sizeof(gamma_blue)) != sizeof(gamma_blue)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:70
0-70
220 return false;
never executed: return false;
0
221 -
222 if (bi.biSize == BMP_WIN5) {
evaluated: bi.biSize == BMP_WIN5
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:35
35
223 qint32 intent = 0; -
224 qint32 profileData = 0; -
225 qint32 profileSize = 0; -
226 qint32 reserved = 0; -
227 -
228 if (d->read((char *)&intent, sizeof(intent)) != sizeof(intent))
partially evaluated: d->read((char *)&intent, sizeof(intent)) != sizeof(intent)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:35
0-35
229 return false;
never executed: return false;
0
230 if (d->read((char *)&profileData, sizeof(profileData)) != sizeof(profileData))
partially evaluated: d->read((char *)&profileData, sizeof(profileData)) != sizeof(profileData)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:35
0-35
231 return false;
never executed: return false;
0
232 if (d->read((char *)&profileSize, sizeof(profileSize)) != sizeof(profileSize))
partially evaluated: d->read((char *)&profileSize, sizeof(profileSize)) != sizeof(profileSize)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:35
0-35
233 return false;
never executed: return false;
0
234 if (d->read((char *)&reserved, sizeof(reserved)) != sizeof(reserved) || reserved != 0)
partially evaluated: d->read((char *)&reserved, sizeof(reserved)) != sizeof(reserved)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:35
partially evaluated: reserved != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:35
0-35
235 return false;
never executed: return false;
0
236 }
executed: }
Execution Count:35
35
237 }
executed: }
Execution Count:70
70
238 }
executed: }
Execution Count:78
78
239 -
240 if (ncols > 0) {
evaluated: ncols > 0
TRUEFALSE
yes
Evaluation Count:174
yes
Evaluation Count:139
139-174
241 uchar rgb[4]; -
242 int rgb_len = t == BMP_OLD ? 3 : 4;
partially evaluated: t == BMP_OLD
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:174
0-174
243 for (int i=0; i<ncols; i++) {
evaluated: i<ncols
TRUEFALSE
yes
Evaluation Count:14006
yes
Evaluation Count:161
161-14006
244 if (d->read((char *)rgb, rgb_len) != rgb_len)
evaluated: d->read((char *)rgb, rgb_len) != rgb_len
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:13993
13-13993
245 return false;
executed: return false;
Execution Count:13
13
246 image.setColor(i, qRgb(rgb[2],rgb[1],rgb[0])); -
247 if (d->atEnd())
partially evaluated: d->atEnd()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13993
0-13993
248 return false;
never executed: return false;
0
249 }
executed: }
Execution Count:13993
13993
250 } else if (comp == BMP_BITFIELDS && (nbits == 16 || nbits == 32)) {
evaluated: comp == BMP_BITFIELDS
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:96
partially evaluated: nbits == 16
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
partially evaluated: nbits == 32
TRUEFALSE
yes
Evaluation Count:43
no
Evaluation Count:0
executed: }
Execution Count:161
0-161
251 red_shift = calc_shift(red_mask); -
252 red_scale = 256 / ((red_mask >> red_shift) + 1); -
253 green_shift = calc_shift(green_mask); -
254 green_scale = 256 / ((green_mask >> green_shift) + 1); -
255 blue_shift = calc_shift(blue_mask); -
256 blue_scale = 256 / ((blue_mask >> blue_shift) + 1); -
257 } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
partially evaluated: comp == BMP_RGB
TRUEFALSE
yes
Evaluation Count:96
no
Evaluation Count:0
evaluated: nbits == 24
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:20
partially evaluated: nbits == 32
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
executed: }
Execution Count:43
0-96
258 blue_mask = 0x000000ff; -
259 green_mask = 0x0000ff00; -
260 red_mask = 0x00ff0000; -
261 blue_shift = 0; -
262 green_shift = 8; -
263 red_shift = 16; -
264 blue_scale = green_scale = red_scale = 1; -
265 } else if (comp == BMP_RGB && nbits == 16) {
partially evaluated: comp == BMP_RGB
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
partially evaluated: nbits == 16
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
executed: }
Execution Count:76
0-76
266 blue_mask = 0x001f; -
267 green_mask = 0x03e0; -
268 red_mask = 0x7c00; -
269 blue_shift = 0; -
270 green_shift = 2; -
271 red_shift = 7; -
272 red_scale = 1; -
273 green_scale = 1; -
274 blue_scale = 8; -
275 }
executed: }
Execution Count:20
20
276 -
277 -
278 if (offset>=0 && startpos + offset > d->pos()) {
partially evaluated: offset>=0
TRUEFALSE
yes
Evaluation Count:300
no
Evaluation Count:0
partially evaluated: startpos + offset > d->pos()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:300
0-300
279 if (!d->isSequential())
never evaluated: !d->isSequential()
0
280 d->seek(startpos + offset);
never executed: d->seek(startpos + offset);
0
281 }
never executed: }
0
282 -
283 int bpl = image.bytesPerLine(); -
284 uchar *data = image.bits(); -
285 -
286 if (nbits == 1) {
evaluated: nbits == 1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:298
2-298
287 while (--h >= 0) {
evaluated: --h >= 0
TRUEFALSE
yes
Evaluation Count:140
yes
Evaluation Count:2
2-140
288 if (d->read((char*)(data + h*bpl), bpl) != bpl)
partially evaluated: d->read((char*)(data + h*bpl), bpl) != bpl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:140
0-140
289 break;
never executed: break;
0
290 }
executed: }
Execution Count:140
140
291 if (ncols == 2 && qGray(image.color(0)) < qGray(image.color(1)))
partially evaluated: ncols == 2
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: qGray(image.color(0)) < qGray(image.color(1))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
292 swapPixel01(&image);
never executed: swapPixel01(&image);
0
293 }
executed: }
Execution Count:2
2
294 -
295 else if (nbits == 4) {
evaluated: nbits == 4
TRUEFALSE
yes
Evaluation Count:86
yes
Evaluation Count:212
86-212
296 int buflen = ((w+7)/8)*4; -
297 uchar *buf = new uchar[buflen]; -
298 if (comp == BMP_RLE4) {
evaluated: comp == BMP_RLE4
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:53
33-53
299 int x=0, y=0, c, i; -
300 quint8 b; -
301 register uchar *p = data + (h-1)*bpl; -
302 const uchar *endp = p + w; -
303 while (y < h) {
evaluated: y < h
TRUEFALSE
yes
Evaluation Count:185485
yes
Evaluation Count:33
33-185485
304 if (!d->getChar((char *)&b))
partially evaluated: !d->getChar((char *)&b)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:185485
0-185485
305 break;
never executed: break;
0
306 if (b == 0) {
evaluated: b == 0
TRUEFALSE
yes
Evaluation Count:25398
yes
Evaluation Count:160087
25398-160087
307 if (!d->getChar((char *)&b) || b == 1) {
partially evaluated: !d->getChar((char *)&b)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25398
evaluated: b == 1
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:25365
0-25398
308 y = h; -
309 } else switch (b) {
executed: }
Execution Count:33
33
310 case 0: -
311 x = 0; -
312 y++; -
313 p = data + (h-y-1)*bpl; -
314 break;
executed: break;
Execution Count:9801
9801
315 case 2: -
316 { -
317 quint8 tmp; -
318 d->getChar((char *)&tmp); -
319 x += tmp; -
320 d->getChar((char *)&tmp); -
321 y += tmp; -
322 } -
323 -
324 -
325 if ((uint)x >= (uint)w)
never evaluated: (uint)x >= (uint)w
0
326 x = w-1;
never executed: x = w-1;
0
327 if ((uint)y >= (uint)h)
never evaluated: (uint)y >= (uint)h
0
328 y = h-1;
never executed: y = h-1;
0
329 -
330 p = data + (h-y-1)*bpl + x; -
331 break;
never executed: break;
0
332 default: -
333 -
334 if (p + b > endp)
partially evaluated: p + b > endp
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15564
0-15564
335 b = endp-p;
never executed: b = endp-p;
0
336 -
337 i = (c = b)/2; -
338 while (i--) {
evaluated: i--
TRUEFALSE
yes
Evaluation Count:94972
yes
Evaluation Count:15564
15564-94972
339 d->getChar((char *)&b); -
340 *p++ = b >> 4; -
341 *p++ = b & 0x0f; -
342 }
executed: }
Execution Count:94972
94972
343 if (c & 1) {
evaluated: c & 1
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:15551
13-15551
344 unsigned char tmp; -
345 d->getChar((char *)&tmp); -
346 *p++ = tmp >> 4; -
347 }
executed: }
Execution Count:13
13
348 if ((((c & 3) + 1) & 2) == 2)
evaluated: (((c & 3) + 1) & 2) == 2
TRUEFALSE
yes
Evaluation Count:8253
yes
Evaluation Count:7311
7311-8253
349 d->getChar(0);
executed: d->getChar(0);
Execution Count:8253
8253
350 x += c; -
351 }
executed: }
Execution Count:15564
15564
352 } else { -
353 -
354 if (p + b > endp)
partially evaluated: p + b > endp
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:160087
0-160087
355 b = endp-p;
never executed: b = endp-p;
0
356 -
357 i = (c = b)/2; -
358 d->getChar((char *)&b); -
359 while (i--) {
evaluated: i--
TRUEFALSE
yes
Evaluation Count:2980473
yes
Evaluation Count:160087
160087-2980473
360 *p++ = b >> 4; -
361 *p++ = b & 0x0f; -
362 }
executed: }
Execution Count:2980473
2980473
363 if (c & 1)
evaluated: c & 1
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:160035
52-160035
364 *p++ = b >> 4;
executed: *p++ = b >> 4;
Execution Count:52
52
365 x += c; -
366 }
executed: }
Execution Count:160087
160087
367 } -
368 } else if (comp == BMP_RGB) {
partially evaluated: comp == BMP_RGB
TRUEFALSE
yes
Evaluation Count:53
no
Evaluation Count:0
executed: }
Execution Count:33
0-53
369 memset(data, 0, h*bpl); -
370 while (--h >= 0) {
evaluated: --h >= 0
TRUEFALSE
yes
Evaluation Count:666
yes
Evaluation Count:42
42-666
371 if (d->read((char*)buf,buflen) != buflen)
evaluated: d->read((char*)buf,buflen) != buflen
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:655
11-655
372 break;
executed: break;
Execution Count:11
11
373 register uchar *p = data + h*bpl; -
374 uchar *b = buf; -
375 for (int i=0; i<w/2; i++) {
evaluated: i<w/2
TRUEFALSE
yes
Evaluation Count:45105
yes
Evaluation Count:655
655-45105
376 *p++ = *b >> 4; -
377 *p++ = *b++ & 0x0f; -
378 }
executed: }
Execution Count:45105
45105
379 if (w & 1)
evaluated: w & 1
TRUEFALSE
yes
Evaluation Count:319
yes
Evaluation Count:336
319-336
380 *p = *b >> 4;
executed: *p = *b >> 4;
Execution Count:319
319
381 }
executed: }
Execution Count:655
655
382 }
executed: }
Execution Count:53
53
383 delete [] buf; -
384 }
executed: }
Execution Count:86
86
385 -
386 else if (nbits == 8) {
evaluated: nbits == 8
TRUEFALSE
yes
Evaluation Count:73
yes
Evaluation Count:139
73-139
387 if (comp == BMP_RLE8) {
evaluated: comp == BMP_RLE8
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:53
20-53
388 int x=0, y=0; -
389 quint8 b; -
390 register uchar *p = data + (h-1)*bpl; -
391 const uchar *endp = p + w; -
392 while (y < h) {
evaluated: y < h
TRUEFALSE
yes
Evaluation Count:455860
yes
Evaluation Count:20
20-455860
393 if (!d->getChar((char *)&b))
partially evaluated: !d->getChar((char *)&b)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:455860
0-455860
394 break;
never executed: break;
0
395 if (b == 0) {
evaluated: b == 0
TRUEFALSE
yes
Evaluation Count:5600
yes
Evaluation Count:450260
5600-450260
396 if (!d->getChar((char *)&b) || b == 1) {
partially evaluated: !d->getChar((char *)&b)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5600
evaluated: b == 1
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:5580
0-5600
397 y = h; -
398 } else switch (b) {
executed: }
Execution Count:20
20
399 case 0: -
400 x = 0; -
401 y++; -
402 p = data + (h-y-1)*bpl; -
403 break;
executed: break;
Execution Count:5580
5580
404 case 2: -
405 -
406 if ((uint)x >= (uint)w)
never evaluated: (uint)x >= (uint)w
0
407 x = w-1;
never executed: x = w-1;
0
408 if ((uint)y >= (uint)h)
never evaluated: (uint)y >= (uint)h
0
409 y = h-1;
never executed: y = h-1;
0
410 -
411 { -
412 quint8 tmp; -
413 d->getChar((char *)&tmp); -
414 x += tmp; -
415 d->getChar((char *)&tmp); -
416 y += tmp; -
417 } -
418 p = data + (h-y-1)*bpl + x; -
419 break;
never executed: break;
0
420 default: -
421 -
422 if (p + b > endp)
never evaluated: p + b > endp
0
423 b = endp-p;
never executed: b = endp-p;
0
424 -
425 if (d->read((char *)p, b) != b)
never evaluated: d->read((char *)p, b) != b
0
426 return false;
never executed: return false;
0
427 if ((b & 1) == 1)
never evaluated: (b & 1) == 1
0
428 d->getChar(0);
never executed: d->getChar(0);
0
429 x += b; -
430 p += b; -
431 }
never executed: }
0
432 } else { -
433 -
434 if (p + b > endp)
partially evaluated: p + b > endp
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:450260
0-450260
435 b = endp-p;
never executed: b = endp-p;
0
436 -
437 char tmp; -
438 d->getChar(&tmp); -
439 memset(p, tmp, b); -
440 x += b; -
441 p += b; -
442 }
executed: }
Execution Count:450260
450260
443 } -
444 } else if (comp == BMP_RGB) {
partially evaluated: comp == BMP_RGB
TRUEFALSE
yes
Evaluation Count:53
no
Evaluation Count:0
executed: }
Execution Count:20
0-53
445 while (--h >= 0) {
evaluated: --h >= 0
TRUEFALSE
yes
Evaluation Count:10470
yes
Evaluation Count:53
53-10470
446 if (d->read((char *)data + h*bpl, bpl) != bpl)
partially evaluated: d->read((char *)data + h*bpl, bpl) != bpl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10470
0-10470
447 break;
never executed: break;
0
448 }
executed: }
Execution Count:10470
10470
449 }
executed: }
Execution Count:53
53
450 } -
451 -
452 else if (nbits == 16 || nbits == 24 || nbits == 32) {
evaluated: nbits == 16
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:119
evaluated: nbits == 24
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:43
partially evaluated: nbits == 32
TRUEFALSE
yes
Evaluation Count:43
no
Evaluation Count:0
0-119
453 register QRgb *p; -
454 QRgb *end; -
455 uchar *buf24 = new uchar[bpl]; -
456 int bpl24 = ((w*nbits+31)/32)*4; -
457 uchar *b; -
458 int c; -
459 -
460 while (--h >= 0) {
evaluated: --h >= 0
TRUEFALSE
yes
Evaluation Count:19736
yes
Evaluation Count:139
139-19736
461 p = (QRgb *)(data + h*bpl); -
462 end = p + w; -
463 if (d->read((char *)buf24,bpl24) != bpl24)
partially evaluated: d->read((char *)buf24,bpl24) != bpl24
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19736
0-19736
464 break;
never executed: break;
0
465 b = buf24; -
466 while (p < end) {
evaluated: p < end
TRUEFALSE
yes
Evaluation Count:6330688
yes
Evaluation Count:19736
19736-6330688
467 c = *(uchar*)b | (*(uchar*)(b+1)<<8); -
468 if (nbits != 16)
evaluated: nbits != 16
TRUEFALSE
yes
Evaluation Count:4794688
yes
Evaluation Count:1536000
1536000-4794688
469 c |= *(uchar*)(b+2)<<16;
executed: c |= *(uchar*)(b+2)<<16;
Execution Count:4794688
4794688
470 *p++ = qRgb(((c & red_mask) >> red_shift) * red_scale, -
471 ((c & green_mask) >> green_shift) * green_scale, -
472 ((c & blue_mask) >> blue_shift) * blue_scale); -
473 b += nbits/8; -
474 }
executed: }
Execution Count:6330688
6330688
475 }
executed: }
Execution Count:19736
19736
476 delete[] buf24; -
477 }
executed: }
Execution Count:139
139
478 -
479 if (bi.biHeight < 0) {
evaluated: bi.biHeight < 0
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:280
20-280
480 -
481 uchar *buf = new uchar[bpl]; -
482 h = -bi.biHeight; -
483 for (int y = 0; y < h/2; ++y) {
evaluated: y < h/2
TRUEFALSE
yes
Evaluation Count:640
yes
Evaluation Count:20
20-640
484 memcpy(buf, data + y*bpl, bpl); -
485 memcpy(data + y*bpl, data + (h-y-1)*bpl, bpl); -
486 memcpy(data + (h-y-1)*bpl, buf, bpl); -
487 }
executed: }
Execution Count:640
640
488 delete [] buf; -
489 }
executed: }
Execution Count:20
20
490 -
491 return true;
executed: return true;
Execution Count:300
300
492} -
493 -
494 -
495bool qt_write_dib(QDataStream &s, QImage image) -
496{ -
497 int nbits; -
498 int bpl_bmp; -
499 int bpl = image.bytesPerLine(); -
500 -
501 QIODevice* d = s.device(); -
502 if (!d->isWritable())
partially evaluated: !d->isWritable()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
0-32
503 return false;
never executed: return false;
0
504 -
505 if (image.depth() == 8 && image.colorCount() <= 16) {
evaluated: image.depth() == 8
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:23
evaluated: image.colorCount() <= 16
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:5
4-23
506 bpl_bmp = (((bpl+1)/2+3)/4)*4; -
507 nbits = 4; -
508 } else if (image.depth() == 32) {
executed: }
Execution Count:4
evaluated: image.depth() == 32
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:7
4-21
509 bpl_bmp = ((image.width()*24+31)/32)*4; -
510 nbits = 24; -
511 } else {
executed: }
Execution Count:21
21
512 bpl_bmp = bpl; -
513 nbits = image.depth(); -
514 }
executed: }
Execution Count:7
7
515 -
516 BMP_INFOHDR bi; -
517 bi.biSize = BMP_WIN; -
518 bi.biWidth = image.width(); -
519 bi.biHeight = image.height(); -
520 bi.biPlanes = 1; -
521 bi.biBitCount = nbits; -
522 bi.biCompression = BMP_RGB; -
523 bi.biSizeImage = bpl_bmp*image.height(); -
524 bi.biXPelsPerMeter = image.dotsPerMeterX() ? image.dotsPerMeterX()
partially evaluated: image.dotsPerMeterX()
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-32
525 : 2834; -
526 bi.biYPelsPerMeter = image.dotsPerMeterY() ? image.dotsPerMeterY() : 2834;
partially evaluated: image.dotsPerMeterY()
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-32
527 bi.biClrUsed = image.colorCount(); -
528 bi.biClrImportant = image.colorCount(); -
529 s << bi; -
530 if (s.status() != QDataStream::Ok)
partially evaluated: s.status() != QDataStream::Ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
0-32
531 return false;
never executed: return false;
0
532 -
533 if (image.depth() != 32) {
evaluated: image.depth() != 32
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:21
11-21
534 uchar *color_table = new uchar[4*image.colorCount()]; -
535 uchar *rgb = color_table; -
536 QVector<QRgb> c = image.colorTable(); -
537 for (int i=0; i<image.colorCount(); i++) {
evaluated: i<image.colorCount()
TRUEFALSE
yes
Evaluation Count:1220
yes
Evaluation Count:11
11-1220
538 *rgb++ = qBlue (c[i]); -
539 *rgb++ = qGreen(c[i]); -
540 *rgb++ = qRed (c[i]); -
541 *rgb++ = 0; -
542 }
executed: }
Execution Count:1220
1220
543 if (d->write((char *)color_table, 4*image.colorCount()) == -1) {
partially evaluated: d->write((char *)color_table, 4*image.colorCount()) == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11
0-11
544 delete [] color_table; -
545 return false;
never executed: return false;
0
546 } -
547 delete [] color_table; -
548 }
executed: }
Execution Count:11
11
549 -
550 if (image.format() == QImage::Format_MonoLSB)
evaluated: image.format() == QImage::Format_MonoLSB
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:31
1-31
551 image = image.convertToFormat(QImage::Format_Mono);
executed: image = image.convertToFormat(QImage::Format_Mono);
Execution Count:1
1
552 -
553 int y; -
554 -
555 if (nbits == 1 || nbits == 8) {
evaluated: nbits == 1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:30
evaluated: nbits == 8
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:25
2-30
556 for (y=image.height()-1; y>=0; y--) {
evaluated: y>=0
TRUEFALSE
yes
Evaluation Count:1010
yes
Evaluation Count:7
7-1010
557 if (d->write((char*)image.constScanLine(y), bpl) == -1)
partially evaluated: d->write((char*)image.constScanLine(y), bpl) == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1010
0-1010
558 return false;
never executed: return false;
0
559 }
executed: }
Execution Count:1010
1010
560 return true;
executed: return true;
Execution Count:7
7
561 } -
562 -
563 uchar *buf = new uchar[bpl_bmp]; -
564 uchar *b, *end; -
565 register const uchar *p; -
566 -
567 memset(buf, 0, bpl_bmp); -
568 for (y=image.height()-1; y>=0; y--) {
evaluated: y>=0
TRUEFALSE
yes
Evaluation Count:2256
yes
Evaluation Count:25
25-2256
569 if (nbits == 4) {
evaluated: nbits == 4
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:2224
32-2224
570 p = image.constScanLine(y); -
571 b = buf; -
572 end = b + image.width()/2; -
573 while (b < end) {
evaluated: b < end
TRUEFALSE
yes
Evaluation Count:3840
yes
Evaluation Count:32
32-3840
574 *b++ = (*p << 4) | (*(p+1) & 0x0f); -
575 p += 2; -
576 }
executed: }
Execution Count:3840
3840
577 if (image.width() & 1)
partially evaluated: image.width() & 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
0-32
578 *b = *p << 4;
never executed: *b = *p << 4;
0
579 } else {
executed: }
Execution Count:32
32
580 const QRgb *p = (const QRgb *)image.constScanLine(y); -
581 const QRgb *end = p + image.width(); -
582 b = buf; -
583 while (p < end) {
evaluated: p < end
TRUEFALSE
yes
Evaluation Count:493944
yes
Evaluation Count:2224
2224-493944
584 *b++ = qBlue(*p); -
585 *b++ = qGreen(*p); -
586 *b++ = qRed(*p); -
587 p++; -
588 }
executed: }
Execution Count:493944
493944
589 }
executed: }
Execution Count:2224
2224
590 if (bpl_bmp != d->write((char*)buf, bpl_bmp)) {
partially evaluated: bpl_bmp != d->write((char*)buf, bpl_bmp)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2256
0-2256
591 delete[] buf; -
592 return false;
never executed: return false;
0
593 } -
594 }
executed: }
Execution Count:2256
2256
595 delete[] buf; -
596 return true;
executed: return true;
Execution Count:25
25
597} -
598 -
599 -
600bool qt_read_dib(QDataStream &s, QImage &image) -
601{ -
602 BMP_INFOHDR bi; -
603 if (!read_dib_infoheader(s, bi))
never evaluated: !read_dib_infoheader(s, bi)
0
604 return false;
never executed: return false;
0
605 return read_dib_body(s, bi, -1, -BMP_FILEHDR_SIZE, image);
never executed: return read_dib_body(s, bi, -1, -BMP_FILEHDR_SIZE, image);
0
606} -
607 -
608QBmpHandler::QBmpHandler(InternalFormat fmt) : -
609 m_format(fmt), state(Ready) -
610{ -
611}
executed: }
Execution Count:372
372
612 -
613QByteArray QBmpHandler::formatName() const -
614{ -
615 return m_format == BmpFormat ? "bmp" : "dib";
executed: return m_format == BmpFormat ? "bmp" : "dib";
Execution Count:85
85
616} -
617 -
618bool QBmpHandler::readHeader() -
619{ -
620 state = Error; -
621 -
622 QIODevice *d = device(); -
623 QDataStream s(d); -
624 startpos = d->pos(); -
625 -
626 -
627 s.setByteOrder(QDataStream::LittleEndian); -
628 -
629 -
630 if (m_format == BmpFormat && !read_dib_fileheader(s, fileHeader))
partially evaluated: m_format == BmpFormat
TRUEFALSE
yes
Evaluation Count:341
no
Evaluation Count:0
evaluated: !read_dib_fileheader(s, fileHeader)
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:321
0-341
631 return false;
executed: return false;
Execution Count:20
20
632 -
633 -
634 if (!read_dib_infoheader(s, infoHeader))
partially evaluated: !read_dib_infoheader(s, infoHeader)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:321
0-321
635 return false;
never executed: return false;
0
636 -
637 state = ReadHeader; -
638 return true;
executed: return true;
Execution Count:321
321
639} -
640 -
641bool QBmpHandler::canRead() const -
642{ -
643 if (m_format == BmpFormat && state == Ready && !canRead(device()))
partially evaluated: m_format == BmpFormat
TRUEFALSE
yes
Evaluation Count:119
no
Evaluation Count:0
evaluated: state == Ready
TRUEFALSE
yes
Evaluation Count:111
yes
Evaluation Count:8
evaluated: !canRead(device())
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:77
0-119
644 return false;
executed: return false;
Execution Count:34
34
645 -
646 if (state != Error) {
partially evaluated: state != Error
TRUEFALSE
yes
Evaluation Count:85
no
Evaluation Count:0
0-85
647 setFormat(formatName()); -
648 return true;
executed: return true;
Execution Count:85
85
649 } -
650 -
651 return false;
never executed: return false;
0
652} -
653 -
654bool QBmpHandler::canRead(QIODevice *device) -
655{ -
656 if (!device) {
partially evaluated: !device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:222
0-222
657 QMessageLogger("image/qbmphandler.cpp", 727, __PRETTY_FUNCTION__).warning("QBmpHandler::canRead() called with 0 pointer"); -
658 return false;
never executed: return false;
0
659 } -
660 -
661 char head[2]; -
662 if (device->peek(head, sizeof(head)) != sizeof(head))
evaluated: device->peek(head, sizeof(head)) != sizeof(head)
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:187
35-187
663 return false;
executed: return false;
Execution Count:35
35
664 -
665 return (qstrncmp(head, "BM", 2) == 0);
executed: return (qstrncmp(head, "BM", 2) == 0);
Execution Count:187
187
666} -
667 -
668bool QBmpHandler::read(QImage *image) -
669{ -
670 if (state == Error)
partially evaluated: state == Error
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:333
0-333
671 return false;
never executed: return false;
0
672 -
673 if (!image) {
partially evaluated: !image
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:333
0-333
674 QMessageLogger("image/qbmphandler.cpp", 744, __PRETTY_FUNCTION__).warning("QBmpHandler::read: cannot read into null pointer"); -
675 return false;
never executed: return false;
0
676 } -
677 -
678 if (state == Ready && !readHeader()) {
evaluated: state == Ready
TRUEFALSE
yes
Evaluation Count:329
yes
Evaluation Count:4
evaluated: !readHeader()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:309
4-329
679 state = Error; -
680 return false;
executed: return false;
Execution Count:20
20
681 } -
682 -
683 QIODevice *d = device(); -
684 QDataStream s(d); -
685 -
686 -
687 s.setByteOrder(QDataStream::LittleEndian); -
688 -
689 -
690 const bool readSuccess = m_format == BmpFormat ?
partially evaluated: m_format == BmpFormat
TRUEFALSE
yes
Evaluation Count:313
no
Evaluation Count:0
0-313
691 read_dib_body(s, infoHeader, fileHeader.bfOffBits, startpos, *image) : -
692 read_dib_body(s, infoHeader, -1, startpos - BMP_FILEHDR_SIZE, *image); -
693 if (!readSuccess)
evaluated: !readSuccess
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:300
13-300
694 return false;
executed: return false;
Execution Count:13
13
695 -
696 state = Ready; -
697 return true;
executed: return true;
Execution Count:300
300
698} -
699 -
700bool QBmpHandler::write(const QImage &img) -
701{ -
702 if (m_format == DibFormat) {
partially evaluated: m_format == DibFormat
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
0-32
703 QDataStream dibStream(device()); -
704 dibStream.setByteOrder(QDataStream::LittleEndian); -
705 return qt_write_dib(dibStream, img);
never executed: return qt_write_dib(dibStream, img);
0
706 } -
707 -
708 QImage image; -
709 switch (img.format()) { -
710 case QImage::Format_ARGB8565_Premultiplied: -
711 case QImage::Format_ARGB8555_Premultiplied: -
712 case QImage::Format_ARGB6666_Premultiplied: -
713 case QImage::Format_ARGB4444_Premultiplied: -
714 image = img.convertToFormat(QImage::Format_ARGB32); -
715 break;
executed: break;
Execution Count:4
4
716 case QImage::Format_RGB16: -
717 case QImage::Format_RGB888: -
718 case QImage::Format_RGB666: -
719 case QImage::Format_RGB555: -
720 case QImage::Format_RGB444: -
721 image = img.convertToFormat(QImage::Format_RGB32); -
722 break;
executed: break;
Execution Count:5
5
723 default: -
724 image = img; -
725 }
executed: }
Execution Count:23
23
726 -
727 QIODevice *d = device(); -
728 QDataStream s(d); -
729 BMP_FILEHDR bf; -
730 int bpl_bmp; -
731 int bpl = image.bytesPerLine(); -
732 -
733 -
734 if (image.depth() == 8 && image.colorCount() <= 16) {
evaluated: image.depth() == 8
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:23
evaluated: image.colorCount() <= 16
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:5
4-23
735 bpl_bmp = (((bpl+1)/2+3)/4)*4; -
736 } else if (image.depth() == 32) {
executed: }
Execution Count:4
evaluated: image.depth() == 32
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:7
4-21
737 bpl_bmp = ((image.width()*24+31)/32)*4; -
738 } else {
executed: }
Execution Count:21
21
739 bpl_bmp = bpl; -
740 }
executed: }
Execution Count:7
7
741 -
742 -
743 s.setByteOrder(QDataStream::LittleEndian); -
744 -
745 -
746 memcpy(bf.bfType, "BM", 2); -
747 -
748 -
749 bf.bfReserved1 = 0; -
750 bf.bfReserved2 = 0; -
751 bf.bfOffBits = BMP_FILEHDR_SIZE + BMP_WIN + image.colorCount() * 4; -
752 bf.bfSize = bf.bfOffBits + bpl_bmp*image.height(); -
753 s << bf; -
754 -
755 -
756 return qt_write_dib(s, image);
executed: return qt_write_dib(s, image);
Execution Count:32
32
757} -
758 -
759bool QBmpHandler::supportsOption(ImageOption option) const -
760{ -
761 return option == Size 2371
762 || option == ImageFormat;
executed: return option == Size || option == ImageFormat;
Execution Count:2371
2371
763} -
764 -
765QVariant QBmpHandler::option(ImageOption option) const -
766{ -
767 if (option == Size) {
evaluated: option == Size
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:4
4-8
768 if (state == Error)
partially evaluated: state == Error
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
769 return QVariant();
never executed: return QVariant();
0
770 if (state == Ready && !const_cast<QBmpHandler*>(this)->readHeader())
partially evaluated: state == Ready
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
partially evaluated: !const_cast<QBmpHandler*>(this)->readHeader()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
771 return QVariant();
never executed: return QVariant();
0
772 return QSize(infoHeader.biWidth, infoHeader.biHeight);
executed: return QSize(infoHeader.biWidth, infoHeader.biHeight);
Execution Count:8
8
773 } else if (option == ImageFormat) {
partially evaluated: option == ImageFormat
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
774 if (state == Error)
partially evaluated: state == Error
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
775 return QVariant();
never executed: return QVariant();
0
776 if (state == Ready && !const_cast<QBmpHandler*>(this)->readHeader())
partially evaluated: state == Ready
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
partially evaluated: !const_cast<QBmpHandler*>(this)->readHeader()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
777 return QVariant();
never executed: return QVariant();
0
778 QImage::Format format; -
779 switch (infoHeader.biBitCount) { -
780 case 32: -
781 case 24: -
782 case 16: -
783 format = QImage::Format_RGB32; -
784 break;
executed: break;
Execution Count:2
2
785 case 8: -
786 case 4: -
787 format = QImage::Format_Indexed8; -
788 break;
executed: break;
Execution Count:2
2
789 default: -
790 format = QImage::Format_Mono; -
791 }
never executed: }
0
792 return format;
executed: return format;
Execution Count:4
4
793 } -
794 return QVariant();
never executed: return QVariant();
0
795} -
796 -
797void QBmpHandler::setOption(ImageOption option, const QVariant &value) -
798{ -
799 (void)option;; -
800 (void)value;; -
801}
never executed: }
0
802 -
803QByteArray QBmpHandler::name() const -
804{ -
805 return formatName();
never executed: return formatName();
0
806} -
807 -
808 -
809 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial