Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "private/qbmphandler_p.h" | - |
43 | | - |
44 | #ifndef QT_NO_IMAGEFORMAT_BMP | - |
45 | | - |
46 | #include <qimage.h> | - |
47 | #include <qvariant.h> | - |
48 | #include <qvector.h> | - |
49 | | - |
50 | QT_BEGIN_NAMESPACE | - |
51 | | - |
52 | static void swapPixel01(QImage *image) // 1-bpp: swap 0 and 1 pixels | - |
53 | { | - |
54 | int i; never executed (the execution status of this line is deduced): int i; | - |
55 | if (image->depth() == 1 && image->colorCount() == 2) { never evaluated: image->depth() == 1 never evaluated: image->colorCount() == 2 | 0 |
56 | register uint *p = (uint *)image->bits(); never executed (the execution status of this line is deduced): register uint *p = (uint *)image->bits(); | - |
57 | int nbytes = image->byteCount(); never executed (the execution status of this line is deduced): int nbytes = image->byteCount(); | - |
58 | for (i=0; i<nbytes/4; i++) { never evaluated: i<nbytes/4 | 0 |
59 | *p = ~*p; never executed (the execution status of this line is deduced): *p = ~*p; | - |
60 | p++; never executed (the execution status of this line is deduced): p++; | - |
61 | } | 0 |
62 | uchar *p2 = (uchar *)p; never executed (the execution status of this line is deduced): uchar *p2 = (uchar *)p; | - |
63 | for (i=0; i<(nbytes&3); i++) { never evaluated: i<(nbytes&3) | 0 |
64 | *p2 = ~*p2; never executed (the execution status of this line is deduced): *p2 = ~*p2; | - |
65 | p2++; never executed (the execution status of this line is deduced): p2++; | - |
66 | } | 0 |
67 | QRgb t = image->color(0); // swap color 0 and 1 never executed (the execution status of this line is deduced): QRgb t = image->color(0); | - |
68 | image->setColor(0, image->color(1)); never executed (the execution status of this line is deduced): image->setColor(0, image->color(1)); | - |
69 | image->setColor(1, t); never executed (the execution status of this line is deduced): image->setColor(1, t); | - |
70 | } | 0 |
71 | } | 0 |
72 | | - |
73 | /* | - |
74 | QImageIO::defineIOHandler("BMP", "^BM", 0, | - |
75 | read_bmp_image, write_bmp_image); | - |
76 | */ | - |
77 | | - |
78 | /***************************************************************************** | - |
79 | BMP (DIB) image read/write functions | - |
80 | *****************************************************************************/ | - |
81 | | - |
82 | const int BMP_FILEHDR_SIZE = 14; // size of BMP_FILEHDR data | - |
83 | | - |
84 | static QDataStream &operator>>(QDataStream &s, BMP_FILEHDR &bf) | - |
85 | { // read file header | - |
86 | s.readRawData(bf.bfType, 2); executed (the execution status of this line is deduced): s.readRawData(bf.bfType, 2); | - |
87 | s >> bf.bfSize >> bf.bfReserved1 >> bf.bfReserved2 >> bf.bfOffBits; executed (the execution status of this line is deduced): s >> bf.bfSize >> bf.bfReserved1 >> bf.bfReserved2 >> bf.bfOffBits; | - |
88 | return s; executed: return s; Execution Count:341 | 341 |
89 | } | - |
90 | | - |
91 | static QDataStream &operator<<(QDataStream &s, const BMP_FILEHDR &bf) | - |
92 | { // write file header | - |
93 | s.writeRawData(bf.bfType, 2); executed (the execution status of this line is deduced): s.writeRawData(bf.bfType, 2); | - |
94 | s << bf.bfSize << bf.bfReserved1 << bf.bfReserved2 << bf.bfOffBits; executed (the execution status of this line is deduced): s << bf.bfSize << bf.bfReserved1 << bf.bfReserved2 << bf.bfOffBits; | - |
95 | return s; executed: return s; Execution Count:32 | 32 |
96 | } | - |
97 | | - |
98 | | - |
99 | const int BMP_OLD = 12; // old Windows/OS2 BMP size | - |
100 | const int BMP_WIN = 40; // Windows BMP v3 size | - |
101 | const int BMP_OS2 = 64; // new OS/2 BMP size | - |
102 | const int BMP_WIN4 = 108; // Windows BMP v4 size | - |
103 | const int BMP_WIN5 = 124; // Windows BMP v5 size | - |
104 | | - |
105 | const int BMP_RGB = 0; // no compression | - |
106 | const int BMP_RLE8 = 1; // run-length encoded, 8 bits | - |
107 | const int BMP_RLE4 = 2; // run-length encoded, 4 bits | - |
108 | const int BMP_BITFIELDS = 3; // RGB values encoded in data as bit-fields | - |
109 | | - |
110 | | - |
111 | static QDataStream &operator>>(QDataStream &s, BMP_INFOHDR &bi) | - |
112 | { | - |
113 | s >> bi.biSize; executed (the execution status of this line is deduced): s >> bi.biSize; | - |
114 | if (bi.biSize == BMP_WIN || bi.biSize == BMP_OS2 || bi.biSize == BMP_WIN4 || bi.biSize == BMP_WIN5) { evaluated: bi.biSize == BMP_WIN yes Evaluation Count:247 | yes Evaluation Count:74 |
partially evaluated: bi.biSize == BMP_OS2 no Evaluation Count:0 | yes Evaluation Count:74 |
evaluated: bi.biSize == BMP_WIN4 yes Evaluation Count:37 | yes Evaluation Count:37 |
partially evaluated: bi.biSize == BMP_WIN5 yes Evaluation Count:37 | no Evaluation Count:0 |
| 0-247 |
115 | s >> bi.biWidth >> bi.biHeight >> bi.biPlanes >> bi.biBitCount; executed (the execution status of this line is deduced): s >> bi.biWidth >> bi.biHeight >> bi.biPlanes >> bi.biBitCount; | - |
116 | s >> bi.biCompression >> bi.biSizeImage; executed (the execution status of this line is deduced): s >> bi.biCompression >> bi.biSizeImage; | - |
117 | s >> bi.biXPelsPerMeter >> bi.biYPelsPerMeter; executed (the execution status of this line is deduced): s >> bi.biXPelsPerMeter >> bi.biYPelsPerMeter; | - |
118 | s >> bi.biClrUsed >> bi.biClrImportant; executed (the execution status of this line is deduced): s >> bi.biClrUsed >> bi.biClrImportant; | - |
119 | } executed: } Execution Count:321 | 321 |
120 | else { // probably old Windows format | - |
121 | qint16 w, h; never executed (the execution status of this line is deduced): qint16 w, h; | - |
122 | s >> w >> h >> bi.biPlanes >> bi.biBitCount; never executed (the execution status of this line is deduced): s >> w >> h >> bi.biPlanes >> bi.biBitCount; | - |
123 | bi.biWidth = w; never executed (the execution status of this line is deduced): bi.biWidth = w; | - |
124 | bi.biHeight = h; never executed (the execution status of this line is deduced): bi.biHeight = h; | - |
125 | bi.biCompression = BMP_RGB; // no compression never executed (the execution status of this line is deduced): bi.biCompression = BMP_RGB; | - |
126 | bi.biSizeImage = 0; never executed (the execution status of this line is deduced): bi.biSizeImage = 0; | - |
127 | bi.biXPelsPerMeter = bi.biYPelsPerMeter = 0; never executed (the execution status of this line is deduced): bi.biXPelsPerMeter = bi.biYPelsPerMeter = 0; | - |
128 | bi.biClrUsed = bi.biClrImportant = 0; never executed (the execution status of this line is deduced): bi.biClrUsed = bi.biClrImportant = 0; | - |
129 | } | 0 |
130 | return s; executed: return s; Execution Count:321 | 321 |
131 | } | - |
132 | | - |
133 | static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi) | - |
134 | { | - |
135 | s << bi.biSize; executed (the execution status of this line is deduced): s << bi.biSize; | - |
136 | s << bi.biWidth << bi.biHeight; executed (the execution status of this line is deduced): s << bi.biWidth << bi.biHeight; | - |
137 | s << bi.biPlanes; executed (the execution status of this line is deduced): s << bi.biPlanes; | - |
138 | s << bi.biBitCount; executed (the execution status of this line is deduced): s << bi.biBitCount; | - |
139 | s << bi.biCompression; executed (the execution status of this line is deduced): s << bi.biCompression; | - |
140 | s << bi.biSizeImage; executed (the execution status of this line is deduced): s << bi.biSizeImage; | - |
141 | s << bi.biXPelsPerMeter << bi.biYPelsPerMeter; executed (the execution status of this line is deduced): s << bi.biXPelsPerMeter << bi.biYPelsPerMeter; | - |
142 | s << bi.biClrUsed << bi.biClrImportant; executed (the execution status of this line is deduced): s << bi.biClrUsed << bi.biClrImportant; | - |
143 | return s; executed: return s; Execution Count:32 | 32 |
144 | } | - |
145 | | - |
146 | static int calc_shift(uint mask) | - |
147 | { | - |
148 | int result = 0; executed (the execution status of this line is deduced): int result = 0; | - |
149 | while (mask && !(mask & 1)) { partially evaluated: mask yes Evaluation Count:1321 | no Evaluation Count:0 |
evaluated: !(mask & 1) yes Evaluation Count:1192 | yes Evaluation Count:129 |
| 0-1321 |
150 | result++; executed (the execution status of this line is deduced): result++; | - |
151 | mask >>= 1; executed (the execution status of this line is deduced): mask >>= 1; | - |
152 | } executed: } Execution Count:1192 | 1192 |
153 | return result; executed: return result; Execution Count:129 | 129 |
154 | } | - |
155 | | - |
156 | static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf) | - |
157 | { | - |
158 | // read BMP file header | - |
159 | s >> bf; executed (the execution status of this line is deduced): s >> bf; | - |
160 | if (s.status() != QDataStream::Ok) evaluated: s.status() != QDataStream::Ok yes Evaluation Count:20 | yes Evaluation Count:321 |
| 20-321 |
161 | return false; executed: return false; Execution Count:20 | 20 |
162 | | - |
163 | // check header | - |
164 | if (qstrncmp(bf.bfType,"BM",2) != 0) partially evaluated: qstrncmp(bf.bfType,"BM",2) != 0 no Evaluation Count:0 | yes Evaluation Count:321 |
| 0-321 |
165 | return false; never executed: return false; | 0 |
166 | | - |
167 | return true; executed: return true; Execution Count:321 | 321 |
168 | } | - |
169 | | - |
170 | static bool read_dib_infoheader(QDataStream &s, BMP_INFOHDR &bi) | - |
171 | { | - |
172 | s >> bi; // read BMP info header executed (the execution status of this line is deduced): s >> bi; | - |
173 | if (s.status() != QDataStream::Ok) partially evaluated: s.status() != QDataStream::Ok no Evaluation Count:0 | yes Evaluation Count:321 |
| 0-321 |
174 | return false; never executed: return false; | 0 |
175 | | - |
176 | int nbits = bi.biBitCount; executed (the execution status of this line is deduced): int nbits = bi.biBitCount; | - |
177 | int comp = bi.biCompression; executed (the execution status of this line is deduced): int comp = bi.biCompression; | - |
178 | if (!(nbits == 1 || nbits == 4 || nbits == 8 || nbits == 16 || nbits == 24 || nbits == 32) || evaluated: nbits == 1 yes Evaluation Count:2 | yes Evaluation Count:319 |
evaluated: nbits == 4 yes Evaluation Count:88 | yes Evaluation Count:231 |
evaluated: nbits == 8 yes Evaluation Count:88 | yes Evaluation Count:143 |
evaluated: nbits == 16 yes Evaluation Count:20 | yes Evaluation Count:123 |
evaluated: nbits == 24 yes Evaluation Count:78 | yes Evaluation Count:45 |
partially evaluated: nbits == 32 yes Evaluation Count:45 | no Evaluation Count:0 |
| 0-319 |
179 | bi.biPlanes != 1 || comp > BMP_BITFIELDS) partially evaluated: bi.biPlanes != 1 no Evaluation Count:0 | yes Evaluation Count:321 |
partially evaluated: comp > BMP_BITFIELDS no Evaluation Count:0 | yes Evaluation Count:321 |
| 0-321 |
180 | return false; // weird BMP image never executed: return false; | 0 |
181 | if (!(comp == BMP_RGB || (nbits == 4 && comp == BMP_RLE4) || evaluated: comp == BMP_RGB yes Evaluation Count:223 | yes Evaluation Count:98 |
evaluated: nbits == 4 yes Evaluation Count:33 | yes Evaluation Count:65 |
partially evaluated: comp == BMP_RLE4 yes Evaluation Count:33 | no Evaluation Count:0 |
| 0-223 |
182 | (nbits == 8 && comp == BMP_RLE8) || ((nbits == 16 || nbits == 32) && comp == BMP_BITFIELDS))) evaluated: nbits == 8 yes Evaluation Count:20 | yes Evaluation Count:45 |
partially evaluated: comp == BMP_RLE8 yes Evaluation Count:20 | no Evaluation Count:0 |
partially evaluated: nbits == 16 no Evaluation Count:0 | yes Evaluation Count:45 |
partially evaluated: nbits == 32 yes Evaluation Count:45 | no Evaluation Count:0 |
partially evaluated: comp == BMP_BITFIELDS yes Evaluation Count:45 | no Evaluation Count:0 |
| 0-45 |
183 | return false; // weird compression type never executed: return false; | 0 |
184 | | - |
185 | return true; executed: return true; Execution Count:321 | 321 |
186 | } | - |
187 | | - |
188 | static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int startpos, QImage &image) | - |
189 | { | - |
190 | QIODevice* d = s.device(); executed (the execution status of this line is deduced): QIODevice* d = s.device(); | - |
191 | if (d->atEnd()) // end of stream/file partially evaluated: d->atEnd() no Evaluation Count:0 | yes Evaluation Count:313 |
| 0-313 |
192 | return false; never executed: return false; | 0 |
193 | #if 0 | - |
194 | qDebug("offset...........%d", offset); | - |
195 | qDebug("startpos.........%d", startpos); | - |
196 | qDebug("biSize...........%d", bi.biSize); | - |
197 | qDebug("biWidth..........%d", bi.biWidth); | - |
198 | qDebug("biHeight.........%d", bi.biHeight); | - |
199 | qDebug("biPlanes.........%d", bi.biPlanes); | - |
200 | qDebug("biBitCount.......%d", bi.biBitCount); | - |
201 | qDebug("biCompression....%d", bi.biCompression); | - |
202 | qDebug("biSizeImage......%d", bi.biSizeImage); | - |
203 | qDebug("biXPelsPerMeter..%d", bi.biXPelsPerMeter); | - |
204 | qDebug("biYPelsPerMeter..%d", bi.biYPelsPerMeter); | - |
205 | qDebug("biClrUsed........%d", bi.biClrUsed); | - |
206 | qDebug("biClrImportant...%d", bi.biClrImportant); | - |
207 | #endif | - |
208 | int w = bi.biWidth, h = bi.biHeight, nbits = bi.biBitCount; executed (the execution status of this line is deduced): int w = bi.biWidth, h = bi.biHeight, nbits = bi.biBitCount; | - |
209 | int t = bi.biSize, comp = bi.biCompression; executed (the execution status of this line is deduced): int t = bi.biSize, comp = bi.biCompression; | - |
210 | uint red_mask = 0; executed (the execution status of this line is deduced): uint red_mask = 0; | - |
211 | uint green_mask = 0; executed (the execution status of this line is deduced): uint green_mask = 0; | - |
212 | uint blue_mask = 0; executed (the execution status of this line is deduced): uint blue_mask = 0; | - |
213 | int red_shift = 0; executed (the execution status of this line is deduced): int red_shift = 0; | - |
214 | int green_shift = 0; executed (the execution status of this line is deduced): int green_shift = 0; | - |
215 | int blue_shift = 0; executed (the execution status of this line is deduced): int blue_shift = 0; | - |
216 | int red_scale = 0; executed (the execution status of this line is deduced): int red_scale = 0; | - |
217 | int green_scale = 0; executed (the execution status of this line is deduced): int green_scale = 0; | - |
218 | int blue_scale = 0; executed (the execution status of this line is deduced): int blue_scale = 0; | - |
219 | | - |
220 | int ncols = 0; executed (the execution status of this line is deduced): int ncols = 0; | - |
221 | int depth = 0; executed (the execution status of this line is deduced): int depth = 0; | - |
222 | QImage::Format format; executed (the execution status of this line is deduced): QImage::Format format; | - |
223 | switch (nbits) { | - |
224 | case 32: | - |
225 | case 24: | - |
226 | case 16: | - |
227 | depth = 32; executed (the execution status of this line is deduced): depth = 32; | - |
228 | format = QImage::Format_RGB32; executed (the execution status of this line is deduced): format = QImage::Format_RGB32; | - |
229 | break; executed: break; Execution Count:139 | 139 |
230 | case 8: | - |
231 | case 4: | - |
232 | depth = 8; executed (the execution status of this line is deduced): depth = 8; | - |
233 | format = QImage::Format_Indexed8; executed (the execution status of this line is deduced): format = QImage::Format_Indexed8; | - |
234 | break; executed: break; Execution Count:172 | 172 |
235 | default: | - |
236 | depth = 1; executed (the execution status of this line is deduced): depth = 1; | - |
237 | format = QImage::Format_Mono; executed (the execution status of this line is deduced): format = QImage::Format_Mono; | - |
238 | } executed: } Execution Count:2 | 2 |
239 | | - |
240 | if (bi.biHeight < 0) evaluated: bi.biHeight < 0 yes Evaluation Count:20 | yes Evaluation Count:293 |
| 20-293 |
241 | h = -h; // support images with negative height executed: h = -h; Execution Count:20 | 20 |
242 | | - |
243 | if (image.size() != QSize(w, h) || image.format() != format) { partially evaluated: image.size() != QSize(w, h) yes Evaluation Count:313 | no Evaluation Count:0 |
never evaluated: image.format() != format | 0-313 |
244 | image = QImage(w, h, format); executed (the execution status of this line is deduced): image = QImage(w, h, format); | - |
245 | if (image.isNull()) // could not create image partially evaluated: image.isNull() no Evaluation Count:0 | yes Evaluation Count:313 |
| 0-313 |
246 | return false; never executed: return false; | 0 |
247 | } executed: } Execution Count:313 | 313 |
248 | | - |
249 | if (depth != 32) { evaluated: depth != 32 yes Evaluation Count:174 | yes Evaluation Count:139 |
| 139-174 |
250 | ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits; evaluated: bi.biClrUsed yes Evaluation Count:163 | yes Evaluation Count:11 |
| 11-163 |
251 | if (ncols > 256) // sanity check - don't run out of mem if color table is broken partially evaluated: ncols > 256 no Evaluation Count:0 | yes Evaluation Count:174 |
| 0-174 |
252 | return false; never executed: return false; | 0 |
253 | image.setColorCount(ncols); executed (the execution status of this line is deduced): image.setColorCount(ncols); | - |
254 | } executed: } Execution Count:174 | 174 |
255 | | - |
256 | image.setDotsPerMeterX(bi.biXPelsPerMeter); executed (the execution status of this line is deduced): image.setDotsPerMeterX(bi.biXPelsPerMeter); | - |
257 | image.setDotsPerMeterY(bi.biYPelsPerMeter); executed (the execution status of this line is deduced): image.setDotsPerMeterY(bi.biYPelsPerMeter); | - |
258 | | - |
259 | if (!d->isSequential()) evaluated: !d->isSequential() yes Evaluation Count:309 | yes Evaluation Count:4 |
| 4-309 |
260 | d->seek(startpos + BMP_FILEHDR_SIZE + (bi.biSize >= BMP_WIN4? BMP_WIN : bi.biSize)); // goto start of colormap executed: d->seek(startpos + BMP_FILEHDR_SIZE + (bi.biSize >= BMP_WIN4? BMP_WIN : bi.biSize)); Execution Count:309 | 309 |
261 | | - |
262 | if (bi.biSize >= BMP_WIN4 || (comp == BMP_BITFIELDS && (nbits == 16 || nbits == 32))) { evaluated: bi.biSize >= BMP_WIN4 yes Evaluation Count:70 | yes Evaluation Count:243 |
evaluated: comp == BMP_BITFIELDS yes Evaluation Count:8 | yes Evaluation Count:235 |
partially evaluated: nbits == 16 no Evaluation Count:0 | yes Evaluation Count:8 |
partially evaluated: nbits == 32 yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-243 |
263 | 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) no Evaluation Count:0 | yes Evaluation Count:78 |
| 0-78 |
264 | return false; never executed: return false; | 0 |
265 | 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) no Evaluation Count:0 | yes Evaluation Count:78 |
| 0-78 |
266 | return false; never executed: return false; | 0 |
267 | 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) no Evaluation Count:0 | yes Evaluation Count:78 |
| 0-78 |
268 | return false; never executed: return false; | 0 |
269 | | - |
270 | // Read BMP v4+ header | - |
271 | if (bi.biSize >= BMP_WIN4) { evaluated: bi.biSize >= BMP_WIN4 yes Evaluation Count:70 | yes Evaluation Count:8 |
| 8-70 |
272 | int alpha_mask = 0; executed (the execution status of this line is deduced): int alpha_mask = 0; | - |
273 | int CSType = 0; executed (the execution status of this line is deduced): int CSType = 0; | - |
274 | int gamma_red = 0; executed (the execution status of this line is deduced): int gamma_red = 0; | - |
275 | int gamma_green = 0; executed (the execution status of this line is deduced): int gamma_green = 0; | - |
276 | int gamma_blue = 0; executed (the execution status of this line is deduced): int gamma_blue = 0; | - |
277 | int endpoints[9]; executed (the execution status of this line is deduced): int endpoints[9]; | - |
278 | | - |
279 | 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) no Evaluation Count:0 | yes Evaluation Count:70 |
| 0-70 |
280 | return false; never executed: return false; | 0 |
281 | if (d->read((char *)&CSType, sizeof(CSType)) != sizeof(CSType)) partially evaluated: d->read((char *)&CSType, sizeof(CSType)) != sizeof(CSType) no Evaluation Count:0 | yes Evaluation Count:70 |
| 0-70 |
282 | return false; never executed: return false; | 0 |
283 | if (d->read((char *)&endpoints, sizeof(endpoints)) != sizeof(endpoints)) partially evaluated: d->read((char *)&endpoints, sizeof(endpoints)) != sizeof(endpoints) no Evaluation Count:0 | yes Evaluation Count:70 |
| 0-70 |
284 | return false; never executed: return false; | 0 |
285 | 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) no Evaluation Count:0 | yes Evaluation Count:70 |
| 0-70 |
286 | return false; never executed: return false; | 0 |
287 | 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) no Evaluation Count:0 | yes Evaluation Count:70 |
| 0-70 |
288 | return false; never executed: return false; | 0 |
289 | 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) no Evaluation Count:0 | yes Evaluation Count:70 |
| 0-70 |
290 | return false; never executed: return false; | 0 |
291 | | - |
292 | if (bi.biSize == BMP_WIN5) { evaluated: bi.biSize == BMP_WIN5 yes Evaluation Count:35 | yes Evaluation Count:35 |
| 35 |
293 | qint32 intent = 0; executed (the execution status of this line is deduced): qint32 intent = 0; | - |
294 | qint32 profileData = 0; executed (the execution status of this line is deduced): qint32 profileData = 0; | - |
295 | qint32 profileSize = 0; executed (the execution status of this line is deduced): qint32 profileSize = 0; | - |
296 | qint32 reserved = 0; executed (the execution status of this line is deduced): qint32 reserved = 0; | - |
297 | | - |
298 | if (d->read((char *)&intent, sizeof(intent)) != sizeof(intent)) partially evaluated: d->read((char *)&intent, sizeof(intent)) != sizeof(intent) no Evaluation Count:0 | yes Evaluation Count:35 |
| 0-35 |
299 | return false; never executed: return false; | 0 |
300 | if (d->read((char *)&profileData, sizeof(profileData)) != sizeof(profileData)) partially evaluated: d->read((char *)&profileData, sizeof(profileData)) != sizeof(profileData) no Evaluation Count:0 | yes Evaluation Count:35 |
| 0-35 |
301 | return false; never executed: return false; | 0 |
302 | if (d->read((char *)&profileSize, sizeof(profileSize)) != sizeof(profileSize)) partially evaluated: d->read((char *)&profileSize, sizeof(profileSize)) != sizeof(profileSize) no Evaluation Count:0 | yes Evaluation Count:35 |
| 0-35 |
303 | return false; never executed: return false; | 0 |
304 | if (d->read((char *)&reserved, sizeof(reserved)) != sizeof(reserved) || reserved != 0) partially evaluated: d->read((char *)&reserved, sizeof(reserved)) != sizeof(reserved) no Evaluation Count:0 | yes Evaluation Count:35 |
partially evaluated: reserved != 0 no Evaluation Count:0 | yes Evaluation Count:35 |
| 0-35 |
305 | return false; never executed: return false; | 0 |
306 | } executed: } Execution Count:35 | 35 |
307 | } executed: } Execution Count:70 | 70 |
308 | } executed: } Execution Count:78 | 78 |
309 | | - |
310 | if (ncols > 0) { // read color table evaluated: ncols > 0 yes Evaluation Count:174 | yes Evaluation Count:139 |
| 139-174 |
311 | uchar rgb[4]; executed (the execution status of this line is deduced): uchar rgb[4]; | - |
312 | int rgb_len = t == BMP_OLD ? 3 : 4; partially evaluated: t == BMP_OLD no Evaluation Count:0 | yes Evaluation Count:174 |
| 0-174 |
313 | for (int i=0; i<ncols; i++) { evaluated: i<ncols yes Evaluation Count:14006 | yes Evaluation Count:161 |
| 161-14006 |
314 | if (d->read((char *)rgb, rgb_len) != rgb_len) evaluated: d->read((char *)rgb, rgb_len) != rgb_len yes Evaluation Count:13 | yes Evaluation Count:13993 |
| 13-13993 |
315 | return false; executed: return false; Execution Count:13 | 13 |
316 | image.setColor(i, qRgb(rgb[2],rgb[1],rgb[0])); executed (the execution status of this line is deduced): image.setColor(i, qRgb(rgb[2],rgb[1],rgb[0])); | - |
317 | if (d->atEnd()) // truncated file partially evaluated: d->atEnd() no Evaluation Count:0 | yes Evaluation Count:13993 |
| 0-13993 |
318 | return false; never executed: return false; | 0 |
319 | } executed: } Execution Count:13993 | 13993 |
320 | } else if (comp == BMP_BITFIELDS && (nbits == 16 || nbits == 32)) { executed: } Execution Count:161 evaluated: comp == BMP_BITFIELDS yes Evaluation Count:43 | yes Evaluation Count:96 |
partially evaluated: nbits == 16 no Evaluation Count:0 | yes Evaluation Count:43 |
partially evaluated: nbits == 32 yes Evaluation Count:43 | no Evaluation Count:0 |
| 0-161 |
321 | red_shift = calc_shift(red_mask); executed (the execution status of this line is deduced): red_shift = calc_shift(red_mask); | - |
322 | red_scale = 256 / ((red_mask >> red_shift) + 1); executed (the execution status of this line is deduced): red_scale = 256 / ((red_mask >> red_shift) + 1); | - |
323 | green_shift = calc_shift(green_mask); executed (the execution status of this line is deduced): green_shift = calc_shift(green_mask); | - |
324 | green_scale = 256 / ((green_mask >> green_shift) + 1); executed (the execution status of this line is deduced): green_scale = 256 / ((green_mask >> green_shift) + 1); | - |
325 | blue_shift = calc_shift(blue_mask); executed (the execution status of this line is deduced): blue_shift = calc_shift(blue_mask); | - |
326 | blue_scale = 256 / ((blue_mask >> blue_shift) + 1); executed (the execution status of this line is deduced): blue_scale = 256 / ((blue_mask >> blue_shift) + 1); | - |
327 | } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) { executed: } Execution Count:43 partially evaluated: comp == BMP_RGB yes Evaluation Count:96 | no Evaluation Count:0 |
evaluated: nbits == 24 yes Evaluation Count:76 | yes Evaluation Count:20 |
partially evaluated: nbits == 32 no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-96 |
328 | blue_mask = 0x000000ff; executed (the execution status of this line is deduced): blue_mask = 0x000000ff; | - |
329 | green_mask = 0x0000ff00; executed (the execution status of this line is deduced): green_mask = 0x0000ff00; | - |
330 | red_mask = 0x00ff0000; executed (the execution status of this line is deduced): red_mask = 0x00ff0000; | - |
331 | blue_shift = 0; executed (the execution status of this line is deduced): blue_shift = 0; | - |
332 | green_shift = 8; executed (the execution status of this line is deduced): green_shift = 8; | - |
333 | red_shift = 16; executed (the execution status of this line is deduced): red_shift = 16; | - |
334 | blue_scale = green_scale = red_scale = 1; executed (the execution status of this line is deduced): blue_scale = green_scale = red_scale = 1; | - |
335 | } else if (comp == BMP_RGB && nbits == 16) { executed: } Execution Count:76 partially evaluated: comp == BMP_RGB yes Evaluation Count:20 | no Evaluation Count:0 |
partially evaluated: nbits == 16 yes Evaluation Count:20 | no Evaluation Count:0 |
| 0-76 |
336 | blue_mask = 0x001f; executed (the execution status of this line is deduced): blue_mask = 0x001f; | - |
337 | green_mask = 0x03e0; executed (the execution status of this line is deduced): green_mask = 0x03e0; | - |
338 | red_mask = 0x7c00; executed (the execution status of this line is deduced): red_mask = 0x7c00; | - |
339 | blue_shift = 0; executed (the execution status of this line is deduced): blue_shift = 0; | - |
340 | green_shift = 2; executed (the execution status of this line is deduced): green_shift = 2; | - |
341 | red_shift = 7; executed (the execution status of this line is deduced): red_shift = 7; | - |
342 | red_scale = 1; executed (the execution status of this line is deduced): red_scale = 1; | - |
343 | green_scale = 1; executed (the execution status of this line is deduced): green_scale = 1; | - |
344 | blue_scale = 8; executed (the execution status of this line is deduced): blue_scale = 8; | - |
345 | } executed: } Execution Count:20 | 20 |
346 | | - |
347 | // offset can be bogus, be careful | - |
348 | if (offset>=0 && startpos + offset > d->pos()) { partially evaluated: offset>=0 yes Evaluation Count:300 | no Evaluation Count:0 |
partially evaluated: startpos + offset > d->pos() no Evaluation Count:0 | yes Evaluation Count:300 |
| 0-300 |
349 | if (!d->isSequential()) never evaluated: !d->isSequential() | 0 |
350 | d->seek(startpos + offset); // start of image data never executed: d->seek(startpos + offset); | 0 |
351 | } | 0 |
352 | | - |
353 | int bpl = image.bytesPerLine(); executed (the execution status of this line is deduced): int bpl = image.bytesPerLine(); | - |
354 | uchar *data = image.bits(); executed (the execution status of this line is deduced): uchar *data = image.bits(); | - |
355 | | - |
356 | if (nbits == 1) { // 1 bit BMP image evaluated: nbits == 1 yes Evaluation Count:2 | yes Evaluation Count:298 |
| 2-298 |
357 | while (--h >= 0) { evaluated: --h >= 0 yes Evaluation Count:140 | yes Evaluation Count:2 |
| 2-140 |
358 | if (d->read((char*)(data + h*bpl), bpl) != bpl) partially evaluated: d->read((char*)(data + h*bpl), bpl) != bpl no Evaluation Count:0 | yes Evaluation Count:140 |
| 0-140 |
359 | break; | 0 |
360 | } executed: } Execution Count:140 | 140 |
361 | if (ncols == 2 && qGray(image.color(0)) < qGray(image.color(1))) partially evaluated: ncols == 2 yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: qGray(image.color(0)) < qGray(image.color(1)) no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
362 | swapPixel01(&image); // pixel 0 is white! never executed: swapPixel01(&image); | 0 |
363 | } executed: } Execution Count:2 | 2 |
364 | | - |
365 | else if (nbits == 4) { // 4 bit BMP image evaluated: nbits == 4 yes Evaluation Count:86 | yes Evaluation Count:212 |
| 86-212 |
366 | int buflen = ((w+7)/8)*4; executed (the execution status of this line is deduced): int buflen = ((w+7)/8)*4; | - |
367 | uchar *buf = new uchar[buflen]; executed (the execution status of this line is deduced): uchar *buf = new uchar[buflen]; | - |
368 | if (comp == BMP_RLE4) { // run length compression evaluated: comp == BMP_RLE4 yes Evaluation Count:33 | yes Evaluation Count:53 |
| 33-53 |
369 | int x=0, y=0, c, i; executed (the execution status of this line is deduced): int x=0, y=0, c, i; | - |
370 | quint8 b; executed (the execution status of this line is deduced): quint8 b; | - |
371 | register uchar *p = data + (h-1)*bpl; executed (the execution status of this line is deduced): register uchar *p = data + (h-1)*bpl; | - |
372 | const uchar *endp = p + w; executed (the execution status of this line is deduced): const uchar *endp = p + w; | - |
373 | while (y < h) { evaluated: y < h yes Evaluation Count:185485 | yes Evaluation Count:33 |
| 33-185485 |
374 | if (!d->getChar((char *)&b)) partially evaluated: !d->getChar((char *)&b) no Evaluation Count:0 | yes Evaluation Count:185485 |
| 0-185485 |
375 | break; | 0 |
376 | if (b == 0) { // escape code evaluated: b == 0 yes Evaluation Count:25398 | yes Evaluation Count:160087 |
| 25398-160087 |
377 | if (!d->getChar((char *)&b) || b == 1) { partially evaluated: !d->getChar((char *)&b) no Evaluation Count:0 | yes Evaluation Count:25398 |
evaluated: b == 1 yes Evaluation Count:33 | yes Evaluation Count:25365 |
| 0-25398 |
378 | y = h; // exit loop executed (the execution status of this line is deduced): y = h; | - |
379 | } else switch (b) { executed: } Execution Count:33 | 33 |
380 | case 0: // end of line | - |
381 | x = 0; executed (the execution status of this line is deduced): x = 0; | - |
382 | y++; executed (the execution status of this line is deduced): y++; | - |
383 | p = data + (h-y-1)*bpl; executed (the execution status of this line is deduced): p = data + (h-y-1)*bpl; | - |
384 | break; executed: break; Execution Count:9801 | 9801 |
385 | case 2: // delta (jump) | - |
386 | { | - |
387 | quint8 tmp; never executed (the execution status of this line is deduced): quint8 tmp; | - |
388 | d->getChar((char *)&tmp); never executed (the execution status of this line is deduced): d->getChar((char *)&tmp); | - |
389 | x += tmp; never executed (the execution status of this line is deduced): x += tmp; | - |
390 | d->getChar((char *)&tmp); never executed (the execution status of this line is deduced): d->getChar((char *)&tmp); | - |
391 | y += tmp; never executed (the execution status of this line is deduced): y += tmp; | - |
392 | } | - |
393 | | - |
394 | // Protection | - |
395 | if ((uint)x >= (uint)w) never evaluated: (uint)x >= (uint)w | 0 |
396 | x = w-1; | 0 |
397 | if ((uint)y >= (uint)h) never evaluated: (uint)y >= (uint)h | 0 |
398 | y = h-1; | 0 |
399 | | - |
400 | p = data + (h-y-1)*bpl + x; never executed (the execution status of this line is deduced): p = data + (h-y-1)*bpl + x; | - |
401 | break; | 0 |
402 | default: // absolute mode | - |
403 | // Protection | - |
404 | if (p + b > endp) partially evaluated: p + b > endp no Evaluation Count:0 | yes Evaluation Count:15564 |
| 0-15564 |
405 | b = endp-p; never executed: b = endp-p; | 0 |
406 | | - |
407 | i = (c = b)/2; executed (the execution status of this line is deduced): i = (c = b)/2; | - |
408 | while (i--) { evaluated: i-- yes Evaluation Count:94972 | yes Evaluation Count:15564 |
| 15564-94972 |
409 | d->getChar((char *)&b); executed (the execution status of this line is deduced): d->getChar((char *)&b); | - |
410 | *p++ = b >> 4; executed (the execution status of this line is deduced): *p++ = b >> 4; | - |
411 | *p++ = b & 0x0f; executed (the execution status of this line is deduced): *p++ = b & 0x0f; | - |
412 | } executed: } Execution Count:94972 | 94972 |
413 | if (c & 1) { evaluated: c & 1 yes Evaluation Count:13 | yes Evaluation Count:15551 |
| 13-15551 |
414 | unsigned char tmp; executed (the execution status of this line is deduced): unsigned char tmp; | - |
415 | d->getChar((char *)&tmp); executed (the execution status of this line is deduced): d->getChar((char *)&tmp); | - |
416 | *p++ = tmp >> 4; executed (the execution status of this line is deduced): *p++ = tmp >> 4; | - |
417 | } executed: } Execution Count:13 | 13 |
418 | if ((((c & 3) + 1) & 2) == 2) evaluated: (((c & 3) + 1) & 2) == 2 yes Evaluation Count:8253 | yes Evaluation Count:7311 |
| 7311-8253 |
419 | d->getChar(0); // align on word boundary executed: d->getChar(0); Execution Count:8253 | 8253 |
420 | x += c; | - |
421 | } executed: } Execution Count:15564 | 15564 |
422 | } else { // encoded mode | - |
423 | // Protection | - |
424 | if (p + b > endp) partially evaluated: p + b > endp no Evaluation Count:0 | yes Evaluation Count:160087 |
| 0-160087 |
425 | b = endp-p; never executed: b = endp-p; | 0 |
426 | | - |
427 | i = (c = b)/2; executed (the execution status of this line is deduced): i = (c = b)/2; | - |
428 | d->getChar((char *)&b); // 2 pixels to be repeated executed (the execution status of this line is deduced): d->getChar((char *)&b); | - |
429 | while (i--) { evaluated: i-- yes Evaluation Count:2980473 | yes Evaluation Count:160087 |
| 160087-2980473 |
430 | *p++ = b >> 4; executed (the execution status of this line is deduced): *p++ = b >> 4; | - |
431 | *p++ = b & 0x0f; executed (the execution status of this line is deduced): *p++ = b & 0x0f; | - |
432 | } executed: } Execution Count:2980473 | 2980473 |
433 | if (c & 1) evaluated: c & 1 yes Evaluation Count:52 | yes Evaluation Count:160035 |
| 52-160035 |
434 | *p++ = b >> 4; executed: *p++ = b >> 4; Execution Count:52 | 52 |
435 | x += c; executed (the execution status of this line is deduced): x += c; | - |
436 | } executed: } Execution Count:160087 | 160087 |
437 | } | - |
438 | } else if (comp == BMP_RGB) { // no compression executed: } Execution Count:33 partially evaluated: comp == BMP_RGB yes Evaluation Count:53 | no Evaluation Count:0 |
| 0-53 |
439 | memset(data, 0, h*bpl); executed (the execution status of this line is deduced): memset(data, 0, h*bpl); | - |
440 | while (--h >= 0) { evaluated: --h >= 0 yes Evaluation Count:666 | yes Evaluation Count:42 |
| 42-666 |
441 | if (d->read((char*)buf,buflen) != buflen) evaluated: d->read((char*)buf,buflen) != buflen yes Evaluation Count:11 | yes Evaluation Count:655 |
| 11-655 |
442 | break; executed: break; Execution Count:11 | 11 |
443 | register uchar *p = data + h*bpl; executed (the execution status of this line is deduced): register uchar *p = data + h*bpl; | - |
444 | uchar *b = buf; executed (the execution status of this line is deduced): uchar *b = buf; | - |
445 | for (int i=0; i<w/2; i++) { // convert nibbles to bytes evaluated: i<w/2 yes Evaluation Count:45105 | yes Evaluation Count:655 |
| 655-45105 |
446 | *p++ = *b >> 4; executed (the execution status of this line is deduced): *p++ = *b >> 4; | - |
447 | *p++ = *b++ & 0x0f; executed (the execution status of this line is deduced): *p++ = *b++ & 0x0f; | - |
448 | } executed: } Execution Count:45105 | 45105 |
449 | if (w & 1) // the last nibble evaluated: w & 1 yes Evaluation Count:319 | yes Evaluation Count:336 |
| 319-336 |
450 | *p = *b >> 4; executed: *p = *b >> 4; Execution Count:319 | 319 |
451 | } executed: } Execution Count:655 | 655 |
452 | } executed: } Execution Count:53 | 53 |
453 | delete [] buf; executed (the execution status of this line is deduced): delete [] buf; | - |
454 | } executed: } Execution Count:86 | 86 |
455 | | - |
456 | else if (nbits == 8) { // 8 bit BMP image evaluated: nbits == 8 yes Evaluation Count:73 | yes Evaluation Count:139 |
| 73-139 |
457 | if (comp == BMP_RLE8) { // run length compression evaluated: comp == BMP_RLE8 yes Evaluation Count:20 | yes Evaluation Count:53 |
| 20-53 |
458 | int x=0, y=0; executed (the execution status of this line is deduced): int x=0, y=0; | - |
459 | quint8 b; executed (the execution status of this line is deduced): quint8 b; | - |
460 | register uchar *p = data + (h-1)*bpl; executed (the execution status of this line is deduced): register uchar *p = data + (h-1)*bpl; | - |
461 | const uchar *endp = p + w; executed (the execution status of this line is deduced): const uchar *endp = p + w; | - |
462 | while (y < h) { evaluated: y < h yes Evaluation Count:455860 | yes Evaluation Count:20 |
| 20-455860 |
463 | if (!d->getChar((char *)&b)) partially evaluated: !d->getChar((char *)&b) no Evaluation Count:0 | yes Evaluation Count:455860 |
| 0-455860 |
464 | break; | 0 |
465 | if (b == 0) { // escape code evaluated: b == 0 yes Evaluation Count:5600 | yes Evaluation Count:450260 |
| 5600-450260 |
466 | if (!d->getChar((char *)&b) || b == 1) { partially evaluated: !d->getChar((char *)&b) no Evaluation Count:0 | yes Evaluation Count:5600 |
evaluated: b == 1 yes Evaluation Count:20 | yes Evaluation Count:5580 |
| 0-5600 |
467 | y = h; // exit loop executed (the execution status of this line is deduced): y = h; | - |
468 | } else switch (b) { executed: } Execution Count:20 | 20 |
469 | case 0: // end of line | - |
470 | x = 0; executed (the execution status of this line is deduced): x = 0; | - |
471 | y++; executed (the execution status of this line is deduced): y++; | - |
472 | p = data + (h-y-1)*bpl; executed (the execution status of this line is deduced): p = data + (h-y-1)*bpl; | - |
473 | break; executed: break; Execution Count:5580 | 5580 |
474 | case 2: // delta (jump) | - |
475 | // Protection | - |
476 | if ((uint)x >= (uint)w) never evaluated: (uint)x >= (uint)w | 0 |
477 | x = w-1; | 0 |
478 | if ((uint)y >= (uint)h) never evaluated: (uint)y >= (uint)h | 0 |
479 | y = h-1; | 0 |
480 | | - |
481 | { | - |
482 | quint8 tmp; never executed (the execution status of this line is deduced): quint8 tmp; | - |
483 | d->getChar((char *)&tmp); never executed (the execution status of this line is deduced): d->getChar((char *)&tmp); | - |
484 | x += tmp; never executed (the execution status of this line is deduced): x += tmp; | - |
485 | d->getChar((char *)&tmp); never executed (the execution status of this line is deduced): d->getChar((char *)&tmp); | - |
486 | y += tmp; never executed (the execution status of this line is deduced): y += tmp; | - |
487 | } | - |
488 | p = data + (h-y-1)*bpl + x; never executed (the execution status of this line is deduced): p = data + (h-y-1)*bpl + x; | - |
489 | break; | 0 |
490 | default: // absolute mode | - |
491 | // Protection | - |
492 | if (p + b > endp) never evaluated: p + b > endp | 0 |
493 | b = endp-p; never executed: b = endp-p; | 0 |
494 | | - |
495 | if (d->read((char *)p, b) != b) never evaluated: d->read((char *)p, b) != b | 0 |
496 | return false; never executed: return false; | 0 |
497 | if ((b & 1) == 1) never evaluated: (b & 1) == 1 | 0 |
498 | d->getChar(0); // align on word boundary never executed: d->getChar(0); | 0 |
499 | x += b; | - |
500 | p += b; | - |
501 | } | 0 |
502 | } else { // encoded mode | - |
503 | // Protection | - |
504 | if (p + b > endp) partially evaluated: p + b > endp no Evaluation Count:0 | yes Evaluation Count:450260 |
| 0-450260 |
505 | b = endp-p; never executed: b = endp-p; | 0 |
506 | | - |
507 | char tmp; executed (the execution status of this line is deduced): char tmp; | - |
508 | d->getChar(&tmp); executed (the execution status of this line is deduced): d->getChar(&tmp); | - |
509 | memset(p, tmp, b); // repeat pixel executed (the execution status of this line is deduced): memset(p, tmp, b); | - |
510 | x += b; executed (the execution status of this line is deduced): x += b; | - |
511 | p += b; executed (the execution status of this line is deduced): p += b; | - |
512 | } executed: } Execution Count:450260 | 450260 |
513 | } | - |
514 | } else if (comp == BMP_RGB) { // uncompressed executed: } Execution Count:20 partially evaluated: comp == BMP_RGB yes Evaluation Count:53 | no Evaluation Count:0 |
| 0-53 |
515 | while (--h >= 0) { evaluated: --h >= 0 yes Evaluation Count:10470 | yes Evaluation Count:53 |
| 53-10470 |
516 | if (d->read((char *)data + h*bpl, bpl) != bpl) partially evaluated: d->read((char *)data + h*bpl, bpl) != bpl no Evaluation Count:0 | yes Evaluation Count:10470 |
| 0-10470 |
517 | break; | 0 |
518 | } executed: } Execution Count:10470 | 10470 |
519 | } executed: } Execution Count:53 | 53 |
520 | } | - |
521 | | - |
522 | else if (nbits == 16 || nbits == 24 || nbits == 32) { // 16,24,32 bit BMP image evaluated: nbits == 16 yes Evaluation Count:20 | yes Evaluation Count:119 |
evaluated: nbits == 24 yes Evaluation Count:76 | yes Evaluation Count:43 |
partially evaluated: nbits == 32 yes Evaluation Count:43 | no Evaluation Count:0 |
| 0-119 |
523 | register QRgb *p; executed (the execution status of this line is deduced): register QRgb *p; | - |
524 | QRgb *end; executed (the execution status of this line is deduced): QRgb *end; | - |
525 | uchar *buf24 = new uchar[bpl]; executed (the execution status of this line is deduced): uchar *buf24 = new uchar[bpl]; | - |
526 | int bpl24 = ((w*nbits+31)/32)*4; executed (the execution status of this line is deduced): int bpl24 = ((w*nbits+31)/32)*4; | - |
527 | uchar *b; executed (the execution status of this line is deduced): uchar *b; | - |
528 | int c; executed (the execution status of this line is deduced): int c; | - |
529 | | - |
530 | while (--h >= 0) { evaluated: --h >= 0 yes Evaluation Count:19736 | yes Evaluation Count:139 |
| 139-19736 |
531 | p = (QRgb *)(data + h*bpl); executed (the execution status of this line is deduced): p = (QRgb *)(data + h*bpl); | - |
532 | end = p + w; executed (the execution status of this line is deduced): end = p + w; | - |
533 | if (d->read((char *)buf24,bpl24) != bpl24) partially evaluated: d->read((char *)buf24,bpl24) != bpl24 no Evaluation Count:0 | yes Evaluation Count:19736 |
| 0-19736 |
534 | break; | 0 |
535 | b = buf24; executed (the execution status of this line is deduced): b = buf24; | - |
536 | while (p < end) { evaluated: p < end yes Evaluation Count:6330688 | yes Evaluation Count:19736 |
| 19736-6330688 |
537 | c = *(uchar*)b | (*(uchar*)(b+1)<<8); executed (the execution status of this line is deduced): c = *(uchar*)b | (*(uchar*)(b+1)<<8); | - |
538 | if (nbits != 16) evaluated: nbits != 16 yes Evaluation Count:4794688 | yes Evaluation Count:1536000 |
| 1536000-4794688 |
539 | c |= *(uchar*)(b+2)<<16; executed: c |= *(uchar*)(b+2)<<16; Execution Count:4794688 | 4794688 |
540 | *p++ = qRgb(((c & red_mask) >> red_shift) * red_scale, executed (the execution status of this line is deduced): *p++ = qRgb(((c & red_mask) >> red_shift) * red_scale, | - |
541 | ((c & green_mask) >> green_shift) * green_scale, executed (the execution status of this line is deduced): ((c & green_mask) >> green_shift) * green_scale, | - |
542 | ((c & blue_mask) >> blue_shift) * blue_scale); executed (the execution status of this line is deduced): ((c & blue_mask) >> blue_shift) * blue_scale); | - |
543 | b += nbits/8; executed (the execution status of this line is deduced): b += nbits/8; | - |
544 | } executed: } Execution Count:6330688 | 6330688 |
545 | } executed: } Execution Count:19736 | 19736 |
546 | delete[] buf24; executed (the execution status of this line is deduced): delete[] buf24; | - |
547 | } executed: } Execution Count:139 | 139 |
548 | | - |
549 | if (bi.biHeight < 0) { evaluated: bi.biHeight < 0 yes Evaluation Count:20 | yes Evaluation Count:280 |
| 20-280 |
550 | // Flip the image | - |
551 | uchar *buf = new uchar[bpl]; executed (the execution status of this line is deduced): uchar *buf = new uchar[bpl]; | - |
552 | h = -bi.biHeight; executed (the execution status of this line is deduced): h = -bi.biHeight; | - |
553 | for (int y = 0; y < h/2; ++y) { evaluated: y < h/2 yes Evaluation Count:640 | yes Evaluation Count:20 |
| 20-640 |
554 | memcpy(buf, data + y*bpl, bpl); executed (the execution status of this line is deduced): memcpy(buf, data + y*bpl, bpl); | - |
555 | memcpy(data + y*bpl, data + (h-y-1)*bpl, bpl); executed (the execution status of this line is deduced): memcpy(data + y*bpl, data + (h-y-1)*bpl, bpl); | - |
556 | memcpy(data + (h-y-1)*bpl, buf, bpl); executed (the execution status of this line is deduced): memcpy(data + (h-y-1)*bpl, buf, bpl); | - |
557 | } executed: } Execution Count:640 | 640 |
558 | delete [] buf; executed (the execution status of this line is deduced): delete [] buf; | - |
559 | } executed: } Execution Count:20 | 20 |
560 | | - |
561 | return true; executed: return true; Execution Count:300 | 300 |
562 | } | - |
563 | | - |
564 | // this is also used in qmime_win.cpp | - |
565 | bool qt_write_dib(QDataStream &s, QImage image) | - |
566 | { | - |
567 | int nbits; executed (the execution status of this line is deduced): int nbits; | - |
568 | int bpl_bmp; executed (the execution status of this line is deduced): int bpl_bmp; | - |
569 | int bpl = image.bytesPerLine(); executed (the execution status of this line is deduced): int bpl = image.bytesPerLine(); | - |
570 | | - |
571 | QIODevice* d = s.device(); executed (the execution status of this line is deduced): QIODevice* d = s.device(); | - |
572 | if (!d->isWritable()) partially evaluated: !d->isWritable() no Evaluation Count:0 | yes Evaluation Count:32 |
| 0-32 |
573 | return false; never executed: return false; | 0 |
574 | | - |
575 | if (image.depth() == 8 && image.colorCount() <= 16) { evaluated: image.depth() == 8 yes Evaluation Count:9 | yes Evaluation Count:23 |
evaluated: image.colorCount() <= 16 yes Evaluation Count:4 | yes Evaluation Count:5 |
| 4-23 |
576 | bpl_bmp = (((bpl+1)/2+3)/4)*4; executed (the execution status of this line is deduced): bpl_bmp = (((bpl+1)/2+3)/4)*4; | - |
577 | nbits = 4; executed (the execution status of this line is deduced): nbits = 4; | - |
578 | } else if (image.depth() == 32) { executed: } Execution Count:4 evaluated: image.depth() == 32 yes Evaluation Count:21 | yes Evaluation Count:7 |
| 4-21 |
579 | bpl_bmp = ((image.width()*24+31)/32)*4; executed (the execution status of this line is deduced): bpl_bmp = ((image.width()*24+31)/32)*4; | - |
580 | nbits = 24; executed (the execution status of this line is deduced): nbits = 24; | - |
581 | } else { executed: } Execution Count:21 | 21 |
582 | bpl_bmp = bpl; executed (the execution status of this line is deduced): bpl_bmp = bpl; | - |
583 | nbits = image.depth(); executed (the execution status of this line is deduced): nbits = image.depth(); | - |
584 | } executed: } Execution Count:7 | 7 |
585 | | - |
586 | BMP_INFOHDR bi; executed (the execution status of this line is deduced): BMP_INFOHDR bi; | - |
587 | bi.biSize = BMP_WIN; // build info header executed (the execution status of this line is deduced): bi.biSize = BMP_WIN; | - |
588 | bi.biWidth = image.width(); executed (the execution status of this line is deduced): bi.biWidth = image.width(); | - |
589 | bi.biHeight = image.height(); executed (the execution status of this line is deduced): bi.biHeight = image.height(); | - |
590 | bi.biPlanes = 1; executed (the execution status of this line is deduced): bi.biPlanes = 1; | - |
591 | bi.biBitCount = nbits; executed (the execution status of this line is deduced): bi.biBitCount = nbits; | - |
592 | bi.biCompression = BMP_RGB; executed (the execution status of this line is deduced): bi.biCompression = BMP_RGB; | - |
593 | bi.biSizeImage = bpl_bmp*image.height(); executed (the execution status of this line is deduced): bi.biSizeImage = bpl_bmp*image.height(); | - |
594 | bi.biXPelsPerMeter = image.dotsPerMeterX() ? image.dotsPerMeterX() partially evaluated: image.dotsPerMeterX() yes Evaluation Count:32 | no Evaluation Count:0 |
| 0-32 |
595 | : 2834; // 72 dpi default executed (the execution status of this line is deduced): : 2834; | - |
596 | bi.biYPelsPerMeter = image.dotsPerMeterY() ? image.dotsPerMeterY() : 2834; partially evaluated: image.dotsPerMeterY() yes Evaluation Count:32 | no Evaluation Count:0 |
| 0-32 |
597 | bi.biClrUsed = image.colorCount(); executed (the execution status of this line is deduced): bi.biClrUsed = image.colorCount(); | - |
598 | bi.biClrImportant = image.colorCount(); executed (the execution status of this line is deduced): bi.biClrImportant = image.colorCount(); | - |
599 | s << bi; // write info header executed (the execution status of this line is deduced): s << bi; | - |
600 | if (s.status() != QDataStream::Ok) partially evaluated: s.status() != QDataStream::Ok no Evaluation Count:0 | yes Evaluation Count:32 |
| 0-32 |
601 | return false; never executed: return false; | 0 |
602 | | - |
603 | if (image.depth() != 32) { // write color table evaluated: image.depth() != 32 yes Evaluation Count:11 | yes Evaluation Count:21 |
| 11-21 |
604 | uchar *color_table = new uchar[4*image.colorCount()]; executed (the execution status of this line is deduced): uchar *color_table = new uchar[4*image.colorCount()]; | - |
605 | uchar *rgb = color_table; executed (the execution status of this line is deduced): uchar *rgb = color_table; | - |
606 | QVector<QRgb> c = image.colorTable(); executed (the execution status of this line is deduced): QVector<QRgb> c = image.colorTable(); | - |
607 | for (int i=0; i<image.colorCount(); i++) { evaluated: i<image.colorCount() yes Evaluation Count:1220 | yes Evaluation Count:11 |
| 11-1220 |
608 | *rgb++ = qBlue (c[i]); executed (the execution status of this line is deduced): *rgb++ = qBlue (c[i]); | - |
609 | *rgb++ = qGreen(c[i]); executed (the execution status of this line is deduced): *rgb++ = qGreen(c[i]); | - |
610 | *rgb++ = qRed (c[i]); executed (the execution status of this line is deduced): *rgb++ = qRed (c[i]); | - |
611 | *rgb++ = 0; executed (the execution status of this line is deduced): *rgb++ = 0; | - |
612 | } executed: } Execution Count:1220 | 1220 |
613 | if (d->write((char *)color_table, 4*image.colorCount()) == -1) { partially evaluated: d->write((char *)color_table, 4*image.colorCount()) == -1 no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
614 | delete [] color_table; never executed (the execution status of this line is deduced): delete [] color_table; | - |
615 | return false; never executed: return false; | 0 |
616 | } | - |
617 | delete [] color_table; executed (the execution status of this line is deduced): delete [] color_table; | - |
618 | } executed: } Execution Count:11 | 11 |
619 | | - |
620 | if (image.format() == QImage::Format_MonoLSB) evaluated: image.format() == QImage::Format_MonoLSB yes Evaluation Count:1 | yes Evaluation Count:31 |
| 1-31 |
621 | image = image.convertToFormat(QImage::Format_Mono); executed: image = image.convertToFormat(QImage::Format_Mono); Execution Count:1 | 1 |
622 | | - |
623 | int y; executed (the execution status of this line is deduced): int y; | - |
624 | | - |
625 | if (nbits == 1 || nbits == 8) { // direct output evaluated: nbits == 1 yes Evaluation Count:2 | yes Evaluation Count:30 |
evaluated: nbits == 8 yes Evaluation Count:5 | yes Evaluation Count:25 |
| 2-30 |
626 | for (y=image.height()-1; y>=0; y--) { evaluated: y>=0 yes Evaluation Count:1010 | yes Evaluation Count:7 |
| 7-1010 |
627 | if (d->write((char*)image.constScanLine(y), bpl) == -1) partially evaluated: d->write((char*)image.constScanLine(y), bpl) == -1 no Evaluation Count:0 | yes Evaluation Count:1010 |
| 0-1010 |
628 | return false; never executed: return false; | 0 |
629 | } executed: } Execution Count:1010 | 1010 |
630 | return true; executed: return true; Execution Count:7 | 7 |
631 | } | - |
632 | | - |
633 | uchar *buf = new uchar[bpl_bmp]; executed (the execution status of this line is deduced): uchar *buf = new uchar[bpl_bmp]; | - |
634 | uchar *b, *end; executed (the execution status of this line is deduced): uchar *b, *end; | - |
635 | register const uchar *p; executed (the execution status of this line is deduced): register const uchar *p; | - |
636 | | - |
637 | memset(buf, 0, bpl_bmp); executed (the execution status of this line is deduced): memset(buf, 0, bpl_bmp); | - |
638 | for (y=image.height()-1; y>=0; y--) { // write the image bits evaluated: y>=0 yes Evaluation Count:2256 | yes Evaluation Count:25 |
| 25-2256 |
639 | if (nbits == 4) { // convert 8 -> 4 bits evaluated: nbits == 4 yes Evaluation Count:32 | yes Evaluation Count:2224 |
| 32-2224 |
640 | p = image.constScanLine(y); executed (the execution status of this line is deduced): p = image.constScanLine(y); | - |
641 | b = buf; executed (the execution status of this line is deduced): b = buf; | - |
642 | end = b + image.width()/2; executed (the execution status of this line is deduced): end = b + image.width()/2; | - |
643 | while (b < end) { evaluated: b < end yes Evaluation Count:3840 | yes Evaluation Count:32 |
| 32-3840 |
644 | *b++ = (*p << 4) | (*(p+1) & 0x0f); executed (the execution status of this line is deduced): *b++ = (*p << 4) | (*(p+1) & 0x0f); | - |
645 | p += 2; executed (the execution status of this line is deduced): p += 2; | - |
646 | } executed: } Execution Count:3840 | 3840 |
647 | if (image.width() & 1) partially evaluated: image.width() & 1 no Evaluation Count:0 | yes Evaluation Count:32 |
| 0-32 |
648 | *b = *p << 4; never executed: *b = *p << 4; | 0 |
649 | } else { // 32 bits executed: } Execution Count:32 | 32 |
650 | const QRgb *p = (const QRgb *)image.constScanLine(y); executed (the execution status of this line is deduced): const QRgb *p = (const QRgb *)image.constScanLine(y); | - |
651 | const QRgb *end = p + image.width(); executed (the execution status of this line is deduced): const QRgb *end = p + image.width(); | - |
652 | b = buf; executed (the execution status of this line is deduced): b = buf; | - |
653 | while (p < end) { evaluated: p < end yes Evaluation Count:493944 | yes Evaluation Count:2224 |
| 2224-493944 |
654 | *b++ = qBlue(*p); executed (the execution status of this line is deduced): *b++ = qBlue(*p); | - |
655 | *b++ = qGreen(*p); executed (the execution status of this line is deduced): *b++ = qGreen(*p); | - |
656 | *b++ = qRed(*p); executed (the execution status of this line is deduced): *b++ = qRed(*p); | - |
657 | p++; executed (the execution status of this line is deduced): p++; | - |
658 | } executed: } Execution Count:493944 | 493944 |
659 | } executed: } Execution Count:2224 | 2224 |
660 | if (bpl_bmp != d->write((char*)buf, bpl_bmp)) { partially evaluated: bpl_bmp != d->write((char*)buf, bpl_bmp) no Evaluation Count:0 | yes Evaluation Count:2256 |
| 0-2256 |
661 | delete[] buf; never executed (the execution status of this line is deduced): delete[] buf; | - |
662 | return false; never executed: return false; | 0 |
663 | } | - |
664 | } executed: } Execution Count:2256 | 2256 |
665 | delete[] buf; executed (the execution status of this line is deduced): delete[] buf; | - |
666 | return true; executed: return true; Execution Count:25 | 25 |
667 | } | - |
668 | | - |
669 | // this is also used in qmime_win.cpp | - |
670 | bool qt_read_dib(QDataStream &s, QImage &image) | - |
671 | { | - |
672 | BMP_INFOHDR bi; never executed (the execution status of this line is deduced): BMP_INFOHDR bi; | - |
673 | if (!read_dib_infoheader(s, bi)) never evaluated: !read_dib_infoheader(s, bi) | 0 |
674 | return false; never executed: return false; | 0 |
675 | 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 |
676 | } | - |
677 | | - |
678 | QBmpHandler::QBmpHandler(InternalFormat fmt) : | - |
679 | m_format(fmt), state(Ready) | - |
680 | { | - |
681 | } executed: } Execution Count:372 | 372 |
682 | | - |
683 | QByteArray QBmpHandler::formatName() const | - |
684 | { | - |
685 | return m_format == BmpFormat ? "bmp" : "dib"; executed: return m_format == BmpFormat ? "bmp" : "dib"; Execution Count:85 | 85 |
686 | } | - |
687 | | - |
688 | bool QBmpHandler::readHeader() | - |
689 | { | - |
690 | state = Error; executed (the execution status of this line is deduced): state = Error; | - |
691 | | - |
692 | QIODevice *d = device(); executed (the execution status of this line is deduced): QIODevice *d = device(); | - |
693 | QDataStream s(d); executed (the execution status of this line is deduced): QDataStream s(d); | - |
694 | startpos = d->pos(); executed (the execution status of this line is deduced): startpos = d->pos(); | - |
695 | | - |
696 | // Intel byte order | - |
697 | s.setByteOrder(QDataStream::LittleEndian); executed (the execution status of this line is deduced): s.setByteOrder(QDataStream::LittleEndian); | - |
698 | | - |
699 | // read BMP file header | - |
700 | if (m_format == BmpFormat && !read_dib_fileheader(s, fileHeader)) partially evaluated: m_format == BmpFormat yes Evaluation Count:341 | no Evaluation Count:0 |
evaluated: !read_dib_fileheader(s, fileHeader) yes Evaluation Count:20 | yes Evaluation Count:321 |
| 0-341 |
701 | return false; executed: return false; Execution Count:20 | 20 |
702 | | - |
703 | // read BMP info header | - |
704 | if (!read_dib_infoheader(s, infoHeader)) partially evaluated: !read_dib_infoheader(s, infoHeader) no Evaluation Count:0 | yes Evaluation Count:321 |
| 0-321 |
705 | return false; never executed: return false; | 0 |
706 | | - |
707 | state = ReadHeader; executed (the execution status of this line is deduced): state = ReadHeader; | - |
708 | return true; executed: return true; Execution Count:321 | 321 |
709 | } | - |
710 | | - |
711 | bool QBmpHandler::canRead() const | - |
712 | { | - |
713 | if (m_format == BmpFormat && state == Ready && !canRead(device())) partially evaluated: m_format == BmpFormat yes Evaluation Count:119 | no Evaluation Count:0 |
evaluated: state == Ready yes Evaluation Count:111 | yes Evaluation Count:8 |
evaluated: !canRead(device()) yes Evaluation Count:34 | yes Evaluation Count:77 |
| 0-119 |
714 | return false; executed: return false; Execution Count:34 | 34 |
715 | | - |
716 | if (state != Error) { partially evaluated: state != Error yes Evaluation Count:85 | no Evaluation Count:0 |
| 0-85 |
717 | setFormat(formatName()); executed (the execution status of this line is deduced): setFormat(formatName()); | - |
718 | return true; executed: return true; Execution Count:85 | 85 |
719 | } | - |
720 | | - |
721 | return false; never executed: return false; | 0 |
722 | } | - |
723 | | - |
724 | bool QBmpHandler::canRead(QIODevice *device) | - |
725 | { | - |
726 | if (!device) { partially evaluated: !device no Evaluation Count:0 | yes Evaluation Count:222 |
| 0-222 |
727 | qWarning("QBmpHandler::canRead() called with 0 pointer"); never executed (the execution status of this line is deduced): QMessageLogger("image/qbmphandler.cpp", 727, __PRETTY_FUNCTION__).warning("QBmpHandler::canRead() called with 0 pointer"); | - |
728 | return false; never executed: return false; | 0 |
729 | } | - |
730 | | - |
731 | char head[2]; executed (the execution status of this line is deduced): char head[2]; | - |
732 | if (device->peek(head, sizeof(head)) != sizeof(head)) evaluated: device->peek(head, sizeof(head)) != sizeof(head) yes Evaluation Count:35 | yes Evaluation Count:187 |
| 35-187 |
733 | return false; executed: return false; Execution Count:35 | 35 |
734 | | - |
735 | return (qstrncmp(head, "BM", 2) == 0); executed: return (qstrncmp(head, "BM", 2) == 0); Execution Count:187 | 187 |
736 | } | - |
737 | | - |
738 | bool QBmpHandler::read(QImage *image) | - |
739 | { | - |
740 | if (state == Error) partially evaluated: state == Error no Evaluation Count:0 | yes Evaluation Count:333 |
| 0-333 |
741 | return false; never executed: return false; | 0 |
742 | | - |
743 | if (!image) { partially evaluated: !image no Evaluation Count:0 | yes Evaluation Count:333 |
| 0-333 |
744 | qWarning("QBmpHandler::read: cannot read into null pointer"); never executed (the execution status of this line is deduced): QMessageLogger("image/qbmphandler.cpp", 744, __PRETTY_FUNCTION__).warning("QBmpHandler::read: cannot read into null pointer"); | - |
745 | return false; never executed: return false; | 0 |
746 | } | - |
747 | | - |
748 | if (state == Ready && !readHeader()) { evaluated: state == Ready yes Evaluation Count:329 | yes Evaluation Count:4 |
evaluated: !readHeader() yes Evaluation Count:20 | yes Evaluation Count:309 |
| 4-329 |
749 | state = Error; executed (the execution status of this line is deduced): state = Error; | - |
750 | return false; executed: return false; Execution Count:20 | 20 |
751 | } | - |
752 | | - |
753 | QIODevice *d = device(); executed (the execution status of this line is deduced): QIODevice *d = device(); | - |
754 | QDataStream s(d); executed (the execution status of this line is deduced): QDataStream s(d); | - |
755 | | - |
756 | // Intel byte order | - |
757 | s.setByteOrder(QDataStream::LittleEndian); executed (the execution status of this line is deduced): s.setByteOrder(QDataStream::LittleEndian); | - |
758 | | - |
759 | // read image | - |
760 | const bool readSuccess = m_format == BmpFormat ? partially evaluated: m_format == BmpFormat yes Evaluation Count:313 | no Evaluation Count:0 |
| 0-313 |
761 | read_dib_body(s, infoHeader, fileHeader.bfOffBits, startpos, *image) : executed (the execution status of this line is deduced): read_dib_body(s, infoHeader, fileHeader.bfOffBits, startpos, *image) : | - |
762 | read_dib_body(s, infoHeader, -1, startpos - BMP_FILEHDR_SIZE, *image); executed (the execution status of this line is deduced): read_dib_body(s, infoHeader, -1, startpos - BMP_FILEHDR_SIZE, *image); | - |
763 | if (!readSuccess) evaluated: !readSuccess yes Evaluation Count:13 | yes Evaluation Count:300 |
| 13-300 |
764 | return false; executed: return false; Execution Count:13 | 13 |
765 | | - |
766 | state = Ready; executed (the execution status of this line is deduced): state = Ready; | - |
767 | return true; executed: return true; Execution Count:300 | 300 |
768 | } | - |
769 | | - |
770 | bool QBmpHandler::write(const QImage &img) | - |
771 | { | - |
772 | if (m_format == DibFormat) { partially evaluated: m_format == DibFormat no Evaluation Count:0 | yes Evaluation Count:32 |
| 0-32 |
773 | QDataStream dibStream(device()); never executed (the execution status of this line is deduced): QDataStream dibStream(device()); | - |
774 | dibStream.setByteOrder(QDataStream::LittleEndian); // Intel byte order never executed (the execution status of this line is deduced): dibStream.setByteOrder(QDataStream::LittleEndian); | - |
775 | return qt_write_dib(dibStream, img); never executed: return qt_write_dib(dibStream, img); | 0 |
776 | } | - |
777 | | - |
778 | QImage image; executed (the execution status of this line is deduced): QImage image; | - |
779 | switch (img.format()) { | - |
780 | case QImage::Format_ARGB8565_Premultiplied: | - |
781 | case QImage::Format_ARGB8555_Premultiplied: | - |
782 | case QImage::Format_ARGB6666_Premultiplied: | - |
783 | case QImage::Format_ARGB4444_Premultiplied: | - |
784 | image = img.convertToFormat(QImage::Format_ARGB32); executed (the execution status of this line is deduced): image = img.convertToFormat(QImage::Format_ARGB32); | - |
785 | break; executed: break; Execution Count:4 | 4 |
786 | case QImage::Format_RGB16: | - |
787 | case QImage::Format_RGB888: | - |
788 | case QImage::Format_RGB666: | - |
789 | case QImage::Format_RGB555: | - |
790 | case QImage::Format_RGB444: | - |
791 | image = img.convertToFormat(QImage::Format_RGB32); executed (the execution status of this line is deduced): image = img.convertToFormat(QImage::Format_RGB32); | - |
792 | break; executed: break; Execution Count:5 | 5 |
793 | default: | - |
794 | image = img; executed (the execution status of this line is deduced): image = img; | - |
795 | } executed: } Execution Count:23 | 23 |
796 | | - |
797 | QIODevice *d = device(); executed (the execution status of this line is deduced): QIODevice *d = device(); | - |
798 | QDataStream s(d); executed (the execution status of this line is deduced): QDataStream s(d); | - |
799 | BMP_FILEHDR bf; executed (the execution status of this line is deduced): BMP_FILEHDR bf; | - |
800 | int bpl_bmp; executed (the execution status of this line is deduced): int bpl_bmp; | - |
801 | int bpl = image.bytesPerLine(); executed (the execution status of this line is deduced): int bpl = image.bytesPerLine(); | - |
802 | | - |
803 | // Code partially repeated in qt_write_dib | - |
804 | if (image.depth() == 8 && image.colorCount() <= 16) { evaluated: image.depth() == 8 yes Evaluation Count:9 | yes Evaluation Count:23 |
evaluated: image.colorCount() <= 16 yes Evaluation Count:4 | yes Evaluation Count:5 |
| 4-23 |
805 | bpl_bmp = (((bpl+1)/2+3)/4)*4; executed (the execution status of this line is deduced): bpl_bmp = (((bpl+1)/2+3)/4)*4; | - |
806 | } else if (image.depth() == 32) { executed: } Execution Count:4 evaluated: image.depth() == 32 yes Evaluation Count:21 | yes Evaluation Count:7 |
| 4-21 |
807 | bpl_bmp = ((image.width()*24+31)/32)*4; executed (the execution status of this line is deduced): bpl_bmp = ((image.width()*24+31)/32)*4; | - |
808 | } else { executed: } Execution Count:21 | 21 |
809 | bpl_bmp = bpl; executed (the execution status of this line is deduced): bpl_bmp = bpl; | - |
810 | } executed: } Execution Count:7 | 7 |
811 | | - |
812 | // Intel byte order | - |
813 | s.setByteOrder(QDataStream::LittleEndian); executed (the execution status of this line is deduced): s.setByteOrder(QDataStream::LittleEndian); | - |
814 | | - |
815 | // build file header | - |
816 | memcpy(bf.bfType, "BM", 2); executed (the execution status of this line is deduced): memcpy(bf.bfType, "BM", 2); | - |
817 | | - |
818 | // write file header | - |
819 | bf.bfReserved1 = 0; executed (the execution status of this line is deduced): bf.bfReserved1 = 0; | - |
820 | bf.bfReserved2 = 0; executed (the execution status of this line is deduced): bf.bfReserved2 = 0; | - |
821 | bf.bfOffBits = BMP_FILEHDR_SIZE + BMP_WIN + image.colorCount() * 4; executed (the execution status of this line is deduced): bf.bfOffBits = BMP_FILEHDR_SIZE + BMP_WIN + image.colorCount() * 4; | - |
822 | bf.bfSize = bf.bfOffBits + bpl_bmp*image.height(); executed (the execution status of this line is deduced): bf.bfSize = bf.bfOffBits + bpl_bmp*image.height(); | - |
823 | s << bf; executed (the execution status of this line is deduced): s << bf; | - |
824 | | - |
825 | // write image | - |
826 | return qt_write_dib(s, image); executed: return qt_write_dib(s, image); Execution Count:32 | 32 |
827 | } | - |
828 | | - |
829 | bool QBmpHandler::supportsOption(ImageOption option) const | - |
830 | { | - |
831 | return option == Size executed: return option == Size || option == ImageFormat; Execution Count:2371 | 2371 |
832 | || option == ImageFormat; executed: return option == Size || option == ImageFormat; Execution Count:2371 | 2371 |
833 | } | - |
834 | | - |
835 | QVariant QBmpHandler::option(ImageOption option) const | - |
836 | { | - |
837 | if (option == Size) { evaluated: option == Size yes Evaluation Count:8 | yes Evaluation Count:4 |
| 4-8 |
838 | if (state == Error) partially evaluated: state == Error no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
839 | return QVariant(); never executed: return QVariant(); | 0 |
840 | if (state == Ready && !const_cast<QBmpHandler*>(this)->readHeader()) partially evaluated: state == Ready yes Evaluation Count:8 | no Evaluation Count:0 |
partially evaluated: !const_cast<QBmpHandler*>(this)->readHeader() no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
841 | return QVariant(); never executed: return QVariant(); | 0 |
842 | return QSize(infoHeader.biWidth, infoHeader.biHeight); executed: return QSize(infoHeader.biWidth, infoHeader.biHeight); Execution Count:8 | 8 |
843 | } else if (option == ImageFormat) { partially evaluated: option == ImageFormat yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
844 | if (state == Error) partially evaluated: state == Error no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
845 | return QVariant(); never executed: return QVariant(); | 0 |
846 | if (state == Ready && !const_cast<QBmpHandler*>(this)->readHeader()) partially evaluated: state == Ready yes Evaluation Count:4 | no Evaluation Count:0 |
partially evaluated: !const_cast<QBmpHandler*>(this)->readHeader() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
847 | return QVariant(); never executed: return QVariant(); | 0 |
848 | QImage::Format format; executed (the execution status of this line is deduced): QImage::Format format; | - |
849 | switch (infoHeader.biBitCount) { | - |
850 | case 32: | - |
851 | case 24: | - |
852 | case 16: | - |
853 | format = QImage::Format_RGB32; executed (the execution status of this line is deduced): format = QImage::Format_RGB32; | - |
854 | break; executed: break; Execution Count:2 | 2 |
855 | case 8: | - |
856 | case 4: | - |
857 | format = QImage::Format_Indexed8; executed (the execution status of this line is deduced): format = QImage::Format_Indexed8; | - |
858 | break; executed: break; Execution Count:2 | 2 |
859 | default: | - |
860 | format = QImage::Format_Mono; never executed (the execution status of this line is deduced): format = QImage::Format_Mono; | - |
861 | } | 0 |
862 | return format; executed: return format; Execution Count:4 | 4 |
863 | } | - |
864 | return QVariant(); never executed: return QVariant(); | 0 |
865 | } | - |
866 | | - |
867 | void QBmpHandler::setOption(ImageOption option, const QVariant &value) | - |
868 | { | - |
869 | Q_UNUSED(option); never executed (the execution status of this line is deduced): (void)option;; | - |
870 | Q_UNUSED(value); never executed (the execution status of this line is deduced): (void)value;; | - |
871 | } | 0 |
872 | | - |
873 | QByteArray QBmpHandler::name() const | - |
874 | { | - |
875 | return formatName(); never executed: return formatName(); | 0 |
876 | } | - |
877 | | - |
878 | QT_END_NAMESPACE | - |
879 | | - |
880 | #endif // QT_NO_IMAGEFORMAT_BMP | - |
881 | | - |
| | |