| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | static void swapPixel01(QImage *image) | - |
| 8 | { | - |
| 9 | int i; | - |
| 10 | if (image->depth() == 1 && image->colorCount() == 2) { | - |
| 11 | register uint *p = (uint *)image->bits(); | - |
| 12 | int nbytes = image->byteCount(); | - |
| 13 | for (i=0; i<nbytes/4; i++) { | - |
| 14 | *p = ~*p; | - |
| 15 | p++; | - |
| 16 | } | - |
| 17 | uchar *p2 = (uchar *)p; | - |
| 18 | for (i=0; i<(nbytes&3); i++) { | - |
| 19 | *p2 = ~*p2; | - |
| 20 | p2++; | - |
| 21 | } | - |
| 22 | QRgb t = image->color(0); | - |
| 23 | image->setColor(0, image->color(1)); | - |
| 24 | image->setColor(1, t); | - |
| 25 | } | - |
| 26 | } | - |
| 27 | const int BMP_FILEHDR_SIZE = 14; | - |
| 28 | | - |
| 29 | static 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; | - |
| 34 | } | - |
| 35 | | - |
| 36 | static 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; | - |
| 41 | } | - |
| 42 | | - |
| 43 | | - |
| 44 | const int BMP_OLD = 12; | - |
| 45 | const int BMP_WIN = 40; | - |
| 46 | const int BMP_OS2 = 64; | - |
| 47 | const int BMP_WIN4 = 108; | - |
| 48 | const int BMP_WIN5 = 124; | - |
| 49 | | - |
| 50 | const int BMP_RGB = 0; | - |
| 51 | const int BMP_RLE8 = 1; | - |
| 52 | const int BMP_RLE4 = 2; | - |
| 53 | const int BMP_BITFIELDS = 3; | - |
| 54 | | - |
| 55 | | - |
| 56 | static 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) { | - |
| 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 | } | - |
| 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 | } | - |
| 75 | return s; | - |
| 76 | } | - |
| 77 | | - |
| 78 | static 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; | - |
| 89 | } | - |
| 90 | | - |
| 91 | static int calc_shift(intuint mask) | - |
| 92 | { | - |
| 93 | int result = 0; | - |
| 94 | 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 |
| 95 | result++; | - |
| 96 | mask >>= 1; | - |
| 97 | } executed: }Execution Count:1192 | 1192 |
| 98 | return result; executed: return result;Execution Count:129 | 129 |
| 99 | } | - |
| 100 | | - |
| 101 | static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf) | - |
| 102 | { | - |
| 103 | | - |
| 104 | s >> bf; | - |
| 105 | if (s.status() != QDataStream::Ok) | - |
| 106 | return false; | - |
| 107 | | - |
| 108 | | - |
| 109 | if (qstrncmp(bf.bfType,"BM",2) != 0) | - |
| 110 | return false; | - |
| 111 | | - |
| 112 | return true; | - |
| 113 | } | - |
| 114 | | - |
| 115 | static bool read_dib_infoheader(QDataStream &s, BMP_INFOHDR &bi) | - |
| 116 | { | - |
| 117 | s >> bi; | - |
| 118 | if (s.status() != QDataStream::Ok) | - |
| 119 | return false; | - |
| 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) || | - |
| 124 | bi.biPlanes != 1 || comp > BMP_BITFIELDS) | - |
| 125 | return false; | - |
| 126 | if (!(comp == BMP_RGB || (nbits == 4 && comp == BMP_RLE4) || | - |
| 127 | (nbits == 8 && comp == BMP_RLE8) || ((nbits == 16 || nbits == 32) && comp == BMP_BITFIELDS))) | - |
| 128 | return false; | - |
| 129 | | - |
| 130 | return true; | - |
| 131 | } | - |
| 132 | | - |
| 133 | static 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()| 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 | intuint red_mask = 0; | - |
| 141 | intuint green_mask = 0; | - |
| 142 | intuint 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| 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)| 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()| 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| yes Evaluation Count:174 | yes Evaluation Count:139 |
| 139-174 |
| 180 | ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits; evaluated: bi.biClrUsed| yes Evaluation Count:163 | yes Evaluation Count:11 |
| 11-163 |
| 181 | if (ncols > 256) partially evaluated: ncols > 256| 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()| 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| 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 |
| 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)| 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)| 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)| 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| 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)| 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)| 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)| 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)| 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)| 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)| 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| 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)| 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)| 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)| 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)| no Evaluation Count:0 | yes Evaluation Count:35 |
partially evaluated: reserved != 0| 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| 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| no Evaluation Count:0 | yes Evaluation Count:174 |
| 0-174 |
| 243 | for (int i=0; i<ncols; i++) { evaluated: i<ncols| 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| 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()| 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| 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 |
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| 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 |
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| yes Evaluation Count:20 | no Evaluation Count:0 |
partially evaluated: nbits == 16| 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| yes Evaluation Count:300 | no Evaluation Count:0 |
partially evaluated: startpos + offset > d->pos()| 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 | } | 0 |
| 282 | | - |
| 283 | int bpl = image.bytesPerLine(); | - |
| 284 | uchar *data = image.bits(); | - |
| 285 | | - |
| 286 | if (nbits == 1) { evaluated: nbits == 1| yes Evaluation Count:2 | yes Evaluation Count:298 |
| 2-298 |
| 287 | while (--h >= 0) { evaluated: --h >= 0| 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| no Evaluation Count:0 | yes Evaluation Count:140 |
| 0-140 |
| 289 | break; | 0 |
| 290 | } executed: }Execution Count:140 | 140 |
| 291 | 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 |
| 292 | swapPixel01(&image); never executed: swapPixel01(&image); | 0 |
| 293 | } executed: }Execution Count:2 | 2 |
| 294 | | - |
| 295 | else if (nbits == 4) { evaluated: nbits == 4| 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| 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| yes Evaluation Count:185485 | yes Evaluation Count:33 |
| 33-185485 |
| 304 | if (!d->getChar((char *)&b)) partially evaluated: !d->getChar((char *)&b)| no Evaluation Count:0 | yes Evaluation Count:185485 |
| 0-185485 |
| 305 | break; | 0 |
| 306 | if (b == 0) { evaluated: b == 0| yes Evaluation Count:25398 | yes Evaluation Count:160087 |
| 25398-160087 |
| 307 | 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 |
| 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; | 0 |
| 327 | if ((uint)y >= (uint)h) never evaluated: (uint)y >= (uint)h | 0 |
| 328 | y = h-1; | 0 |
| 329 | | - |
| 330 | p = data + (h-y-1)*bpl + x; | - |
| 331 | break; | 0 |
| 332 | default: | - |
| 333 | | - |
| 334 | if (p + b > endp) partially evaluated: p + b > endp| 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--| 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| 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| 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| 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--| 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| 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| 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| 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| 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| 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| 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| yes Evaluation Count:73 | yes Evaluation Count:139 |
| 73-139 |
| 387 | if (comp == BMP_RLE8) { evaluated: comp == BMP_RLE8| 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| yes Evaluation Count:455860 | yes Evaluation Count:20 |
| 20-455860 |
| 393 | if (!d->getChar((char *)&b)) partially evaluated: !d->getChar((char *)&b)| no Evaluation Count:0 | yes Evaluation Count:455860 |
| 0-455860 |
| 394 | break; | 0 |
| 395 | if (b == 0) { evaluated: b == 0| yes Evaluation Count:5600 | yes Evaluation Count:450260 |
| 5600-450260 |
| 396 | 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 |
| 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; | 0 |
| 408 | if ((uint)y >= (uint)h) never evaluated: (uint)y >= (uint)h | 0 |
| 409 | 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; | 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 | } | 0 |
| 432 | } else { | - |
| 433 | | - |
| 434 | if (p + b > endp) partially evaluated: p + b > endp| 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| yes Evaluation Count:53 | no Evaluation Count:0 |
executed: }Execution Count:20 | 0-53 |
| 445 | while (--h >= 0) { evaluated: --h >= 0| 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| no Evaluation Count:0 | yes Evaluation Count:10470 |
| 0-10470 |
| 447 | 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| 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 |
| 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| 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| no Evaluation Count:0 | yes Evaluation Count:19736 |
| 0-19736 |
| 464 | break; | 0 |
| 465 | b = buf24; | - |
| 466 | while (p < end) { evaluated: p < end| 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| 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| 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| 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 | | - |
| 495 | bool 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()) | - |
| 503 | return false; | - |
| 504 | | - |
| 505 | if (image.depth() == 8 && image.colorCount() <= 16) { | - |
| 506 | bpl_bmp = (((bpl+1)/2+3)/4)*4; | - |
| 507 | nbits = 4; | - |
| 508 | } else if (image.depth() == 32) { | - |
| 509 | bpl_bmp = ((image.width()*24+31)/32)*4; | - |
| 510 | nbits = 24; | - |
| 511 | } else { | - |
| 512 | bpl_bmp = bpl; | - |
| 513 | nbits = image.depth(); | - |
| 514 | } | - |
| 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() | - |
| 525 | : 2834; | - |
| 526 | bi.biYPelsPerMeter = image.dotsPerMeterY() ? image.dotsPerMeterY() : 2834; | - |
| 527 | bi.biClrUsed = image.colorCount(); | - |
| 528 | bi.biClrImportant = image.colorCount(); | - |
| 529 | s << bi; | - |
| 530 | if (s.status() != QDataStream::Ok) | - |
| 531 | return false; | - |
| 532 | | - |
| 533 | if (image.depth() != 32) { | - |
| 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++) { | - |
| 538 | *rgb++ = qBlue (c[i]); | - |
| 539 | *rgb++ = qGreen(c[i]); | - |
| 540 | *rgb++ = qRed (c[i]); | - |
| 541 | *rgb++ = 0; | - |
| 542 | } | - |
| 543 | if (d->write((char *)color_table, 4*image.colorCount()) == -1) { | - |
| 544 | delete [] color_table; | - |
| 545 | return false; | - |
| 546 | } | - |
| 547 | delete [] color_table; | - |
| 548 | } | - |
| 549 | | - |
| 550 | if (image.format() == QImage::Format_MonoLSB) | - |
| 551 | image = image.convertToFormat(QImage::Format_Mono); | - |
| 552 | | - |
| 553 | int y; | - |
| 554 | | - |
| 555 | if (nbits == 1 || nbits == 8) { | - |
| 556 | for (y=image.height()-1; y>=0; y--) { | - |
| 557 | if (d->write((char*)image.constScanLine(y), bpl) == -1) | - |
| 558 | return false; | - |
| 559 | } | - |
| 560 | return true; | - |
| 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--) { | - |
| 569 | if (nbits == 4) { | - |
| 570 | p = image.constScanLine(y); | - |
| 571 | b = buf; | - |
| 572 | end = b + image.width()/2; | - |
| 573 | while (b < end) { | - |
| 574 | *b++ = (*p << 4) | (*(p+1) & 0x0f); | - |
| 575 | p += 2; | - |
| 576 | } | - |
| 577 | if (image.width() & 1) | - |
| 578 | *b = *p << 4; | - |
| 579 | } else { | - |
| 580 | const QRgb *p = (const QRgb *)image.constScanLine(y); | - |
| 581 | const QRgb *end = p + image.width(); | - |
| 582 | b = buf; | - |
| 583 | while (p < end) { | - |
| 584 | *b++ = qBlue(*p); | - |
| 585 | *b++ = qGreen(*p); | - |
| 586 | *b++ = qRed(*p); | - |
| 587 | p++; | - |
| 588 | } | - |
| 589 | } | - |
| 590 | if (bpl_bmp != d->write((char*)buf, bpl_bmp)) { | - |
| 591 | delete[] buf; | - |
| 592 | return false; | - |
| 593 | } | - |
| 594 | } | - |
| 595 | delete[] buf; | - |
| 596 | return true; | - |
| 597 | } | - |
| 598 | | - |
| 599 | | - |
| 600 | bool qt_read_dib(QDataStream &s, QImage &image) | - |
| 601 | { | - |
| 602 | BMP_INFOHDR bi; | - |
| 603 | if (!read_dib_infoheader(s, bi)) | - |
| 604 | return false; | - |
| 605 | return read_dib_body(s, bi, -1, -BMP_FILEHDR_SIZE, image); | - |
| 606 | } | - |
| 607 | | - |
| 608 | QBmpHandler::QBmpHandler(InternalFormat fmt) : | - |
| 609 | m_format(fmt), state(Ready) | - |
| 610 | { | - |
| 611 | } | - |
| 612 | | - |
| 613 | QByteArray QBmpHandler::formatName() const | - |
| 614 | { | - |
| 615 | return m_format == BmpFormat ? "bmp" : "dib"; | - |
| 616 | } | - |
| 617 | | - |
| 618 | bool 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)) | - |
| 631 | return false; | - |
| 632 | | - |
| 633 | | - |
| 634 | if (!read_dib_infoheader(s, infoHeader)) | - |
| 635 | return false; | - |
| 636 | | - |
| 637 | state = ReadHeader; | - |
| 638 | return true; | - |
| 639 | } | - |
| 640 | | - |
| 641 | bool QBmpHandler::canRead() const | - |
| 642 | { | - |
| 643 | if (m_format == BmpFormat && state == Ready && !canRead(device())) | - |
| 644 | return false; | - |
| 645 | | - |
| 646 | if (state != Error) { | - |
| 647 | setFormat(formatName()); | - |
| 648 | return true; | - |
| 649 | } | - |
| 650 | | - |
| 651 | return false; | - |
| 652 | } | - |
| 653 | | - |
| 654 | bool QBmpHandler::canRead(QIODevice *device) | - |
| 655 | { | - |
| 656 | if (!device) { | - |
| 657 | QMessageLogger("image/qbmphandler.cpp", 727, __PRETTY_FUNCTION__).warning("QBmpHandler::canRead() called with 0 pointer"); | - |
| 658 | return false; | - |
| 659 | } | - |
| 660 | | - |
| 661 | char head[2]; | - |
| 662 | if (device->peek(head, sizeof(head)) != sizeof(head)) | - |
| 663 | return false; | - |
| 664 | | - |
| 665 | return (qstrncmp(head, "BM", 2) == 0); | - |
| 666 | } | - |
| 667 | | - |
| 668 | bool QBmpHandler::read(QImage *image) | - |
| 669 | { | - |
| 670 | if (state == Error) | - |
| 671 | return false; | - |
| 672 | | - |
| 673 | if (!image) { | - |
| 674 | QMessageLogger("image/qbmphandler.cpp", 744, __PRETTY_FUNCTION__).warning("QBmpHandler::read: cannot read into null pointer"); | - |
| 675 | return false; | - |
| 676 | } | - |
| 677 | | - |
| 678 | if (state == Ready && !readHeader()) { | - |
| 679 | state = Error; | - |
| 680 | return false; | - |
| 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 ? | - |
| 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) | - |
| 694 | return false; | - |
| 695 | | - |
| 696 | state = Ready; | - |
| 697 | return true; | - |
| 698 | } | - |
| 699 | | - |
| 700 | bool QBmpHandler::write(const QImage &img) | - |
| 701 | { | - |
| 702 | if (m_format == DibFormat) { | - |
| 703 | QDataStream dibStream(device()); | - |
| 704 | dibStream.setByteOrder(QDataStream::LittleEndian); | - |
| 705 | return qt_write_dib(dibStream, img); | - |
| 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; | - |
| 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; | - |
| 723 | default: | - |
| 724 | image = img; | - |
| 725 | } | - |
| 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) { | - |
| 735 | bpl_bmp = (((bpl+1)/2+3)/4)*4; | - |
| 736 | } else if (image.depth() == 32) { | - |
| 737 | bpl_bmp = ((image.width()*24+31)/32)*4; | - |
| 738 | } else { | - |
| 739 | bpl_bmp = bpl; | - |
| 740 | } | - |
| 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); | - |
| 757 | } | - |
| 758 | | - |
| 759 | bool QBmpHandler::supportsOption(ImageOption option) const | - |
| 760 | { | - |
| 761 | return option == Size | - |
| 762 | || option == ImageFormat; | - |
| 763 | } | - |
| 764 | | - |
| 765 | QVariant QBmpHandler::option(ImageOption option) const | - |
| 766 | { | - |
| 767 | if (option == Size) { | - |
| 768 | if (state == Error) | - |
| 769 | return QVariant(); | - |
| 770 | if (state == Ready && !const_cast<QBmpHandler*>(this)->readHeader()) | - |
| 771 | return QVariant(); | - |
| 772 | return QSize(infoHeader.biWidth, infoHeader.biHeight); | - |
| 773 | } else if (option == ImageFormat) { | - |
| 774 | if (state == Error) | - |
| 775 | return QVariant(); | - |
| 776 | if (state == Ready && !const_cast<QBmpHandler*>(this)->readHeader()) | - |
| 777 | return QVariant(); | - |
| 778 | QImage::Format format; | - |
| 779 | switch (infoHeader.biBitCount) { | - |
| 780 | case 32: | - |
| 781 | case 24: | - |
| 782 | case 16: | - |
| 783 | format = QImage::Format_RGB32; | - |
| 784 | break; | - |
| 785 | case 8: | - |
| 786 | case 4: | - |
| 787 | format = QImage::Format_Indexed8; | - |
| 788 | break; | - |
| 789 | default: | - |
| 790 | format = QImage::Format_Mono; | - |
| 791 | } | - |
| 792 | return format; | - |
| 793 | } | - |
| 794 | return QVariant(); | - |
| 795 | } | - |
| 796 | | - |
| 797 | void QBmpHandler::setOption(ImageOption option, const QVariant &value) | - |
| 798 | { | - |
| 799 | (void)option;; | - |
| 800 | (void)value;; | - |
| 801 | } | - |
| 802 | | - |
| 803 | QByteArray QBmpHandler::name() const | - |
| 804 | { | - |
| 805 | return formatName(); | - |
| 806 | } | - |
| 807 | | - |
| 808 | | - |
| 809 | | - |
| | |