| 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 <qplatformdefs.h> | - |
| 43 | #include "private/qxbmhandler_p.h" | - |
| 44 | | - |
| 45 | #ifndef QT_NO_IMAGEFORMAT_XBM | - |
| 46 | | - |
| 47 | #include <qimage.h> | - |
| 48 | #include <qiodevice.h> | - |
| 49 | #include <qvariant.h> | - |
| 50 | | - |
| 51 | #include <stdio.h> | - |
| 52 | #include <ctype.h> | - |
| 53 | | - |
| 54 | QT_BEGIN_NAMESPACE | - |
| 55 | | - |
| 56 | /***************************************************************************** | - |
| 57 | X bitmap image read/write functions | - |
| 58 | *****************************************************************************/ | - |
| 59 | | - |
| 60 | static inline int hex2byte(register char *p) | - |
| 61 | { | - |
| 62 | return ((isdigit((uchar) *p) ? *p - '0' : toupper((uchar) *p) - 'A' + 10) << 4) | executed: return ((isdigit((uchar) *p) ? *p - '0' : toupper((uchar) *p) - 'A' + 10) << 4) | (isdigit((uchar) *(p+1)) ? *(p+1) - '0' : toupper((uchar) *(p+1)) - 'A' + 10);Execution Count:521400 | 521400 |
| 63 | (isdigit((uchar) *(p+1)) ? *(p+1) - '0' : toupper((uchar) *(p+1)) - 'A' + 10); executed: return ((isdigit((uchar) *p) ? *p - '0' : toupper((uchar) *p) - 'A' + 10) << 4) | (isdigit((uchar) *(p+1)) ? *(p+1) - '0' : toupper((uchar) *(p+1)) - 'A' + 10);Execution Count:521400 | 521400 |
| 64 | } | - |
| 65 | | - |
| 66 | static bool read_xbm_header(QIODevice *device, int& w, int& h) | - |
| 67 | { | - |
| 68 | const int buflen = 300; executed (the execution status of this line is deduced): const int buflen = 300; | - |
| 69 | const int maxlen = 4096; executed (the execution status of this line is deduced): const int maxlen = 4096; | - |
| 70 | char buf[buflen + 1]; executed (the execution status of this line is deduced): char buf[buflen + 1]; | - |
| 71 | QRegExp r1(QLatin1String("^#define[ \t]+[a-zA-Z0-9._]+[ \t]+")); executed (the execution status of this line is deduced): QRegExp r1(QLatin1String("^#define[ \t]+[a-zA-Z0-9._]+[ \t]+")); | - |
| 72 | QRegExp r2(QLatin1String("[0-9]+")); executed (the execution status of this line is deduced): QRegExp r2(QLatin1String("[0-9]+")); | - |
| 73 | | - |
| 74 | qint64 readBytes = 0; executed (the execution status of this line is deduced): qint64 readBytes = 0; | - |
| 75 | qint64 totalReadBytes = 0; executed (the execution status of this line is deduced): qint64 totalReadBytes = 0; | - |
| 76 | | - |
| 77 | buf[0] = '\0'; executed (the execution status of this line is deduced): buf[0] = '\0'; | - |
| 78 | | - |
| 79 | // skip initial comment, if any | - |
| 80 | while (buf[0] != '#') { evaluated: buf[0] != '#'| yes Evaluation Count:2161 | yes Evaluation Count:64 |
| 64-2161 |
| 81 | readBytes = device->readLine(buf, buflen); executed (the execution status of this line is deduced): readBytes = device->readLine(buf, buflen); | - |
| 82 | | - |
| 83 | // if readBytes >= buflen, it's very probably not a C file | - |
| 84 | if (readBytes <= 0 || readBytes >= buflen -1) evaluated: readBytes <= 0| yes Evaluation Count:17 | yes Evaluation Count:2144 |
evaluated: readBytes >= buflen -1| yes Evaluation Count:10 | yes Evaluation Count:2134 |
| 10-2144 |
| 85 | return false; executed: return false;Execution Count:27 | 27 |
| 86 | | - |
| 87 | // limit xbm headers to the first 4k in the file to prevent | - |
| 88 | // excessive reads on non-xbm files | - |
| 89 | totalReadBytes += readBytes; executed (the execution status of this line is deduced): totalReadBytes += readBytes; | - |
| 90 | if (totalReadBytes >= maxlen) evaluated: totalReadBytes >= maxlen| yes Evaluation Count:6 | yes Evaluation Count:2128 |
| 6-2128 |
| 91 | return false; executed: return false;Execution Count:6 | 6 |
| 92 | } executed: }Execution Count:2128 | 2128 |
| 93 | | - |
| 94 | buf[readBytes - 1] = '\0'; executed (the execution status of this line is deduced): buf[readBytes - 1] = '\0'; | - |
| 95 | QString sbuf; executed (the execution status of this line is deduced): QString sbuf; | - |
| 96 | sbuf = QString::fromLatin1(buf); executed (the execution status of this line is deduced): sbuf = QString::fromLatin1(buf); | - |
| 97 | | - |
| 98 | // "#define .._width <num>" | - |
| 99 | if (r1.indexIn(sbuf) == 0 && evaluated: r1.indexIn(sbuf) == 0| yes Evaluation Count:63 | yes Evaluation Count:1 |
| 1-63 |
| 100 | r2.indexIn(sbuf, r1.matchedLength()) == r1.matchedLength()) partially evaluated: r2.indexIn(sbuf, r1.matchedLength()) == r1.matchedLength()| yes Evaluation Count:63 | no Evaluation Count:0 |
| 0-63 |
| 101 | w = QByteArray(&buf[r1.matchedLength()]).trimmed().toInt(); executed: w = QByteArray(&buf[r1.matchedLength()]).trimmed().toInt();Execution Count:63 | 63 |
| 102 | | - |
| 103 | // "#define .._height <num>" | - |
| 104 | readBytes = device->readLine(buf, buflen); executed (the execution status of this line is deduced): readBytes = device->readLine(buf, buflen); | - |
| 105 | if (readBytes <= 0) partially evaluated: readBytes <= 0| no Evaluation Count:0 | yes Evaluation Count:64 |
| 0-64 |
| 106 | return false; never executed: return false; | 0 |
| 107 | buf[readBytes - 1] = '\0'; executed (the execution status of this line is deduced): buf[readBytes - 1] = '\0'; | - |
| 108 | | - |
| 109 | sbuf = QString::fromLatin1(buf); executed (the execution status of this line is deduced): sbuf = QString::fromLatin1(buf); | - |
| 110 | | - |
| 111 | if (r1.indexIn(sbuf) == 0 && evaluated: r1.indexIn(sbuf) == 0| yes Evaluation Count:63 | yes Evaluation Count:1 |
| 1-63 |
| 112 | r2.indexIn(sbuf, r1.matchedLength()) == r1.matchedLength()) partially evaluated: r2.indexIn(sbuf, r1.matchedLength()) == r1.matchedLength()| yes Evaluation Count:63 | no Evaluation Count:0 |
| 0-63 |
| 113 | h = QByteArray(&buf[r1.matchedLength()]).trimmed().toInt(); executed: h = QByteArray(&buf[r1.matchedLength()]).trimmed().toInt();Execution Count:63 | 63 |
| 114 | | - |
| 115 | // format error | - |
| 116 | if (w <= 0 || w > 32767 || h <= 0 || h > 32767) evaluated: w <= 0| yes Evaluation Count:1 | yes Evaluation Count:63 |
partially evaluated: w > 32767| no Evaluation Count:0 | yes Evaluation Count:63 |
partially evaluated: h <= 0| no Evaluation Count:0 | yes Evaluation Count:63 |
partially evaluated: h > 32767| no Evaluation Count:0 | yes Evaluation Count:63 |
| 0-63 |
| 117 | return false; executed: return false;Execution Count:1 | 1 |
| 118 | | - |
| 119 | return true; executed: return true;Execution Count:63 | 63 |
| 120 | } | - |
| 121 | | - |
| 122 | static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) | - |
| 123 | { | - |
| 124 | const int buflen = 300; executed (the execution status of this line is deduced): const int buflen = 300; | - |
| 125 | char buf[buflen + 1]; executed (the execution status of this line is deduced): char buf[buflen + 1]; | - |
| 126 | | - |
| 127 | qint64 readBytes = 0; executed (the execution status of this line is deduced): qint64 readBytes = 0; | - |
| 128 | | - |
| 129 | // scan for database | - |
| 130 | for (;;) { executed (the execution status of this line is deduced): for (;;) { | - |
| 131 | if ((readBytes = device->readLine(buf, buflen)) <= 0) { partially evaluated: (readBytes = device->readLine(buf, buflen)) <= 0| no Evaluation Count:0 | yes Evaluation Count:124 |
| 0-124 |
| 132 | // end of file | - |
| 133 | return false; never executed: return false; | 0 |
| 134 | } | - |
| 135 | | - |
| 136 | buf[readBytes] = '\0'; executed (the execution status of this line is deduced): buf[readBytes] = '\0'; | - |
| 137 | if (QByteArray::fromRawData(buf, readBytes).contains("0x")) evaluated: QByteArray::fromRawData(buf, readBytes).contains("0x")| yes Evaluation Count:62 | yes Evaluation Count:62 |
| 62 |
| 138 | break; executed: break;Execution Count:62 | 62 |
| 139 | } executed: }Execution Count:62 | 62 |
| 140 | | - |
| 141 | if (outImage->size() != QSize(w, h) || outImage->format() != QImage::Format_MonoLSB) { partially evaluated: outImage->size() != QSize(w, h)| yes Evaluation Count:62 | no Evaluation Count:0 |
never evaluated: outImage->format() != QImage::Format_MonoLSB | 0-62 |
| 142 | *outImage = QImage(w, h, QImage::Format_MonoLSB); executed (the execution status of this line is deduced): *outImage = QImage(w, h, QImage::Format_MonoLSB); | - |
| 143 | if (outImage->isNull()) partially evaluated: outImage->isNull()| no Evaluation Count:0 | yes Evaluation Count:62 |
| 0-62 |
| 144 | return false; never executed: return false; | 0 |
| 145 | } executed: }Execution Count:62 | 62 |
| 146 | | - |
| 147 | outImage->setColorCount(2); executed (the execution status of this line is deduced): outImage->setColorCount(2); | - |
| 148 | outImage->setColor(0, qRgb(255,255,255)); // white executed (the execution status of this line is deduced): outImage->setColor(0, qRgb(255,255,255)); | - |
| 149 | outImage->setColor(1, qRgb(0,0,0)); // black executed (the execution status of this line is deduced): outImage->setColor(1, qRgb(0,0,0)); | - |
| 150 | | - |
| 151 | int x = 0, y = 0; executed (the execution status of this line is deduced): int x = 0, y = 0; | - |
| 152 | uchar *b = outImage->scanLine(0); executed (the execution status of this line is deduced): uchar *b = outImage->scanLine(0); | - |
| 153 | char *p = buf + QByteArray::fromRawData(buf, readBytes).indexOf("0x"); executed (the execution status of this line is deduced): char *p = buf + QByteArray::fromRawData(buf, readBytes).indexOf("0x"); | - |
| 154 | w = (w+7)/8; // byte width executed (the execution status of this line is deduced): w = (w+7)/8; | - |
| 155 | | - |
| 156 | while (y < h) { // for all encoded bytes... evaluated: y < h| yes Evaluation Count:556115 | yes Evaluation Count:60 |
| 60-556115 |
| 157 | if (p) { // p = "0x.." evaluated: p| yes Evaluation Count:521400 | yes Evaluation Count:34715 |
| 34715-521400 |
| 158 | *b++ = hex2byte(p+2); executed (the execution status of this line is deduced): *b++ = hex2byte(p+2); | - |
| 159 | p += 2; executed (the execution status of this line is deduced): p += 2; | - |
| 160 | if (++x == w && ++y < h) { evaluated: ++x == w| yes Evaluation Count:15489 | yes Evaluation Count:505911 |
evaluated: ++y < h| yes Evaluation Count:15429 | yes Evaluation Count:60 |
| 60-505911 |
| 161 | b = outImage->scanLine(y); executed (the execution status of this line is deduced): b = outImage->scanLine(y); | - |
| 162 | x = 0; executed (the execution status of this line is deduced): x = 0; | - |
| 163 | } executed: }Execution Count:15429 | 15429 |
| 164 | p = strstr(p, "0x"); executed (the execution status of this line is deduced): p = strstr(p, "0x"); | - |
| 165 | } else { // read another line executed: }Execution Count:521400 | 521400 |
| 166 | if ((readBytes = device->readLine(buf,buflen)) <= 0) // EOF ==> truncated image evaluated: (readBytes = device->readLine(buf,buflen)) <= 0| yes Evaluation Count:2 | yes Evaluation Count:34713 |
| 2-34713 |
| 167 | break; executed: break;Execution Count:2 | 2 |
| 168 | p = buf + QByteArray::fromRawData(buf, readBytes).indexOf("0x"); executed (the execution status of this line is deduced): p = buf + QByteArray::fromRawData(buf, readBytes).indexOf("0x"); | - |
| 169 | } executed: }Execution Count:34713 | 34713 |
| 170 | } | - |
| 171 | | - |
| 172 | return true; executed: return true;Execution Count:62 | 62 |
| 173 | } | - |
| 174 | | - |
| 175 | static bool read_xbm_image(QIODevice *device, QImage *outImage) | - |
| 176 | { | - |
| 177 | int w = 0, h = 0; executed (the execution status of this line is deduced): int w = 0, h = 0; | - |
| 178 | if (!read_xbm_header(device, w, h)) evaluated: !read_xbm_header(device, w, h)| yes Evaluation Count:32 | yes Evaluation Count:18 |
| 18-32 |
| 179 | return false; executed: return false;Execution Count:32 | 32 |
| 180 | return read_xbm_body(device, w, h, outImage); executed: return read_xbm_body(device, w, h, outImage);Execution Count:18 | 18 |
| 181 | } | - |
| 182 | | - |
| 183 | static bool write_xbm_image(const QImage &sourceImage, QIODevice *device, const QString &fileName) | - |
| 184 | { | - |
| 185 | QImage image = sourceImage; executed (the execution status of this line is deduced): QImage image = sourceImage; | - |
| 186 | int w = image.width(); executed (the execution status of this line is deduced): int w = image.width(); | - |
| 187 | int h = image.height(); executed (the execution status of this line is deduced): int h = image.height(); | - |
| 188 | int i; executed (the execution status of this line is deduced): int i; | - |
| 189 | QString s = fileName; // get file base name executed (the execution status of this line is deduced): QString s = fileName; | - |
| 190 | int msize = s.length() + 100; executed (the execution status of this line is deduced): int msize = s.length() + 100; | - |
| 191 | char *buf = new char[msize]; executed (the execution status of this line is deduced): char *buf = new char[msize]; | - |
| 192 | | - |
| 193 | qsnprintf(buf, msize, "#define %s_width %d\n", s.toUtf8().data(), w); executed (the execution status of this line is deduced): qsnprintf(buf, msize, "#define %s_width %d\n", s.toUtf8().data(), w); | - |
| 194 | device->write(buf, qstrlen(buf)); executed (the execution status of this line is deduced): device->write(buf, qstrlen(buf)); | - |
| 195 | qsnprintf(buf, msize, "#define %s_height %d\n", s.toUtf8().data(), h); executed (the execution status of this line is deduced): qsnprintf(buf, msize, "#define %s_height %d\n", s.toUtf8().data(), h); | - |
| 196 | device->write(buf, qstrlen(buf)); executed (the execution status of this line is deduced): device->write(buf, qstrlen(buf)); | - |
| 197 | qsnprintf(buf, msize, "static char %s_bits[] = {\n ", s.toUtf8().data()); executed (the execution status of this line is deduced): qsnprintf(buf, msize, "static char %s_bits[] = {\n ", s.toUtf8().data()); | - |
| 198 | device->write(buf, qstrlen(buf)); executed (the execution status of this line is deduced): device->write(buf, qstrlen(buf)); | - |
| 199 | | - |
| 200 | if (image.format() != QImage::Format_MonoLSB) evaluated: image.format() != QImage::Format_MonoLSB| yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
| 201 | image = image.convertToFormat(QImage::Format_MonoLSB); executed: image = image.convertToFormat(QImage::Format_MonoLSB);Execution Count:1 | 1 |
| 202 | | - |
| 203 | bool invert = qGray(image.color(0)) < qGray(image.color(1)); executed (the execution status of this line is deduced): bool invert = qGray(image.color(0)) < qGray(image.color(1)); | - |
| 204 | char hexrep[16]; executed (the execution status of this line is deduced): char hexrep[16]; | - |
| 205 | for (i=0; i<10; i++) evaluated: i<10| yes Evaluation Count:50 | yes Evaluation Count:5 |
| 5-50 |
| 206 | hexrep[i] = '0' + i; executed: hexrep[i] = '0' + i;Execution Count:50 | 50 |
| 207 | for (i=10; i<16; i++) evaluated: i<16| yes Evaluation Count:30 | yes Evaluation Count:5 |
| 5-30 |
| 208 | hexrep[i] = 'a' -10 + i; executed: hexrep[i] = 'a' -10 + i;Execution Count:30 | 30 |
| 209 | if (invert) { partially evaluated: invert| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 210 | char t; never executed (the execution status of this line is deduced): char t; | - |
| 211 | for (i=0; i<8; i++) { | 0 |
| 212 | t = hexrep[15-i]; never executed (the execution status of this line is deduced): t = hexrep[15-i]; | - |
| 213 | hexrep[15-i] = hexrep[i]; never executed (the execution status of this line is deduced): hexrep[15-i] = hexrep[i]; | - |
| 214 | hexrep[i] = t; never executed (the execution status of this line is deduced): hexrep[i] = t; | - |
| 215 | } | 0 |
| 216 | } | 0 |
| 217 | int bcnt = 0; executed (the execution status of this line is deduced): int bcnt = 0; | - |
| 218 | register char *p = buf; executed (the execution status of this line is deduced): register char *p = buf; | - |
| 219 | int bpl = (w+7)/8; executed (the execution status of this line is deduced): int bpl = (w+7)/8; | - |
| 220 | for (int y = 0; y < h; ++y) { evaluated: y < h| yes Evaluation Count:1156 | yes Evaluation Count:5 |
| 5-1156 |
| 221 | uchar *b = image.scanLine(y); executed (the execution status of this line is deduced): uchar *b = image.scanLine(y); | - |
| 222 | for (i = 0; i < bpl; ++i) { evaluated: i < bpl| yes Evaluation Count:37640 | yes Evaluation Count:1156 |
| 1156-37640 |
| 223 | *p++ = '0'; *p++ = 'x'; executed (the execution status of this line is deduced): *p++ = '0'; *p++ = 'x'; | - |
| 224 | *p++ = hexrep[*b >> 4]; executed (the execution status of this line is deduced): *p++ = hexrep[*b >> 4]; | - |
| 225 | *p++ = hexrep[*b++ & 0xf]; executed (the execution status of this line is deduced): *p++ = hexrep[*b++ & 0xf]; | - |
| 226 | | - |
| 227 | if (i < bpl - 1 || y < h - 1) { evaluated: i < bpl - 1| yes Evaluation Count:36484 | yes Evaluation Count:1156 |
evaluated: y < h - 1| yes Evaluation Count:1151 | yes Evaluation Count:5 |
| 5-36484 |
| 228 | *p++ = ','; executed (the execution status of this line is deduced): *p++ = ','; | - |
| 229 | if (++bcnt > 14) { evaluated: ++bcnt > 14| yes Evaluation Count:2506 | yes Evaluation Count:35129 |
| 2506-35129 |
| 230 | *p++ = '\n'; executed (the execution status of this line is deduced): *p++ = '\n'; | - |
| 231 | *p++ = ' '; executed (the execution status of this line is deduced): *p++ = ' '; | - |
| 232 | *p = '\0'; executed (the execution status of this line is deduced): *p = '\0'; | - |
| 233 | if ((int)qstrlen(buf) != device->write(buf, qstrlen(buf))) { partially evaluated: (int)qstrlen(buf) != device->write(buf, qstrlen(buf))| no Evaluation Count:0 | yes Evaluation Count:2506 |
| 0-2506 |
| 234 | delete [] buf; never executed (the execution status of this line is deduced): delete [] buf; | - |
| 235 | return false; never executed: return false; | 0 |
| 236 | } | - |
| 237 | p = buf; executed (the execution status of this line is deduced): p = buf; | - |
| 238 | bcnt = 0; executed (the execution status of this line is deduced): bcnt = 0; | - |
| 239 | } executed: }Execution Count:2506 | 2506 |
| 240 | } executed: }Execution Count:37635 | 37635 |
| 241 | } executed: }Execution Count:37640 | 37640 |
| 242 | } executed: }Execution Count:1156 | 1156 |
| 243 | #if defined(_MSC_VER) && _MSC_VER >= 1400 | - |
| 244 | strcpy_s(p, sizeof(" };\n"), " };\n"); | - |
| 245 | #else | - |
| 246 | strcpy(p, " };\n"); executed (the execution status of this line is deduced): strcpy(p, " };\n"); | - |
| 247 | #endif | - |
| 248 | if ((int)qstrlen(buf) != device->write(buf, qstrlen(buf))) { partially evaluated: (int)qstrlen(buf) != device->write(buf, qstrlen(buf))| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 249 | delete [] buf; never executed (the execution status of this line is deduced): delete [] buf; | - |
| 250 | return false; never executed: return false; | 0 |
| 251 | } | - |
| 252 | | - |
| 253 | delete [] buf; executed (the execution status of this line is deduced): delete [] buf; | - |
| 254 | return true; executed: return true;Execution Count:5 | 5 |
| 255 | } | - |
| 256 | | - |
| 257 | QXbmHandler::QXbmHandler() | - |
| 258 | : state(Ready) | - |
| 259 | { | - |
| 260 | } executed: }Execution Count:57 | 57 |
| 261 | | - |
| 262 | bool QXbmHandler::readHeader() | - |
| 263 | { | - |
| 264 | state = Error; executed (the execution status of this line is deduced): state = Error; | - |
| 265 | if (!read_xbm_header(device(), width, height)) evaluated: !read_xbm_header(device(), width, height)| yes Evaluation Count:2 | yes Evaluation Count:45 |
| 2-45 |
| 266 | return false; executed: return false;Execution Count:2 | 2 |
| 267 | state = ReadHeader; executed (the execution status of this line is deduced): state = ReadHeader; | - |
| 268 | return true; executed: return true;Execution Count:45 | 45 |
| 269 | } | - |
| 270 | | - |
| 271 | bool QXbmHandler::canRead() const | - |
| 272 | { | - |
| 273 | if (state == Ready && !canRead(device())) evaluated: state == Ready| yes Evaluation Count:19 | yes Evaluation Count:2 |
evaluated: !canRead(device())| yes Evaluation Count:5 | yes Evaluation Count:14 |
| 2-19 |
| 274 | return false; executed: return false;Execution Count:5 | 5 |
| 275 | | - |
| 276 | if (state != Error) { partially evaluated: state != Error| yes Evaluation Count:16 | no Evaluation Count:0 |
| 0-16 |
| 277 | setFormat("xbm"); executed (the execution status of this line is deduced): setFormat("xbm"); | - |
| 278 | return true; executed: return true;Execution Count:16 | 16 |
| 279 | } | - |
| 280 | | - |
| 281 | return false; never executed: return false; | 0 |
| 282 | } | - |
| 283 | | - |
| 284 | bool QXbmHandler::canRead(QIODevice *device) | - |
| 285 | { | - |
| 286 | QImage image; executed (the execution status of this line is deduced): QImage image; | - |
| 287 | | - |
| 288 | // it's impossible to tell whether we can load an XBM or not when | - |
| 289 | // it's from a sequential device, as the only way to do it is to | - |
| 290 | // attempt to parse the whole image. | - |
| 291 | if (device->isSequential()) evaluated: device->isSequential()| yes Evaluation Count:2 | yes Evaluation Count:50 |
| 2-50 |
| 292 | return false; executed: return false;Execution Count:2 | 2 |
| 293 | | - |
| 294 | qint64 oldPos = device->pos(); executed (the execution status of this line is deduced): qint64 oldPos = device->pos(); | - |
| 295 | bool success = read_xbm_image(device, &image); executed (the execution status of this line is deduced): bool success = read_xbm_image(device, &image); | - |
| 296 | device->seek(oldPos); executed (the execution status of this line is deduced): device->seek(oldPos); | - |
| 297 | | - |
| 298 | return success; executed: return success;Execution Count:50 | 50 |
| 299 | } | - |
| 300 | | - |
| 301 | bool QXbmHandler::read(QImage *image) | - |
| 302 | { | - |
| 303 | if (state == Error) partially evaluated: state == Error| no Evaluation Count:0 | yes Evaluation Count:46 |
| 0-46 |
| 304 | return false; never executed: return false; | 0 |
| 305 | | - |
| 306 | if (state == Ready && !readHeader()) { evaluated: state == Ready| yes Evaluation Count:45 | yes Evaluation Count:1 |
evaluated: !readHeader()| yes Evaluation Count:2 | yes Evaluation Count:43 |
| 1-45 |
| 307 | state = Error; executed (the execution status of this line is deduced): state = Error; | - |
| 308 | return false; executed: return false;Execution Count:2 | 2 |
| 309 | } | - |
| 310 | | - |
| 311 | if (!read_xbm_body(device(), width, height, image)) { partially evaluated: !read_xbm_body(device(), width, height, image)| no Evaluation Count:0 | yes Evaluation Count:44 |
| 0-44 |
| 312 | state = Error; never executed (the execution status of this line is deduced): state = Error; | - |
| 313 | return false; never executed: return false; | 0 |
| 314 | } | - |
| 315 | | - |
| 316 | state = Ready; executed (the execution status of this line is deduced): state = Ready; | - |
| 317 | return true; executed: return true;Execution Count:44 | 44 |
| 318 | } | - |
| 319 | | - |
| 320 | bool QXbmHandler::write(const QImage &image) | - |
| 321 | { | - |
| 322 | return write_xbm_image(image, device(), fileName); executed: return write_xbm_image(image, device(), fileName);Execution Count:5 | 5 |
| 323 | } | - |
| 324 | | - |
| 325 | bool QXbmHandler::supportsOption(ImageOption option) const | - |
| 326 | { | - |
| 327 | return option == Name executed: return option == Name || option == Size || option == ImageFormat;Execution Count:339 | 339 |
| 328 | || option == Size executed: return option == Name || option == Size || option == ImageFormat;Execution Count:339 | 339 |
| 329 | || option == ImageFormat; executed: return option == Name || option == Size || option == ImageFormat;Execution Count:339 | 339 |
| 330 | } | - |
| 331 | | - |
| 332 | QVariant QXbmHandler::option(ImageOption option) const | - |
| 333 | { | - |
| 334 | if (option == Name) { partially evaluated: option == Name| no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
| 335 | return fileName; never executed: return fileName; | 0 |
| 336 | } else if (option == Size) { evaluated: option == Size| yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
| 337 | if (state == Error) partially evaluated: state == Error| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 338 | return QVariant(); never executed: return QVariant(); | 0 |
| 339 | if (state == Ready && !const_cast<QXbmHandler*>(this)->readHeader()) partially evaluated: state == Ready| yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: !const_cast<QXbmHandler*>(this)->readHeader()| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 340 | return QVariant(); never executed: return QVariant(); | 0 |
| 341 | return QSize(width, height); executed: return QSize(width, height);Execution Count:2 | 2 |
| 342 | } else if (option == ImageFormat) { partially evaluated: option == ImageFormat| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 343 | return QImage::Format_MonoLSB; executed: return QImage::Format_MonoLSB;Execution Count:1 | 1 |
| 344 | } | - |
| 345 | return QVariant(); never executed: return QVariant(); | 0 |
| 346 | } | - |
| 347 | | - |
| 348 | void QXbmHandler::setOption(ImageOption option, const QVariant &value) | - |
| 349 | { | - |
| 350 | if (option == Name) partially evaluated: option == Name| no Evaluation Count:0 | yes Evaluation Count:53 |
| 0-53 |
| 351 | fileName = value.toString(); never executed: fileName = value.toString(); | 0 |
| 352 | } executed: }Execution Count:53 | 53 |
| 353 | | - |
| 354 | QByteArray QXbmHandler::name() const | - |
| 355 | { | - |
| 356 | return "xbm"; never executed: return "xbm"; | 0 |
| 357 | } | - |
| 358 | | - |
| 359 | QT_END_NAMESPACE | - |
| 360 | | - |
| 361 | #endif // QT_NO_IMAGEFORMAT_XBM | - |
| 362 | | - |
| | |