Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2012 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 "qimage.h" | - |
43 | #include "qdatastream.h" | - |
44 | #include "qbuffer.h" | - |
45 | #include "qmap.h" | - |
46 | #include "qmatrix.h" | - |
47 | #include "qtransform.h" | - |
48 | #include "qimagereader.h" | - |
49 | #include "qimagewriter.h" | - |
50 | #include "qstringlist.h" | - |
51 | #include "qvariant.h" | - |
52 | #include "qimagepixmapcleanuphooks_p.h" | - |
53 | #include <qpa/qplatformintegration.h> | - |
54 | #include <private/qguiapplication_p.h> | - |
55 | #include <ctype.h> | - |
56 | #include <stdlib.h> | - |
57 | #include <limits.h> | - |
58 | #include <math.h> | - |
59 | #include <qpa/qplatformpixmap.h> | - |
60 | #include <private/qdrawhelper_p.h> | - |
61 | #include <private/qmemrotate_p.h> | - |
62 | #include <private/qimagescale_p.h> | - |
63 | #include <private/qsimd_p.h> | - |
64 | | - |
65 | #include <qhash.h> | - |
66 | | - |
67 | #include <private/qpaintengine_raster_p.h> | - |
68 | | - |
69 | #include <private/qimage_p.h> | - |
70 | #include <private/qfont_p.h> | - |
71 | | - |
72 | QT_BEGIN_NAMESPACE | - |
73 | | - |
74 | static inline bool isLocked(QImageData *data) | - |
75 | { | - |
76 | return data != 0 && data->is_locked; executed: return data != 0 && data->is_locked; Execution Count:43615 | 43615 |
77 | } | - |
78 | | - |
79 | #if defined(Q_CC_DEC) && defined(__alpha) && (__DECCXX_VER-0 >= 50190001) | - |
80 | #pragma message disable narrowptr | - |
81 | #endif | - |
82 | | - |
83 | | - |
84 | #define QIMAGE_SANITYCHECK_MEMORY(image) \ | - |
85 | if ((image).isNull()) { \ | - |
86 | qWarning("QImage: out of memory, returning null image"); \ | - |
87 | return QImage(); \ | - |
88 | } | - |
89 | | - |
90 | | - |
91 | static QImage rotated90(const QImage &src); | - |
92 | static QImage rotated180(const QImage &src); | - |
93 | static QImage rotated270(const QImage &src); | - |
94 | | - |
95 | QBasicAtomicInt qimage_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1); | - |
96 | | - |
97 | QImageData::QImageData() | - |
98 | : ref(0), width(0), height(0), depth(0), nbytes(0), devicePixelRatio(1.0), data(0), | - |
99 | format(QImage::Format_ARGB32), bytes_per_line(0), | - |
100 | ser_no(qimage_serial_number.fetchAndAddRelaxed(1)), | - |
101 | detach_no(0), | - |
102 | ldpmx(qt_defaultDpiX() * 100 / qreal(2.54)), | - |
103 | ldpmy(qt_defaultDpiY() * 100 / qreal(2.54)), | - |
104 | dpmx(qt_defaultDpiX() * 100 / qreal(2.54)), | - |
105 | dpmy(qt_defaultDpiY() * 100 / qreal(2.54)), | - |
106 | offset(0, 0), own_data(true), ro_data(false), has_alpha_clut(false), | - |
107 | is_cached(false), is_locked(false), cleanupFunction(0), cleanupInfo(0), | - |
108 | paintEngine(0) | - |
109 | { | - |
110 | } executed: } Execution Count:148464 | 148464 |
111 | | - |
112 | /*! \fn QImageData * QImageData::create(const QSize &size, QImage::Format format, int numColors) | - |
113 | | - |
114 | \internal | - |
115 | | - |
116 | Creates a new image data. | - |
117 | Returns 0 if invalid parameters are give or anything else failed. | - |
118 | */ | - |
119 | QImageData * QImageData::create(const QSize &size, QImage::Format format, int numColors) | - |
120 | { | - |
121 | if (!size.isValid() || numColors < 0 || format == QImage::Format_Invalid) partially evaluated: !size.isValid() no Evaluation Count:0 | yes Evaluation Count:34171 |
partially evaluated: numColors < 0 no Evaluation Count:0 | yes Evaluation Count:34171 |
partially evaluated: format == QImage::Format_Invalid no Evaluation Count:0 | yes Evaluation Count:34171 |
| 0-34171 |
122 | return 0; // invalid parameter(s) never executed: return 0; | 0 |
123 | | - |
124 | uint width = size.width(); executed (the execution status of this line is deduced): uint width = size.width(); | - |
125 | uint height = size.height(); executed (the execution status of this line is deduced): uint height = size.height(); | - |
126 | uint depth = qt_depthForFormat(format); executed (the execution status of this line is deduced): uint depth = qt_depthForFormat(format); | - |
127 | | - |
128 | switch (format) { | - |
129 | case QImage::Format_Mono: | - |
130 | case QImage::Format_MonoLSB: | - |
131 | numColors = 2; executed (the execution status of this line is deduced): numColors = 2; | - |
132 | break; executed: break; Execution Count:5562 | 5562 |
133 | case QImage::Format_Indexed8: | - |
134 | numColors = qBound(0, numColors, 256); executed (the execution status of this line is deduced): numColors = qBound(0, numColors, 256); | - |
135 | break; executed: break; Execution Count:2984 | 2984 |
136 | default: | - |
137 | numColors = 0; executed (the execution status of this line is deduced): numColors = 0; | - |
138 | break; executed: break; Execution Count:25625 | 25625 |
139 | } | - |
140 | | - |
141 | const int bytes_per_line = ((width * depth + 31) >> 5) << 2; // bytes per scanline (must be multiple of 4) executed (the execution status of this line is deduced): const int bytes_per_line = ((width * depth + 31) >> 5) << 2; | - |
142 | | - |
143 | // sanity check for potential overflows | - |
144 | if (INT_MAX/depth < width partially evaluated: 2147483647/depth < width no Evaluation Count:0 | yes Evaluation Count:34171 |
| 0-34171 |
145 | || bytes_per_line <= 0 evaluated: bytes_per_line <= 0 yes Evaluation Count:240 | yes Evaluation Count:33931 |
| 240-33931 |
146 | || height <= 0 partially evaluated: height <= 0 no Evaluation Count:0 | yes Evaluation Count:33931 |
| 0-33931 |
147 | || INT_MAX/uint(bytes_per_line) < height evaluated: 2147483647/uint(bytes_per_line) < height yes Evaluation Count:1 | yes Evaluation Count:33930 |
| 1-33930 |
148 | || INT_MAX/sizeof(uchar *) < uint(height)) partially evaluated: 2147483647/sizeof(uchar *) < uint(height) no Evaluation Count:0 | yes Evaluation Count:33930 |
| 0-33930 |
149 | return 0; executed: return 0; Execution Count:241 | 241 |
150 | | - |
151 | QScopedPointer<QImageData> d(new QImageData); executed (the execution status of this line is deduced): QScopedPointer<QImageData> d(new QImageData); | - |
152 | d->colortable.resize(numColors); executed (the execution status of this line is deduced): d->colortable.resize(numColors); | - |
153 | if (depth == 1) { evaluated: depth == 1 yes Evaluation Count:5449 | yes Evaluation Count:28481 |
| 5449-28481 |
154 | d->colortable[0] = QColor(Qt::black).rgba(); executed (the execution status of this line is deduced): d->colortable[0] = QColor(Qt::black).rgba(); | - |
155 | d->colortable[1] = QColor(Qt::white).rgba(); executed (the execution status of this line is deduced): d->colortable[1] = QColor(Qt::white).rgba(); | - |
156 | } else { executed: } Execution Count:5449 | 5449 |
157 | for (int i = 0; i < numColors; ++i) partially evaluated: i < numColors no Evaluation Count:0 | yes Evaluation Count:28481 |
| 0-28481 |
158 | d->colortable[i] = 0; never executed: d->colortable[i] = 0; | 0 |
159 | } executed: } Execution Count:28481 | 28481 |
160 | | - |
161 | d->width = width; executed (the execution status of this line is deduced): d->width = width; | - |
162 | d->height = height; executed (the execution status of this line is deduced): d->height = height; | - |
163 | d->depth = depth; executed (the execution status of this line is deduced): d->depth = depth; | - |
164 | d->format = format; executed (the execution status of this line is deduced): d->format = format; | - |
165 | d->has_alpha_clut = false; executed (the execution status of this line is deduced): d->has_alpha_clut = false; | - |
166 | d->is_cached = false; executed (the execution status of this line is deduced): d->is_cached = false; | - |
167 | | - |
168 | d->bytes_per_line = bytes_per_line; executed (the execution status of this line is deduced): d->bytes_per_line = bytes_per_line; | - |
169 | | - |
170 | d->nbytes = d->bytes_per_line*height; executed (the execution status of this line is deduced): d->nbytes = d->bytes_per_line*height; | - |
171 | d->data = (uchar *)malloc(d->nbytes); executed (the execution status of this line is deduced): d->data = (uchar *)malloc(d->nbytes); | - |
172 | | - |
173 | if (!d->data) { partially evaluated: !d->data no Evaluation Count:0 | yes Evaluation Count:33930 |
| 0-33930 |
174 | return 0; never executed: return 0; | 0 |
175 | } | - |
176 | | - |
177 | d->ref.ref(); executed (the execution status of this line is deduced): d->ref.ref(); | - |
178 | return d.take(); executed: return d.take(); Execution Count:33930 | 33930 |
179 | | - |
180 | } | - |
181 | | - |
182 | QImageData::~QImageData() | - |
183 | { | - |
184 | if (cleanupFunction) evaluated: cleanupFunction yes Evaluation Count:2 | yes Evaluation Count:148361 |
| 2-148361 |
185 | cleanupFunction(cleanupInfo); executed: cleanupFunction(cleanupInfo); Execution Count:2 | 2 |
186 | if (is_cached) partially evaluated: is_cached no Evaluation Count:0 | yes Evaluation Count:148363 |
| 0-148363 |
187 | QImagePixmapCleanupHooks::executeImageHooks((((qint64) ser_no) << 32) | ((qint64) detach_no)); never executed: QImagePixmapCleanupHooks::executeImageHooks((((qint64) ser_no) << 32) | ((qint64) detach_no)); | 0 |
188 | delete paintEngine; executed (the execution status of this line is deduced): delete paintEngine; | - |
189 | if (data && own_data) partially evaluated: data yes Evaluation Count:148363 | no Evaluation Count:0 |
evaluated: own_data yes Evaluation Count:33862 | yes Evaluation Count:114501 |
| 0-148363 |
190 | free(data); executed: free(data); Execution Count:33862 | 33862 |
191 | data = 0; executed (the execution status of this line is deduced): data = 0; | - |
192 | } executed: } Execution Count:148363 | 148363 |
193 | | - |
194 | | - |
195 | bool QImageData::checkForAlphaPixels() const | - |
196 | { | - |
197 | bool has_alpha_pixels = false; executed (the execution status of this line is deduced): bool has_alpha_pixels = false; | - |
198 | | - |
199 | switch (format) { | - |
200 | | - |
201 | case QImage::Format_Mono: | - |
202 | case QImage::Format_MonoLSB: | - |
203 | case QImage::Format_Indexed8: | - |
204 | has_alpha_pixels = has_alpha_clut; executed (the execution status of this line is deduced): has_alpha_pixels = has_alpha_clut; | - |
205 | break; executed: break; Execution Count:2234 | 2234 |
206 | | - |
207 | case QImage::Format_ARGB32: | - |
208 | case QImage::Format_ARGB32_Premultiplied: { | - |
209 | uchar *bits = data; executed (the execution status of this line is deduced): uchar *bits = data; | - |
210 | for (int y=0; y<height && !has_alpha_pixels; ++y) { evaluated: y<height yes Evaluation Count:83972 | yes Evaluation Count:1207 |
evaluated: !has_alpha_pixels yes Evaluation Count:83542 | yes Evaluation Count:430 |
| 430-83972 |
211 | for (int x=0; x<width; ++x) evaluated: x<width yes Evaluation Count:7632550 | yes Evaluation Count:83542 |
| 83542-7632550 |
212 | has_alpha_pixels |= (((uint *)bits)[x] & 0xff000000) != 0xff000000; executed: has_alpha_pixels |= (((uint *)bits)[x] & 0xff000000) != 0xff000000; Execution Count:7632550 | 7632550 |
213 | bits += bytes_per_line; executed (the execution status of this line is deduced): bits += bytes_per_line; | - |
214 | } executed: } Execution Count:83542 | 83542 |
215 | } break; executed: break; Execution Count:1637 | 1637 |
216 | | - |
217 | case QImage::Format_ARGB8555_Premultiplied: | - |
218 | case QImage::Format_ARGB8565_Premultiplied: { | - |
219 | uchar *bits = data; never executed (the execution status of this line is deduced): uchar *bits = data; | - |
220 | uchar *end_bits = data + bytes_per_line; never executed (the execution status of this line is deduced): uchar *end_bits = data + bytes_per_line; | - |
221 | | - |
222 | for (int y=0; y<height && !has_alpha_pixels; ++y) { never evaluated: y<height never evaluated: !has_alpha_pixels | 0 |
223 | while (bits < end_bits) { never evaluated: bits < end_bits | 0 |
224 | has_alpha_pixels |= bits[0] != 0; never executed (the execution status of this line is deduced): has_alpha_pixels |= bits[0] != 0; | - |
225 | bits += 3; never executed (the execution status of this line is deduced): bits += 3; | - |
226 | } | 0 |
227 | bits = end_bits; never executed (the execution status of this line is deduced): bits = end_bits; | - |
228 | end_bits += bytes_per_line; never executed (the execution status of this line is deduced): end_bits += bytes_per_line; | - |
229 | } | 0 |
230 | } break; | 0 |
231 | | - |
232 | case QImage::Format_ARGB6666_Premultiplied: { | - |
233 | uchar *bits = data; never executed (the execution status of this line is deduced): uchar *bits = data; | - |
234 | uchar *end_bits = data + bytes_per_line; never executed (the execution status of this line is deduced): uchar *end_bits = data + bytes_per_line; | - |
235 | | - |
236 | for (int y=0; y<height && !has_alpha_pixels; ++y) { never evaluated: y<height never evaluated: !has_alpha_pixels | 0 |
237 | while (bits < end_bits) { never evaluated: bits < end_bits | 0 |
238 | has_alpha_pixels |= (bits[0] & 0xfc) != 0; never executed (the execution status of this line is deduced): has_alpha_pixels |= (bits[0] & 0xfc) != 0; | - |
239 | bits += 3; never executed (the execution status of this line is deduced): bits += 3; | - |
240 | } | 0 |
241 | bits = end_bits; never executed (the execution status of this line is deduced): bits = end_bits; | - |
242 | end_bits += bytes_per_line; never executed (the execution status of this line is deduced): end_bits += bytes_per_line; | - |
243 | } | 0 |
244 | } break; | 0 |
245 | | - |
246 | case QImage::Format_ARGB4444_Premultiplied: { | - |
247 | uchar *bits = data; never executed (the execution status of this line is deduced): uchar *bits = data; | - |
248 | uchar *end_bits = data + bytes_per_line; never executed (the execution status of this line is deduced): uchar *end_bits = data + bytes_per_line; | - |
249 | | - |
250 | for (int y=0; y<height && !has_alpha_pixels; ++y) { never evaluated: y<height never evaluated: !has_alpha_pixels | 0 |
251 | while (bits < end_bits) { never evaluated: bits < end_bits | 0 |
252 | has_alpha_pixels |= (bits[0] & 0xf0) != 0; never executed (the execution status of this line is deduced): has_alpha_pixels |= (bits[0] & 0xf0) != 0; | - |
253 | bits += 2; never executed (the execution status of this line is deduced): bits += 2; | - |
254 | } | 0 |
255 | bits = end_bits; never executed (the execution status of this line is deduced): bits = end_bits; | - |
256 | end_bits += bytes_per_line; never executed (the execution status of this line is deduced): end_bits += bytes_per_line; | - |
257 | } | 0 |
258 | } break; | 0 |
259 | | - |
260 | default: | - |
261 | break; | 0 |
262 | } | - |
263 | | - |
264 | return has_alpha_pixels; executed: return has_alpha_pixels; Execution Count:3871 | 3871 |
265 | } | - |
266 | | - |
267 | /*! | - |
268 | \class QImage | - |
269 | | - |
270 | \inmodule QtGui | - |
271 | \ingroup painting | - |
272 | \ingroup shared | - |
273 | | - |
274 | \reentrant | - |
275 | | - |
276 | \brief The QImage class provides a hardware-independent image | - |
277 | representation that allows direct access to the pixel data, and | - |
278 | can be used as a paint device. | - |
279 | | - |
280 | Qt provides four classes for handling image data: QImage, QPixmap, | - |
281 | QBitmap and QPicture. QImage is designed and optimized for I/O, | - |
282 | and for direct pixel access and manipulation, while QPixmap is | - |
283 | designed and optimized for showing images on screen. QBitmap is | - |
284 | only a convenience class that inherits QPixmap, ensuring a | - |
285 | depth of 1. Finally, the QPicture class is a paint device that | - |
286 | records and replays QPainter commands. | - |
287 | | - |
288 | Because QImage is a QPaintDevice subclass, QPainter can be used to | - |
289 | draw directly onto images. When using QPainter on a QImage, the | - |
290 | painting can be performed in another thread than the current GUI | - |
291 | thread. | - |
292 | | - |
293 | The QImage class supports several image formats described by the | - |
294 | \l Format enum. These include monochrome, 8-bit, 32-bit and | - |
295 | alpha-blended images which are available in all versions of Qt | - |
296 | 4.x. | - |
297 | | - |
298 | QImage provides a collection of functions that can be used to | - |
299 | obtain a variety of information about the image. There are also | - |
300 | several functions that enables transformation of the image. | - |
301 | | - |
302 | QImage objects can be passed around by value since the QImage | - |
303 | class uses \l{Implicit Data Sharing}{implicit data | - |
304 | sharing}. QImage objects can also be streamed and compared. | - |
305 | | - |
306 | \note If you would like to load QImage objects in a static build of Qt, | - |
307 | refer to the \l{How To Create Qt Plugins#Static Plugins}{Plugin HowTo}. | - |
308 | | - |
309 | \warning Painting on a QImage with the format | - |
310 | QImage::Format_Indexed8 is not supported. | - |
311 | | - |
312 | \tableofcontents | - |
313 | | - |
314 | \section1 Reading and Writing Image Files | - |
315 | | - |
316 | QImage provides several ways of loading an image file: The file | - |
317 | can be loaded when constructing the QImage object, or by using the | - |
318 | load() or loadFromData() functions later on. QImage also provides | - |
319 | the static fromData() function, constructing a QImage from the | - |
320 | given data. When loading an image, the file name can either refer | - |
321 | to an actual file on disk or to one of the application's embedded | - |
322 | resources. See \l{The Qt Resource System} overview for details | - |
323 | on how to embed images and other resource files in the | - |
324 | application's executable. | - |
325 | | - |
326 | Simply call the save() function to save a QImage object. | - |
327 | | - |
328 | The complete list of supported file formats are available through | - |
329 | the QImageReader::supportedImageFormats() and | - |
330 | QImageWriter::supportedImageFormats() functions. New file formats | - |
331 | can be added as plugins. By default, Qt supports the following | - |
332 | formats: | - |
333 | | - |
334 | \table | - |
335 | \header \li Format \li Description \li Qt's support | - |
336 | \row \li BMP \li Windows Bitmap \li Read/write | - |
337 | \row \li GIF \li Graphic Interchange Format (optional) \li Read | - |
338 | \row \li JPG \li Joint Photographic Experts Group \li Read/write | - |
339 | \row \li JPEG \li Joint Photographic Experts Group \li Read/write | - |
340 | \row \li PNG \li Portable Network Graphics \li Read/write | - |
341 | \row \li PBM \li Portable Bitmap \li Read | - |
342 | \row \li PGM \li Portable Graymap \li Read | - |
343 | \row \li PPM \li Portable Pixmap \li Read/write | - |
344 | \row \li XBM \li X11 Bitmap \li Read/write | - |
345 | \row \li XPM \li X11 Pixmap \li Read/write | - |
346 | \endtable | - |
347 | | - |
348 | \section1 Image Information | - |
349 | | - |
350 | QImage provides a collection of functions that can be used to | - |
351 | obtain a variety of information about the image: | - |
352 | | - |
353 | \table | - |
354 | \header | - |
355 | \li \li Available Functions | - |
356 | | - |
357 | \row | - |
358 | \li Geometry | - |
359 | \li | - |
360 | | - |
361 | The size(), width(), height(), dotsPerMeterX(), and | - |
362 | dotsPerMeterY() functions provide information about the image size | - |
363 | and aspect ratio. | - |
364 | | - |
365 | The rect() function returns the image's enclosing rectangle. The | - |
366 | valid() function tells if a given pair of coordinates is within | - |
367 | this rectangle. The offset() function returns the number of pixels | - |
368 | by which the image is intended to be offset by when positioned | - |
369 | relative to other images, which also can be manipulated using the | - |
370 | setOffset() function. | - |
371 | | - |
372 | \row | - |
373 | \li Colors | - |
374 | \li | - |
375 | | - |
376 | The color of a pixel can be retrieved by passing its coordinates | - |
377 | to the pixel() function. The pixel() function returns the color | - |
378 | as a QRgb value indepedent of the image's format. | - |
379 | | - |
380 | In case of monochrome and 8-bit images, the colorCount() and | - |
381 | colorTable() functions provide information about the color | - |
382 | components used to store the image data: The colorTable() function | - |
383 | returns the image's entire color table. To obtain a single entry, | - |
384 | use the pixelIndex() function to retrieve the pixel index for a | - |
385 | given pair of coordinates, then use the color() function to | - |
386 | retrieve the color. Note that if you create an 8-bit image | - |
387 | manually, you have to set a valid color table on the image as | - |
388 | well. | - |
389 | | - |
390 | The hasAlphaChannel() function tells if the image's format | - |
391 | respects the alpha channel, or not. The allGray() and | - |
392 | isGrayscale() functions tell whether an image's colors are all | - |
393 | shades of gray. | - |
394 | | - |
395 | See also the \l {QImage#Pixel Manipulation}{Pixel Manipulation} | - |
396 | and \l {QImage#Image Transformations}{Image Transformations} | - |
397 | sections. | - |
398 | | - |
399 | \row | - |
400 | \li Text | - |
401 | \li | - |
402 | | - |
403 | The text() function returns the image text associated with the | - |
404 | given text key. An image's text keys can be retrieved using the | - |
405 | textKeys() function. Use the setText() function to alter an | - |
406 | image's text. | - |
407 | | - |
408 | \row | - |
409 | \li Low-level information | - |
410 | \li | - |
411 | | - |
412 | The depth() function returns the depth of the image. The supported | - |
413 | depths are 1 (monochrome), 8, 16, 24 and 32 bits. The | - |
414 | bitPlaneCount() function tells how many of those bits that are | - |
415 | used. For more information see the | - |
416 | \l {QImage#Image Formats}{Image Formats} section. | - |
417 | | - |
418 | The format(), bytesPerLine(), and byteCount() functions provide | - |
419 | low-level information about the data stored in the image. | - |
420 | | - |
421 | The cacheKey() function returns a number that uniquely | - |
422 | identifies the contents of this QImage object. | - |
423 | \endtable | - |
424 | | - |
425 | \section1 Pixel Manipulation | - |
426 | | - |
427 | The functions used to manipulate an image's pixels depend on the | - |
428 | image format. The reason is that monochrome and 8-bit images are | - |
429 | index-based and use a color lookup table, while 32-bit images | - |
430 | store ARGB values directly. For more information on image formats, | - |
431 | see the \l {Image Formats} section. | - |
432 | | - |
433 | In case of a 32-bit image, the setPixel() function can be used to | - |
434 | alter the color of the pixel at the given coordinates to any other | - |
435 | color specified as an ARGB quadruplet. To make a suitable QRgb | - |
436 | value, use the qRgb() (adding a default alpha component to the | - |
437 | given RGB values, i.e. creating an opaque color) or qRgba() | - |
438 | function. For example: | - |
439 | | - |
440 | \table | - |
441 | \header | - |
442 | \li {2,1}32-bit | - |
443 | \row | - |
444 | \li \inlineimage qimage-32bit_scaled.png | - |
445 | \li | - |
446 | \snippet code/src_gui_image_qimage.cpp 0 | - |
447 | \endtable | - |
448 | | - |
449 | In case of a 8-bit and monchrome images, the pixel value is only | - |
450 | an index from the image's color table. So the setPixel() function | - |
451 | can only be used to alter the color of the pixel at the given | - |
452 | coordinates to a predefined color from the image's color table, | - |
453 | i.e. it can only change the pixel's index value. To alter or add a | - |
454 | color to an image's color table, use the setColor() function. | - |
455 | | - |
456 | An entry in the color table is an ARGB quadruplet encoded as an | - |
457 | QRgb value. Use the qRgb() and qRgba() functions to make a | - |
458 | suitable QRgb value for use with the setColor() function. For | - |
459 | example: | - |
460 | | - |
461 | \table | - |
462 | \header | - |
463 | \li {2,1} 8-bit | - |
464 | \row | - |
465 | \li \inlineimage qimage-8bit_scaled.png | - |
466 | \li | - |
467 | \snippet code/src_gui_image_qimage.cpp 1 | - |
468 | \endtable | - |
469 | | - |
470 | QImage also provide the scanLine() function which returns a | - |
471 | pointer to the pixel data at the scanline with the given index, | - |
472 | and the bits() function which returns a pointer to the first pixel | - |
473 | data (this is equivalent to \c scanLine(0)). | - |
474 | | - |
475 | \section1 Image Formats | - |
476 | | - |
477 | Each pixel stored in a QImage is represented by an integer. The | - |
478 | size of the integer varies depending on the format. QImage | - |
479 | supports several image formats described by the \l Format | - |
480 | enum. | - |
481 | | - |
482 | Monochrome images are stored using 1-bit indexes into a color table | - |
483 | with at most two colors. There are two different types of | - |
484 | monochrome images: big endian (MSB first) or little endian (LSB | - |
485 | first) bit order. | - |
486 | | - |
487 | 8-bit images are stored using 8-bit indexes into a color table, | - |
488 | i.e. they have a single byte per pixel. The color table is a | - |
489 | QVector<QRgb>, and the QRgb typedef is equivalent to an unsigned | - |
490 | int containing an ARGB quadruplet on the format 0xAARRGGBB. | - |
491 | | - |
492 | 32-bit images have no color table; instead, each pixel contains an | - |
493 | QRgb value. There are three different types of 32-bit images | - |
494 | storing RGB (i.e. 0xffRRGGBB), ARGB and premultiplied ARGB | - |
495 | values respectively. In the premultiplied format the red, green, | - |
496 | and blue channels are multiplied by the alpha component divided by | - |
497 | 255. | - |
498 | | - |
499 | An image's format can be retrieved using the format() | - |
500 | function. Use the convertToFormat() functions to convert an image | - |
501 | into another format. The allGray() and isGrayscale() functions | - |
502 | tell whether a color image can safely be converted to a grayscale | - |
503 | image. | - |
504 | | - |
505 | \section1 Image Transformations | - |
506 | | - |
507 | QImage supports a number of functions for creating a new image | - |
508 | that is a transformed version of the original: The | - |
509 | createAlphaMask() function builds and returns a 1-bpp mask from | - |
510 | the alpha buffer in this image, and the createHeuristicMask() | - |
511 | function creates and returns a 1-bpp heuristic mask for this | - |
512 | image. The latter function works by selecting a color from one of | - |
513 | the corners, then chipping away pixels of that color starting at | - |
514 | all the edges. | - |
515 | | - |
516 | The mirrored() function returns a mirror of the image in the | - |
517 | desired direction, the scaled() returns a copy of the image scaled | - |
518 | to a rectangle of the desired measures, and the rgbSwapped() function | - |
519 | constructs a BGR image from a RGB image. | - |
520 | | - |
521 | The scaledToWidth() and scaledToHeight() functions return scaled | - |
522 | copies of the image. | - |
523 | | - |
524 | The transformed() function returns a copy of the image that is | - |
525 | transformed with the given transformation matrix and | - |
526 | transformation mode: Internally, the transformation matrix is | - |
527 | adjusted to compensate for unwanted translation, | - |
528 | i.e. transformed() returns the smallest image containing all | - |
529 | transformed points of the original image. The static trueMatrix() | - |
530 | function returns the actual matrix used for transforming the | - |
531 | image. | - |
532 | | - |
533 | There are also functions for changing attributes of an image | - |
534 | in-place: | - |
535 | | - |
536 | \table | - |
537 | \header \li Function \li Description | - |
538 | \row | - |
539 | \li setDotsPerMeterX() | - |
540 | \li Defines the aspect ratio by setting the number of pixels that fit | - |
541 | horizontally in a physical meter. | - |
542 | \row | - |
543 | \li setDotsPerMeterY() | - |
544 | \li Defines the aspect ratio by setting the number of pixels that fit | - |
545 | vertically in a physical meter. | - |
546 | \row | - |
547 | \li fill() | - |
548 | \li Fills the entire image with the given pixel value. | - |
549 | \row | - |
550 | \li invertPixels() | - |
551 | \li Inverts all pixel values in the image using the given InvertMode value. | - |
552 | \row | - |
553 | \li setColorTable() | - |
554 | \li Sets the color table used to translate color indexes. Only | - |
555 | monochrome and 8-bit formats. | - |
556 | \row | - |
557 | \li setColorCount() | - |
558 | \li Resizes the color table. Only monochrome and 8-bit formats. | - |
559 | | - |
560 | \endtable | - |
561 | | - |
562 | \section1 Legal Information | - |
563 | | - |
564 | For smooth scaling, the transformed() functions use code based on | - |
565 | smooth scaling algorithm by Daniel M. Duley. | - |
566 | | - |
567 | \legalese | - |
568 | Copyright (C) 2004, 2005 Daniel M. Duley | - |
569 | | - |
570 | Redistribution and use in source and binary forms, with or without | - |
571 | modification, are permitted provided that the following conditions | - |
572 | are met: | - |
573 | | - |
574 | 1. Redistributions of source code must retain the above copyright | - |
575 | notice, this list of conditions and the following disclaimer. | - |
576 | 2. Redistributions in binary form must reproduce the above copyright | - |
577 | notice, this list of conditions and the following disclaimer in the | - |
578 | documentation and/or other materials provided with the distribution. | - |
579 | | - |
580 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | - |
581 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | - |
582 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | - |
583 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | - |
584 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | - |
585 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | - |
586 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | - |
587 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | - |
588 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | - |
589 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | - |
590 | \endlegalese | - |
591 | | - |
592 | \sa QImageReader, QImageWriter, QPixmap, QSvgRenderer, {Image Composition Example}, | - |
593 | {Image Viewer Example}, {Scribble Example}, {Pixelator Example} | - |
594 | */ | - |
595 | | - |
596 | /*! | - |
597 | \typedef QImageCleanupFunction | - |
598 | \relates QImage | - |
599 | \since 5.0 | - |
600 | | - |
601 | A function with the following signature that can be used to | - |
602 | implement basic image memory management: | - |
603 | | - |
604 | \code | - |
605 | void myImageCleanupHandler(void *info); | - |
606 | \endcode | - |
607 | */ | - |
608 | | - |
609 | /*! | - |
610 | \enum QImage::InvertMode | - |
611 | | - |
612 | This enum type is used to describe how pixel values should be | - |
613 | inverted in the invertPixels() function. | - |
614 | | - |
615 | \value InvertRgb Invert only the RGB values and leave the alpha | - |
616 | channel unchanged. | - |
617 | | - |
618 | \value InvertRgba Invert all channels, including the alpha channel. | - |
619 | | - |
620 | \sa invertPixels() | - |
621 | */ | - |
622 | | - |
623 | /*! | - |
624 | \enum QImage::Format | - |
625 | | - |
626 | The following image formats are available in Qt. Values greater | - |
627 | than QImage::Format_RGB16 were added in Qt 4.4. See the notes | - |
628 | after the table. | - |
629 | | - |
630 | \value Format_Invalid The image is invalid. | - |
631 | \value Format_Mono The image is stored using 1-bit per pixel. Bytes are | - |
632 | packed with the most significant bit (MSB) first. | - |
633 | \value Format_MonoLSB The image is stored using 1-bit per pixel. Bytes are | - |
634 | packed with the less significant bit (LSB) first. | - |
635 | | - |
636 | \value Format_Indexed8 The image is stored using 8-bit indexes | - |
637 | into a colormap. | - |
638 | | - |
639 | \value Format_RGB32 The image is stored using a 32-bit RGB format (0xffRRGGBB). | - |
640 | | - |
641 | \value Format_ARGB32 The image is stored using a 32-bit ARGB | - |
642 | format (0xAARRGGBB). | - |
643 | | - |
644 | \value Format_ARGB32_Premultiplied The image is stored using a premultiplied 32-bit | - |
645 | ARGB format (0xAARRGGBB), i.e. the red, | - |
646 | green, and blue channels are multiplied | - |
647 | by the alpha component divided by 255. (If RR, GG, or BB | - |
648 | has a higher value than the alpha channel, the results are | - |
649 | undefined.) Certain operations (such as image composition | - |
650 | using alpha blending) are faster using premultiplied ARGB32 | - |
651 | than with plain ARGB32. | - |
652 | | - |
653 | \value Format_RGB16 The image is stored using a 16-bit RGB format (5-6-5). | - |
654 | | - |
655 | \value Format_ARGB8565_Premultiplied The image is stored using a | - |
656 | premultiplied 24-bit ARGB format (8-5-6-5). | - |
657 | \value Format_RGB666 The image is stored using a 24-bit RGB format (6-6-6). | - |
658 | The unused most significant bits is always zero. | - |
659 | \value Format_ARGB6666_Premultiplied The image is stored using a | - |
660 | premultiplied 24-bit ARGB format (6-6-6-6). | - |
661 | \value Format_RGB555 The image is stored using a 16-bit RGB format (5-5-5). | - |
662 | The unused most significant bit is always zero. | - |
663 | \value Format_ARGB8555_Premultiplied The image is stored using a | - |
664 | premultiplied 24-bit ARGB format (8-5-5-5). | - |
665 | \value Format_RGB888 The image is stored using a 24-bit RGB format (8-8-8). | - |
666 | \value Format_RGB444 The image is stored using a 16-bit RGB format (4-4-4). | - |
667 | The unused bits are always zero. | - |
668 | \value Format_ARGB4444_Premultiplied The image is stored using a | - |
669 | premultiplied 16-bit ARGB format (4-4-4-4). | - |
670 | | - |
671 | \note Drawing into a QImage with QImage::Format_Indexed8 is not | - |
672 | supported. | - |
673 | | - |
674 | \note Do not render into ARGB32 images using QPainter. Using | - |
675 | QImage::Format_ARGB32_Premultiplied is significantly faster. | - |
676 | | - |
677 | \sa format(), convertToFormat() | - |
678 | */ | - |
679 | | - |
680 | /***************************************************************************** | - |
681 | QImage member functions | - |
682 | *****************************************************************************/ | - |
683 | | - |
684 | // table to flip bits | - |
685 | static const uchar bitflip[256] = { | - |
686 | /* | - |
687 | open OUT, "| fmt"; | - |
688 | for $i (0..255) { | - |
689 | print OUT (($i >> 7) & 0x01) | (($i >> 5) & 0x02) | | - |
690 | (($i >> 3) & 0x04) | (($i >> 1) & 0x08) | | - |
691 | (($i << 7) & 0x80) | (($i << 5) & 0x40) | | - |
692 | (($i << 3) & 0x20) | (($i << 1) & 0x10), ", "; | - |
693 | } | - |
694 | close OUT; | - |
695 | */ | - |
696 | 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, | - |
697 | 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, | - |
698 | 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, | - |
699 | 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, | - |
700 | 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, | - |
701 | 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, | - |
702 | 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, | - |
703 | 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, | - |
704 | 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, | - |
705 | 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, | - |
706 | 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, | - |
707 | 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, | - |
708 | 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, | - |
709 | 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, | - |
710 | 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, | - |
711 | 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 | - |
712 | }; | - |
713 | | - |
714 | const uchar *qt_get_bitflip_array() // called from QPixmap code | - |
715 | { | - |
716 | return bitflip; never executed: return bitflip; | 0 |
717 | } | - |
718 | | - |
719 | | - |
720 | /*! | - |
721 | Constructs a null image. | - |
722 | | - |
723 | \sa isNull() | - |
724 | */ | - |
725 | | - |
726 | QImage::QImage() | - |
727 | : QPaintDevice() | - |
728 | { | - |
729 | d = 0; executed (the execution status of this line is deduced): d = 0; | - |
730 | } executed: } Execution Count:128365 | 128365 |
731 | | - |
732 | /*! | - |
733 | Constructs an image with the given \a width, \a height and \a | - |
734 | format. | - |
735 | | - |
736 | A \l{isNull()}{null} image will be returned if memory cannot be allocated. | - |
737 | | - |
738 | \warning This will create a QImage with uninitialized data. Call | - |
739 | fill() to fill the image with an appropriate pixel value before | - |
740 | drawing onto it with QPainter. | - |
741 | */ | - |
742 | QImage::QImage(int width, int height, Format format) | - |
743 | : QPaintDevice() | - |
744 | { | - |
745 | d = QImageData::create(QSize(width, height), format, 0); executed (the execution status of this line is deduced): d = QImageData::create(QSize(width, height), format, 0); | - |
746 | } executed: } Execution Count:28544 | 28544 |
747 | | - |
748 | /*! | - |
749 | Constructs an image with the given \a size and \a format. | - |
750 | | - |
751 | A \l{isNull()}{null} image is returned if memory cannot be allocated. | - |
752 | | - |
753 | \warning This will create a QImage with uninitialized data. Call | - |
754 | fill() to fill the image with an appropriate pixel value before | - |
755 | drawing onto it with QPainter. | - |
756 | */ | - |
757 | QImage::QImage(const QSize &size, Format format) | - |
758 | : QPaintDevice() | - |
759 | { | - |
760 | d = QImageData::create(size, format, 0); executed (the execution status of this line is deduced): d = QImageData::create(size, format, 0); | - |
761 | } executed: } Execution Count:5505 | 5505 |
762 | | - |
763 | | - |
764 | | - |
765 | QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction, void *cleanupInfo) | - |
766 | { | - |
767 | QImageData *d = 0; executed (the execution status of this line is deduced): QImageData *d = 0; | - |
768 | | - |
769 | if (format == QImage::Format_Invalid) partially evaluated: format == QImage::Format_Invalid no Evaluation Count:0 | yes Evaluation Count:114534 |
| 0-114534 |
770 | return d; never executed: return d; | 0 |
771 | | - |
772 | const int depth = qt_depthForFormat(format); executed (the execution status of this line is deduced): const int depth = qt_depthForFormat(format); | - |
773 | const int calc_bytes_per_line = ((width * depth + 31)/32) * 4; executed (the execution status of this line is deduced): const int calc_bytes_per_line = ((width * depth + 31)/32) * 4; | - |
774 | const int min_bytes_per_line = (width * depth + 7)/8; executed (the execution status of this line is deduced): const int min_bytes_per_line = (width * depth + 7)/8; | - |
775 | | - |
776 | if (bpl <= 0) evaluated: bpl <= 0 yes Evaluation Count:4 | yes Evaluation Count:114530 |
| 4-114530 |
777 | bpl = calc_bytes_per_line; executed: bpl = calc_bytes_per_line; Execution Count:4 | 4 |
778 | | - |
779 | if (width <= 0 || height <= 0 || !data partially evaluated: width <= 0 no Evaluation Count:0 | yes Evaluation Count:114534 |
partially evaluated: height <= 0 no Evaluation Count:0 | yes Evaluation Count:114534 |
partially evaluated: !data no Evaluation Count:0 | yes Evaluation Count:114534 |
| 0-114534 |
780 | || INT_MAX/sizeof(uchar *) < uint(height) partially evaluated: 2147483647/sizeof(uchar *) < uint(height) no Evaluation Count:0 | yes Evaluation Count:114534 |
| 0-114534 |
781 | || INT_MAX/uint(depth) < uint(width) partially evaluated: 2147483647/uint(depth) < uint(width) no Evaluation Count:0 | yes Evaluation Count:114534 |
| 0-114534 |
782 | || bpl <= 0 partially evaluated: bpl <= 0 no Evaluation Count:0 | yes Evaluation Count:114534 |
| 0-114534 |
783 | || height <= 0 partially evaluated: height <= 0 no Evaluation Count:0 | yes Evaluation Count:114534 |
| 0-114534 |
784 | || bpl < min_bytes_per_line partially evaluated: bpl < min_bytes_per_line no Evaluation Count:0 | yes Evaluation Count:114534 |
| 0-114534 |
785 | || INT_MAX/uint(bpl) < uint(height)) partially evaluated: 2147483647/uint(bpl) < uint(height) no Evaluation Count:0 | yes Evaluation Count:114534 |
| 0-114534 |
786 | return d; // invalid parameter(s) never executed: return d; | 0 |
787 | | - |
788 | d = new QImageData; executed (the execution status of this line is deduced): d = new QImageData; | - |
789 | d->ref.ref(); executed (the execution status of this line is deduced): d->ref.ref(); | - |
790 | | - |
791 | d->own_data = false; executed (the execution status of this line is deduced): d->own_data = false; | - |
792 | d->ro_data = readOnly; executed (the execution status of this line is deduced): d->ro_data = readOnly; | - |
793 | d->data = data; executed (the execution status of this line is deduced): d->data = data; | - |
794 | d->width = width; executed (the execution status of this line is deduced): d->width = width; | - |
795 | d->height = height; executed (the execution status of this line is deduced): d->height = height; | - |
796 | d->depth = depth; executed (the execution status of this line is deduced): d->depth = depth; | - |
797 | d->format = format; executed (the execution status of this line is deduced): d->format = format; | - |
798 | | - |
799 | d->bytes_per_line = bpl; executed (the execution status of this line is deduced): d->bytes_per_line = bpl; | - |
800 | d->nbytes = d->bytes_per_line * height; executed (the execution status of this line is deduced): d->nbytes = d->bytes_per_line * height; | - |
801 | | - |
802 | d->cleanupFunction = cleanupFunction; executed (the execution status of this line is deduced): d->cleanupFunction = cleanupFunction; | - |
803 | d->cleanupInfo = cleanupInfo; executed (the execution status of this line is deduced): d->cleanupInfo = cleanupInfo; | - |
804 | | - |
805 | return d; executed: return d; Execution Count:114534 | 114534 |
806 | } | - |
807 | | - |
808 | /*! | - |
809 | Constructs an image with the given \a width, \a height and \a | - |
810 | format, that uses an existing memory buffer, \a data. The \a width | - |
811 | and \a height must be specified in pixels, \a data must be 32-bit aligned, | - |
812 | and each scanline of data in the image must also be 32-bit aligned. | - |
813 | | - |
814 | The buffer must remain valid throughout the life of the QImage and | - |
815 | all copies that have not been modified or otherwise detached from | - |
816 | the original buffer. The image does not delete the buffer at destruction. | - |
817 | You can provide a function pointer \a cleanupFunction along with an | - |
818 | extra pointer \a cleanupInfo that will be called when the last copy | - |
819 | is destroyed. | - |
820 | | - |
821 | If \a format is an indexed color format, the image color table is | - |
822 | initially empty and must be sufficiently expanded with | - |
823 | setColorCount() or setColorTable() before the image is used. | - |
824 | */ | - |
825 | QImage::QImage(uchar* data, int width, int height, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo) | - |
826 | : QPaintDevice() | - |
827 | { | - |
828 | d = QImageData::create(data, width, height, 0, format, false, cleanupFunction, cleanupInfo); executed (the execution status of this line is deduced): d = QImageData::create(data, width, height, 0, format, false, cleanupFunction, cleanupInfo); | - |
829 | } executed: } Execution Count:4 | 4 |
830 | | - |
831 | /*! | - |
832 | Constructs an image with the given \a width, \a height and \a | - |
833 | format, that uses an existing read-only memory buffer, \a | - |
834 | data. The \a width and \a height must be specified in pixels, \a | - |
835 | data must be 32-bit aligned, and each scanline of data in the | - |
836 | image must also be 32-bit aligned. | - |
837 | | - |
838 | The buffer must remain valid throughout the life of the QImage and | - |
839 | all copies that have not been modified or otherwise detached from | - |
840 | the original buffer. The image does not delete the buffer at destruction. | - |
841 | You can provide a function pointer \a cleanupFunction along with an | - |
842 | extra pointer \a cleanupInfo that will be called when the last copy | - |
843 | is destroyed. | - |
844 | | - |
845 | If \a format is an indexed color format, the image color table is | - |
846 | initially empty and must be sufficiently expanded with | - |
847 | setColorCount() or setColorTable() before the image is used. | - |
848 | | - |
849 | Unlike the similar QImage constructor that takes a non-const data buffer, | - |
850 | this version will never alter the contents of the buffer. For example, | - |
851 | calling QImage::bits() will return a deep copy of the image, rather than | - |
852 | the buffer passed to the constructor. This allows for the efficiency of | - |
853 | constructing a QImage from raw data, without the possibility of the raw | - |
854 | data being changed. | - |
855 | */ | - |
856 | QImage::QImage(const uchar* data, int width, int height, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo) | - |
857 | : QPaintDevice() | - |
858 | { | - |
859 | d = QImageData::create(const_cast<uchar*>(data), width, height, 0, format, true, cleanupFunction, cleanupInfo); never executed (the execution status of this line is deduced): d = QImageData::create(const_cast<uchar*>(data), width, height, 0, format, true, cleanupFunction, cleanupInfo); | - |
860 | } | 0 |
861 | | - |
862 | /*! | - |
863 | Constructs an image with the given \a width, \a height and \a | - |
864 | format, that uses an existing memory buffer, \a data. The \a width | - |
865 | and \a height must be specified in pixels. \a bytesPerLine | - |
866 | specifies the number of bytes per line (stride). | - |
867 | | - |
868 | The buffer must remain valid throughout the life of the QImage and | - |
869 | all copies that have not been modified or otherwise detached from | - |
870 | the original buffer. The image does not delete the buffer at destruction. | - |
871 | You can provide a function pointer \a cleanupFunction along with an | - |
872 | extra pointer \a cleanupInfo that will be called when the last copy | - |
873 | is destroyed. | - |
874 | | - |
875 | If \a format is an indexed color format, the image color table is | - |
876 | initially empty and must be sufficiently expanded with | - |
877 | setColorCount() or setColorTable() before the image is used. | - |
878 | */ | - |
879 | QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo) | - |
880 | :QPaintDevice() | - |
881 | { | - |
882 | d = QImageData::create(data, width, height, bytesPerLine, format, false, cleanupFunction, cleanupInfo); executed (the execution status of this line is deduced): d = QImageData::create(data, width, height, bytesPerLine, format, false, cleanupFunction, cleanupInfo); | - |
883 | } executed: } Execution Count:113193 | 113193 |
884 | | - |
885 | | - |
886 | /*! | - |
887 | Constructs an image with the given \a width, \a height and \a | - |
888 | format, that uses an existing memory buffer, \a data. The \a width | - |
889 | and \a height must be specified in pixels. \a bytesPerLine | - |
890 | specifies the number of bytes per line (stride). | - |
891 | | - |
892 | The buffer must remain valid throughout the life of the QImage and | - |
893 | all copies that have not been modified or otherwise detached from | - |
894 | the original buffer. The image does not delete the buffer at destruction. | - |
895 | You can provide a function pointer \a cleanupFunction along with an | - |
896 | extra pointer \a cleanupInfo that will be called when the last copy | - |
897 | is destroyed. | - |
898 | | - |
899 | If \a format is an indexed color format, the image color table is | - |
900 | initially empty and must be sufficiently expanded with | - |
901 | setColorCount() or setColorTable() before the image is used. | - |
902 | | - |
903 | Unlike the similar QImage constructor that takes a non-const data buffer, | - |
904 | this version will never alter the contents of the buffer. For example, | - |
905 | calling QImage::bits() will return a deep copy of the image, rather than | - |
906 | the buffer passed to the constructor. This allows for the efficiency of | - |
907 | constructing a QImage from raw data, without the possibility of the raw | - |
908 | data being changed. | - |
909 | */ | - |
910 | | - |
911 | QImage::QImage(const uchar *data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo) | - |
912 | :QPaintDevice() | - |
913 | { | - |
914 | d = QImageData::create(const_cast<uchar*>(data), width, height, bytesPerLine, format, true, cleanupFunction, cleanupInfo); executed (the execution status of this line is deduced): d = QImageData::create(const_cast<uchar*>(data), width, height, bytesPerLine, format, true, cleanupFunction, cleanupInfo); | - |
915 | } executed: } Execution Count:1337 | 1337 |
916 | | - |
917 | /*! | - |
918 | Constructs an image and tries to load the image from the file with | - |
919 | the given \a fileName. | - |
920 | | - |
921 | The loader attempts to read the image using the specified \a | - |
922 | format. If the \a format is not specified (which is the default), | - |
923 | the loader probes the file for a header to guess the file format. | - |
924 | | - |
925 | If the loading of the image failed, this object is a null image. | - |
926 | | - |
927 | The file name can either refer to an actual file on disk or to one | - |
928 | of the application's embedded resources. See the | - |
929 | \l{resources.html}{Resource System} overview for details on how to | - |
930 | embed images and other resource files in the application's | - |
931 | executable. | - |
932 | | - |
933 | \sa isNull(), {QImage#Reading and Writing Image Files}{Reading and Writing Image Files} | - |
934 | */ | - |
935 | | - |
936 | QImage::QImage(const QString &fileName, const char *format) | - |
937 | : QPaintDevice() | - |
938 | { | - |
939 | d = 0; executed (the execution status of this line is deduced): d = 0; | - |
940 | load(fileName, format); executed (the execution status of this line is deduced): load(fileName, format); | - |
941 | } executed: } Execution Count:168 | 168 |
942 | | - |
943 | #ifndef QT_NO_IMAGEFORMAT_XPM | - |
944 | extern bool qt_read_xpm_image_or_array(QIODevice *device, const char * const *source, QImage &image); | - |
945 | | - |
946 | /*! | - |
947 | Constructs an image from the given \a xpm image. | - |
948 | | - |
949 | Make sure that the image is a valid XPM image. Errors are silently | - |
950 | ignored. | - |
951 | | - |
952 | Note that it's possible to squeeze the XPM variable a little bit | - |
953 | by using an unusual declaration: | - |
954 | | - |
955 | \snippet code/src_gui_image_qimage.cpp 2 | - |
956 | | - |
957 | The extra \c const makes the entire definition read-only, which is | - |
958 | slightly more efficient (e.g., when the code is in a shared | - |
959 | library) and able to be stored in ROM with the application. | - |
960 | */ | - |
961 | | - |
962 | QImage::QImage(const char * const xpm[]) | - |
963 | : QPaintDevice() | - |
964 | { | - |
965 | d = 0; executed (the execution status of this line is deduced): d = 0; | - |
966 | if (!xpm) partially evaluated: !xpm no Evaluation Count:0 | yes Evaluation Count:2216 |
| 0-2216 |
967 | return; | 0 |
968 | if (!qt_read_xpm_image_or_array(0, xpm, *this)) evaluated: !qt_read_xpm_image_or_array(0, xpm, *this) yes Evaluation Count:1 | yes Evaluation Count:2215 |
| 1-2215 |
969 | // Issue: Warning because the constructor may be ambigious | - |
970 | qWarning("QImage::QImage(), XPM is not supported"); executed: QMessageLogger("image/qimage.cpp", 970, __PRETTY_FUNCTION__).warning("QImage::QImage(), XPM is not supported"); Execution Count:1 | 1 |
971 | } executed: } Execution Count:2216 | 2216 |
972 | #endif // QT_NO_IMAGEFORMAT_XPM | - |
973 | | - |
974 | /*! | - |
975 | Constructs a shallow copy of the given \a image. | - |
976 | | - |
977 | For more information about shallow copies, see the \l {Implicit | - |
978 | Data Sharing} documentation. | - |
979 | | - |
980 | \sa copy() | - |
981 | */ | - |
982 | | - |
983 | QImage::QImage(const QImage &image) | - |
984 | : QPaintDevice() | - |
985 | { | - |
986 | if (image.paintingActive() || isLocked(image.d)) { evaluated: image.paintingActive() yes Evaluation Count:1 | yes Evaluation Count:39174 |
partially evaluated: isLocked(image.d) no Evaluation Count:0 | yes Evaluation Count:39174 |
| 0-39174 |
987 | d = 0; executed (the execution status of this line is deduced): d = 0; | - |
988 | image.copy().swap(*this); executed (the execution status of this line is deduced): image.copy().swap(*this); | - |
989 | } else { executed: } Execution Count:1 | 1 |
990 | d = image.d; executed (the execution status of this line is deduced): d = image.d; | - |
991 | if (d) evaluated: d yes Evaluation Count:39146 | yes Evaluation Count:28 |
| 28-39146 |
992 | d->ref.ref(); executed: d->ref.ref(); Execution Count:39146 | 39146 |
993 | } executed: } Execution Count:39174 | 39174 |
994 | } | - |
995 | | - |
996 | /*! | - |
997 | Destroys the image and cleans up. | - |
998 | */ | - |
999 | | - |
1000 | QImage::~QImage() | - |
1001 | { | - |
1002 | if (d && !d->ref.deref()) evaluated: d yes Evaluation Count:189281 | yes Evaluation Count:129053 |
evaluated: !d->ref.deref() yes Evaluation Count:146169 | yes Evaluation Count:43112 |
| 43112-189281 |
1003 | delete d; executed: delete d; Execution Count:146169 | 146169 |
1004 | } executed: } Execution Count:318334 | 318334 |
1005 | | - |
1006 | /*! | - |
1007 | Assigns a shallow copy of the given \a image to this image and | - |
1008 | returns a reference to this image. | - |
1009 | | - |
1010 | For more information about shallow copies, see the \l {Implicit | - |
1011 | Data Sharing} documentation. | - |
1012 | | - |
1013 | \sa copy(), QImage() | - |
1014 | */ | - |
1015 | | - |
1016 | QImage &QImage::operator=(const QImage &image) | - |
1017 | { | - |
1018 | if (image.paintingActive() || isLocked(image.d)) { partially evaluated: image.paintingActive() no Evaluation Count:0 | yes Evaluation Count:4441 |
partially evaluated: isLocked(image.d) no Evaluation Count:0 | yes Evaluation Count:4441 |
| 0-4441 |
1019 | operator=(image.copy()); never executed (the execution status of this line is deduced): operator=(image.copy()); | - |
1020 | } else { | 0 |
1021 | if (image.d) evaluated: image.d yes Evaluation Count:4396 | yes Evaluation Count:45 |
| 45-4396 |
1022 | image.d->ref.ref(); executed: image.d->ref.ref(); Execution Count:4396 | 4396 |
1023 | if (d && !d->ref.deref()) evaluated: d yes Evaluation Count:2502 | yes Evaluation Count:1939 |
evaluated: !d->ref.deref() yes Evaluation Count:2072 | yes Evaluation Count:430 |
| 430-2502 |
1024 | delete d; executed: delete d; Execution Count:2072 | 2072 |
1025 | d = image.d; executed (the execution status of this line is deduced): d = image.d; | - |
1026 | } executed: } Execution Count:4441 | 4441 |
1027 | return *this; executed: return *this; Execution Count:4441 | 4441 |
1028 | } | - |
1029 | | - |
1030 | /*! | - |
1031 | \fn void QImage::swap(QImage &other) | - |
1032 | \since 4.8 | - |
1033 | | - |
1034 | Swaps image \a other with this image. This operation is very | - |
1035 | fast and never fails. | - |
1036 | */ | - |
1037 | | - |
1038 | /*! | - |
1039 | \internal | - |
1040 | */ | - |
1041 | int QImage::devType() const | - |
1042 | { | - |
1043 | return QInternal::Image; executed: return QInternal::Image; Execution Count:74182 | 74182 |
1044 | } | - |
1045 | | - |
1046 | /*! | - |
1047 | Returns the image as a QVariant. | - |
1048 | */ | - |
1049 | QImage::operator QVariant() const | - |
1050 | { | - |
1051 | return QVariant(QVariant::Image, this); executed: return QVariant(QVariant::Image, this); Execution Count:112 | 112 |
1052 | } | - |
1053 | | - |
1054 | /*! | - |
1055 | \internal | - |
1056 | | - |
1057 | If multiple images share common data, this image makes a copy of | - |
1058 | the data and detaches itself from the sharing mechanism, making | - |
1059 | sure that this image is the only one referring to the data. | - |
1060 | | - |
1061 | Nothing is done if there is just a single reference. | - |
1062 | | - |
1063 | \sa copy(), isDetached(), {Implicit Data Sharing} | - |
1064 | */ | - |
1065 | void QImage::detach() | - |
1066 | { | - |
1067 | if (d) { evaluated: d yes Evaluation Count:4217841 | yes Evaluation Count:185 |
| 185-4217841 |
1068 | if (d->is_cached && d->ref.load() == 1) partially evaluated: d->is_cached no Evaluation Count:0 | yes Evaluation Count:4217841 |
never evaluated: d->ref.load() == 1 | 0-4217841 |
1069 | QImagePixmapCleanupHooks::executeImageHooks(cacheKey()); never executed: QImagePixmapCleanupHooks::executeImageHooks(cacheKey()); | 0 |
1070 | | - |
1071 | if (d->ref.load() != 1 || d->ro_data) evaluated: d->ref.load() != 1 yes Evaluation Count:6021 | yes Evaluation Count:4211820 |
evaluated: d->ro_data yes Evaluation Count:1 | yes Evaluation Count:4211819 |
| 1-4211820 |
1072 | *this = copy(); executed: *this = copy(); Execution Count:6022 | 6022 |
1073 | | - |
1074 | if (d) partially evaluated: d yes Evaluation Count:4217841 | no Evaluation Count:0 |
| 0-4217841 |
1075 | ++d->detach_no; executed: ++d->detach_no; Execution Count:4217841 | 4217841 |
1076 | } executed: } Execution Count:4217841 | 4217841 |
1077 | } executed: } Execution Count:4218026 | 4218026 |
1078 | | - |
1079 | | - |
1080 | /*! | - |
1081 | \fn QImage QImage::copy(int x, int y, int width, int height) const | - |
1082 | \overload | - |
1083 | | - |
1084 | The returned image is copied from the position (\a x, \a y) in | - |
1085 | this image, and will always have the given \a width and \a height. | - |
1086 | In areas beyond this image, pixels are set to 0. | - |
1087 | | - |
1088 | */ | - |
1089 | | - |
1090 | /*! | - |
1091 | \fn QImage QImage::copy(const QRect& rectangle) const | - |
1092 | | - |
1093 | Returns a sub-area of the image as a new image. | - |
1094 | | - |
1095 | The returned image is copied from the position (\a | - |
1096 | {rectangle}.x(), \a{rectangle}.y()) in this image, and will always | - |
1097 | have the size of the given \a rectangle. | - |
1098 | | - |
1099 | In areas beyond this image, pixels are set to 0. For 32-bit RGB | - |
1100 | images, this means black; for 32-bit ARGB images, this means | - |
1101 | transparent black; for 8-bit images, this means the color with | - |
1102 | index 0 in the color table which can be anything; for 1-bit | - |
1103 | images, this means Qt::color0. | - |
1104 | | - |
1105 | If the given \a rectangle is a null rectangle the entire image is | - |
1106 | copied. | - |
1107 | | - |
1108 | \sa QImage() | - |
1109 | */ | - |
1110 | QImage QImage::copy(const QRect& r) const | - |
1111 | { | - |
1112 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:10031 |
| 0-10031 |
1113 | return QImage(); never executed: return QImage(); | 0 |
1114 | | - |
1115 | if (r.isNull()) { evaluated: r.isNull() yes Evaluation Count:6043 | yes Evaluation Count:3988 |
| 3988-6043 |
1116 | QImage image(d->width, d->height, d->format); executed (the execution status of this line is deduced): QImage image(d->width, d->height, d->format); | - |
1117 | if (image.isNull()) partially evaluated: image.isNull() no Evaluation Count:0 | yes Evaluation Count:6043 |
| 0-6043 |
1118 | return image; never executed: return image; | 0 |
1119 | | - |
1120 | // Qt for Embedded Linux can create images with non-default bpl | - |
1121 | // make sure we don't crash. | - |
1122 | if (image.d->nbytes != d->nbytes) { evaluated: image.d->nbytes != d->nbytes yes Evaluation Count:4584 | yes Evaluation Count:1459 |
| 1459-4584 |
1123 | int bpl = qMin(bytesPerLine(), image.bytesPerLine()); executed (the execution status of this line is deduced): int bpl = qMin(bytesPerLine(), image.bytesPerLine()); | - |
1124 | for (int i = 0; i < height(); i++) evaluated: i < height() yes Evaluation Count:37748 | yes Evaluation Count:4584 |
| 4584-37748 |
1125 | memcpy(image.scanLine(i), scanLine(i), bpl); executed: memcpy(image.scanLine(i), scanLine(i), bpl); Execution Count:37748 | 37748 |
1126 | } else executed: } Execution Count:4584 | 4584 |
1127 | memcpy(image.bits(), bits(), d->nbytes); executed: memcpy(image.bits(), bits(), d->nbytes); Execution Count:1459 | 1459 |
1128 | image.d->colortable = d->colortable; executed (the execution status of this line is deduced): image.d->colortable = d->colortable; | - |
1129 | image.d->dpmx = d->dpmx; executed (the execution status of this line is deduced): image.d->dpmx = d->dpmx; | - |
1130 | image.d->dpmy = d->dpmy; executed (the execution status of this line is deduced): image.d->dpmy = d->dpmy; | - |
1131 | image.d->offset = d->offset; executed (the execution status of this line is deduced): image.d->offset = d->offset; | - |
1132 | image.d->has_alpha_clut = d->has_alpha_clut; executed (the execution status of this line is deduced): image.d->has_alpha_clut = d->has_alpha_clut; | - |
1133 | image.d->text = d->text; executed (the execution status of this line is deduced): image.d->text = d->text; | - |
1134 | return image; executed: return image; Execution Count:6043 | 6043 |
1135 | } | - |
1136 | | - |
1137 | int x = r.x(); executed (the execution status of this line is deduced): int x = r.x(); | - |
1138 | int y = r.y(); executed (the execution status of this line is deduced): int y = r.y(); | - |
1139 | int w = r.width(); executed (the execution status of this line is deduced): int w = r.width(); | - |
1140 | int h = r.height(); executed (the execution status of this line is deduced): int h = r.height(); | - |
1141 | | - |
1142 | int dx = 0; executed (the execution status of this line is deduced): int dx = 0; | - |
1143 | int dy = 0; executed (the execution status of this line is deduced): int dy = 0; | - |
1144 | if (w <= 0 || h <= 0) partially evaluated: w <= 0 no Evaluation Count:0 | yes Evaluation Count:3988 |
partially evaluated: h <= 0 no Evaluation Count:0 | yes Evaluation Count:3988 |
| 0-3988 |
1145 | return QImage(); never executed: return QImage(); | 0 |
1146 | | - |
1147 | QImage image(w, h, d->format); executed (the execution status of this line is deduced): QImage image(w, h, d->format); | - |
1148 | if (image.isNull()) partially evaluated: image.isNull() no Evaluation Count:0 | yes Evaluation Count:3988 |
| 0-3988 |
1149 | return image; never executed: return image; | 0 |
1150 | | - |
1151 | if (x < 0 || y < 0 || x + w > d->width || y + h > d->height) { partially evaluated: x < 0 no Evaluation Count:0 | yes Evaluation Count:3988 |
partially evaluated: y < 0 no Evaluation Count:0 | yes Evaluation Count:3988 |
evaluated: x + w > d->width yes Evaluation Count:3 | yes Evaluation Count:3985 |
evaluated: y + h > d->height yes Evaluation Count:2 | yes Evaluation Count:3983 |
| 0-3988 |
1152 | // bitBlt will not cover entire image - clear it. | - |
1153 | image.fill(0); executed (the execution status of this line is deduced): image.fill(0); | - |
1154 | if (x < 0) { partially evaluated: x < 0 no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1155 | dx = -x; never executed (the execution status of this line is deduced): dx = -x; | - |
1156 | x = 0; never executed (the execution status of this line is deduced): x = 0; | - |
1157 | } | 0 |
1158 | if (y < 0) { partially evaluated: y < 0 no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1159 | dy = -y; never executed (the execution status of this line is deduced): dy = -y; | - |
1160 | y = 0; never executed (the execution status of this line is deduced): y = 0; | - |
1161 | } | 0 |
1162 | } executed: } Execution Count:5 | 5 |
1163 | | - |
1164 | image.d->colortable = d->colortable; executed (the execution status of this line is deduced): image.d->colortable = d->colortable; | - |
1165 | | - |
1166 | int pixels_to_copy = qMax(w - dx, 0); executed (the execution status of this line is deduced): int pixels_to_copy = qMax(w - dx, 0); | - |
1167 | if (x > d->width) evaluated: x > d->width yes Evaluation Count:1 | yes Evaluation Count:3987 |
| 1-3987 |
1168 | pixels_to_copy = 0; executed: pixels_to_copy = 0; Execution Count:1 | 1 |
1169 | else if (pixels_to_copy > d->width - x) evaluated: pixels_to_copy > d->width - x yes Evaluation Count:2 | yes Evaluation Count:3985 |
| 2-3985 |
1170 | pixels_to_copy = d->width - x; executed: pixels_to_copy = d->width - x; Execution Count:2 | 2 |
1171 | int lines_to_copy = qMax(h - dy, 0); executed (the execution status of this line is deduced): int lines_to_copy = qMax(h - dy, 0); | - |
1172 | if (y > d->height) partially evaluated: y > d->height no Evaluation Count:0 | yes Evaluation Count:3988 |
| 0-3988 |
1173 | lines_to_copy = 0; never executed: lines_to_copy = 0; | 0 |
1174 | else if (lines_to_copy > d->height - y) evaluated: lines_to_copy > d->height - y yes Evaluation Count:4 | yes Evaluation Count:3984 |
| 4-3984 |
1175 | lines_to_copy = d->height - y; executed: lines_to_copy = d->height - y; Execution Count:4 | 4 |
1176 | | - |
1177 | bool byteAligned = true; executed (the execution status of this line is deduced): bool byteAligned = true; | - |
1178 | if (d->format == Format_Mono || d->format == Format_MonoLSB) partially evaluated: d->format == Format_Mono no Evaluation Count:0 | yes Evaluation Count:3988 |
evaluated: d->format == Format_MonoLSB yes Evaluation Count:3 | yes Evaluation Count:3985 |
| 0-3988 |
1179 | byteAligned = !(dx & 7) && !(x & 7) && !(pixels_to_copy & 7); executed: byteAligned = !(dx & 7) && !(x & 7) && !(pixels_to_copy & 7); Execution Count:3 partially evaluated: !(dx & 7) yes Evaluation Count:3 | no Evaluation Count:0 |
partially evaluated: !(x & 7) yes Evaluation Count:3 | no Evaluation Count:0 |
partially evaluated: !(pixels_to_copy & 7) no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
1180 | | - |
1181 | if (byteAligned) { evaluated: byteAligned yes Evaluation Count:3985 | yes Evaluation Count:3 |
| 3-3985 |
1182 | const uchar *src = d->data + ((x * d->depth) >> 3) + y * d->bytes_per_line; executed (the execution status of this line is deduced): const uchar *src = d->data + ((x * d->depth) >> 3) + y * d->bytes_per_line; | - |
1183 | uchar *dest = image.d->data + ((dx * d->depth) >> 3) + dy * image.d->bytes_per_line; executed (the execution status of this line is deduced): uchar *dest = image.d->data + ((dx * d->depth) >> 3) + dy * image.d->bytes_per_line; | - |
1184 | const int bytes_to_copy = (pixels_to_copy * d->depth) >> 3; executed (the execution status of this line is deduced): const int bytes_to_copy = (pixels_to_copy * d->depth) >> 3; | - |
1185 | for (int i = 0; i < lines_to_copy; ++i) { evaluated: i < lines_to_copy yes Evaluation Count:6902 | yes Evaluation Count:3985 |
| 3985-6902 |
1186 | memcpy(dest, src, bytes_to_copy); executed (the execution status of this line is deduced): memcpy(dest, src, bytes_to_copy); | - |
1187 | src += d->bytes_per_line; executed (the execution status of this line is deduced): src += d->bytes_per_line; | - |
1188 | dest += image.d->bytes_per_line; executed (the execution status of this line is deduced): dest += image.d->bytes_per_line; | - |
1189 | } executed: } Execution Count:6902 | 6902 |
1190 | } else if (d->format == Format_Mono) { executed: } Execution Count:3985 partially evaluated: d->format == Format_Mono no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3985 |
1191 | const uchar *src = d->data + y * d->bytes_per_line; never executed (the execution status of this line is deduced): const uchar *src = d->data + y * d->bytes_per_line; | - |
1192 | uchar *dest = image.d->data + dy * image.d->bytes_per_line; never executed (the execution status of this line is deduced): uchar *dest = image.d->data + dy * image.d->bytes_per_line; | - |
1193 | for (int i = 0; i < lines_to_copy; ++i) { never evaluated: i < lines_to_copy | 0 |
1194 | for (int j = 0; j < pixels_to_copy; ++j) { never evaluated: j < pixels_to_copy | 0 |
1195 | if (src[(x + j) >> 3] & (0x80 >> ((x + j) & 7))) never evaluated: src[(x + j) >> 3] & (0x80 >> ((x + j) & 7)) | 0 |
1196 | dest[(dx + j) >> 3] |= (0x80 >> ((dx + j) & 7)); never executed: dest[(dx + j) >> 3] |= (0x80 >> ((dx + j) & 7)); | 0 |
1197 | else | - |
1198 | dest[(dx + j) >> 3] &= ~(0x80 >> ((dx + j) & 7)); never executed: dest[(dx + j) >> 3] &= ~(0x80 >> ((dx + j) & 7)); | 0 |
1199 | } | - |
1200 | src += d->bytes_per_line; never executed (the execution status of this line is deduced): src += d->bytes_per_line; | - |
1201 | dest += image.d->bytes_per_line; never executed (the execution status of this line is deduced): dest += image.d->bytes_per_line; | - |
1202 | } | 0 |
1203 | } else { // Format_MonoLSB | 0 |
1204 | Q_ASSERT(d->format == Format_MonoLSB); executed (the execution status of this line is deduced): qt_noop(); | - |
1205 | const uchar *src = d->data + y * d->bytes_per_line; executed (the execution status of this line is deduced): const uchar *src = d->data + y * d->bytes_per_line; | - |
1206 | uchar *dest = image.d->data + dy * image.d->bytes_per_line; executed (the execution status of this line is deduced): uchar *dest = image.d->data + dy * image.d->bytes_per_line; | - |
1207 | for (int i = 0; i < lines_to_copy; ++i) { evaluated: i < lines_to_copy yes Evaluation Count:110 | yes Evaluation Count:3 |
| 3-110 |
1208 | for (int j = 0; j < pixels_to_copy; ++j) { evaluated: j < pixels_to_copy yes Evaluation Count:5100 | yes Evaluation Count:110 |
| 110-5100 |
1209 | if (src[(x + j) >> 3] & (0x1 << ((x + j) & 7))) evaluated: src[(x + j) >> 3] & (0x1 << ((x + j) & 7)) yes Evaluation Count:4222 | yes Evaluation Count:878 |
| 878-4222 |
1210 | dest[(dx + j) >> 3] |= (0x1 << ((dx + j) & 7)); executed: dest[(dx + j) >> 3] |= (0x1 << ((dx + j) & 7)); Execution Count:4222 | 4222 |
1211 | else | - |
1212 | dest[(dx + j) >> 3] &= ~(0x1 << ((dx + j) & 7)); executed: dest[(dx + j) >> 3] &= ~(0x1 << ((dx + j) & 7)); Execution Count:878 | 878 |
1213 | } | - |
1214 | src += d->bytes_per_line; executed (the execution status of this line is deduced): src += d->bytes_per_line; | - |
1215 | dest += image.d->bytes_per_line; executed (the execution status of this line is deduced): dest += image.d->bytes_per_line; | - |
1216 | } executed: } Execution Count:110 | 110 |
1217 | } executed: } Execution Count:3 | 3 |
1218 | | - |
1219 | image.d->dpmx = dotsPerMeterX(); executed (the execution status of this line is deduced): image.d->dpmx = dotsPerMeterX(); | - |
1220 | image.d->dpmy = dotsPerMeterY(); executed (the execution status of this line is deduced): image.d->dpmy = dotsPerMeterY(); | - |
1221 | image.d->devicePixelRatio = devicePixelRatio(); executed (the execution status of this line is deduced): image.d->devicePixelRatio = devicePixelRatio(); | - |
1222 | image.d->offset = offset(); executed (the execution status of this line is deduced): image.d->offset = offset(); | - |
1223 | image.d->has_alpha_clut = d->has_alpha_clut; executed (the execution status of this line is deduced): image.d->has_alpha_clut = d->has_alpha_clut; | - |
1224 | image.d->text = d->text; executed (the execution status of this line is deduced): image.d->text = d->text; | - |
1225 | return image; executed: return image; Execution Count:3988 | 3988 |
1226 | } | - |
1227 | | - |
1228 | | - |
1229 | /*! | - |
1230 | \fn bool QImage::isNull() const | - |
1231 | | - |
1232 | Returns true if it is a null image, otherwise returns false. | - |
1233 | | - |
1234 | A null image has all parameters set to zero and no allocated data. | - |
1235 | */ | - |
1236 | bool QImage::isNull() const | - |
1237 | { | - |
1238 | return !d; executed: return !d; Execution Count:169815 | 169815 |
1239 | } | - |
1240 | | - |
1241 | /*! | - |
1242 | \fn int QImage::width() const | - |
1243 | | - |
1244 | Returns the width of the image. | - |
1245 | | - |
1246 | \sa {QImage#Image Information}{Image Information} | - |
1247 | */ | - |
1248 | int QImage::width() const | - |
1249 | { | - |
1250 | return d ? d->width : 0; executed: return d ? d->width : 0; Execution Count:22822819 | 22822819 |
1251 | } | - |
1252 | | - |
1253 | /*! | - |
1254 | \fn int QImage::height() const | - |
1255 | | - |
1256 | Returns the height of the image. | - |
1257 | | - |
1258 | \sa {QImage#Image Information}{Image Information} | - |
1259 | */ | - |
1260 | int QImage::height() const | - |
1261 | { | - |
1262 | return d ? d->height : 0; executed: return d ? d->height : 0; Execution Count:33571873 | 33571873 |
1263 | } | - |
1264 | | - |
1265 | /*! | - |
1266 | \fn QSize QImage::size() const | - |
1267 | | - |
1268 | Returns the size of the image, i.e. its width() and height(). | - |
1269 | | - |
1270 | \sa {QImage#Image Information}{Image Information} | - |
1271 | */ | - |
1272 | QSize QImage::size() const | - |
1273 | { | - |
1274 | return d ? QSize(d->width, d->height) : QSize(0, 0); executed: return d ? QSize(d->width, d->height) : QSize(0, 0); Execution Count:16998 | 16998 |
1275 | } | - |
1276 | | - |
1277 | /*! | - |
1278 | \fn QRect QImage::rect() const | - |
1279 | | - |
1280 | Returns the enclosing rectangle (0, 0, width(), height()) of the | - |
1281 | image. | - |
1282 | | - |
1283 | \sa {QImage#Image Information}{Image Information} | - |
1284 | */ | - |
1285 | QRect QImage::rect() const | - |
1286 | { | - |
1287 | return d ? QRect(0, 0, d->width, d->height) : QRect(); executed: return d ? QRect(0, 0, d->width, d->height) : QRect(); Execution Count:18195 | 18195 |
1288 | } | - |
1289 | | - |
1290 | /*! | - |
1291 | Returns the depth of the image. | - |
1292 | | - |
1293 | The image depth is the number of bits used to store a single | - |
1294 | pixel, also called bits per pixel (bpp). | - |
1295 | | - |
1296 | The supported depths are 1, 8, 16, 24 and 32. | - |
1297 | | - |
1298 | \sa bitPlaneCount(), convertToFormat(), {QImage#Image Formats}{Image Formats}, | - |
1299 | {QImage#Image Information}{Image Information} | - |
1300 | | - |
1301 | */ | - |
1302 | int QImage::depth() const | - |
1303 | { | - |
1304 | return d ? d->depth : 0; executed: return d ? d->depth : 0; Execution Count:200904 | 200904 |
1305 | } | - |
1306 | | - |
1307 | /*! | - |
1308 | \obsolete | - |
1309 | \fn int QImage::numColors() const | - |
1310 | | - |
1311 | Returns the size of the color table for the image. | - |
1312 | | - |
1313 | \sa setColorCount() | - |
1314 | */ | - |
1315 | | - |
1316 | /*! | - |
1317 | \since 4.6 | - |
1318 | \fn int QImage::colorCount() const | - |
1319 | | - |
1320 | Returns the size of the color table for the image. | - |
1321 | | - |
1322 | Notice that colorCount() returns 0 for 32-bpp images because these | - |
1323 | images do not use color tables, but instead encode pixel values as | - |
1324 | ARGB quadruplets. | - |
1325 | | - |
1326 | \sa setColorCount(), {QImage#Image Information}{Image Information} | - |
1327 | */ | - |
1328 | int QImage::colorCount() const | - |
1329 | { | - |
1330 | return d ? d->colortable.size() : 0; executed: return d ? d->colortable.size() : 0; Execution Count:4852 | 4852 |
1331 | } | - |
1332 | | - |
1333 | /*! | - |
1334 | Sets the color table used to translate color indexes to QRgb | - |
1335 | values, to the specified \a colors. | - |
1336 | | - |
1337 | When the image is used, the color table must be large enough to | - |
1338 | have entries for all the pixel/index values present in the image, | - |
1339 | otherwise the results are undefined. | - |
1340 | | - |
1341 | \sa colorTable(), setColor(), {QImage#Image Transformations}{Image | - |
1342 | Transformations} | - |
1343 | */ | - |
1344 | void QImage::setColorTable(const QVector<QRgb> colors) | - |
1345 | { | - |
1346 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:24 |
| 0-24 |
1347 | return; | 0 |
1348 | detach(); executed (the execution status of this line is deduced): detach(); | - |
1349 | | - |
1350 | // In case detach() ran out of memory | - |
1351 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:24 |
| 0-24 |
1352 | return; | 0 |
1353 | | - |
1354 | d->colortable = colors; executed (the execution status of this line is deduced): d->colortable = colors; | - |
1355 | d->has_alpha_clut = false; executed (the execution status of this line is deduced): d->has_alpha_clut = false; | - |
1356 | for (int i = 0; i < d->colortable.size(); ++i) { evaluated: i < d->colortable.size() yes Evaluation Count:2855 | yes Evaluation Count:14 |
| 14-2855 |
1357 | if (qAlpha(d->colortable.at(i)) != 255) { evaluated: qAlpha(d->colortable.at(i)) != 255 yes Evaluation Count:10 | yes Evaluation Count:2845 |
| 10-2845 |
1358 | d->has_alpha_clut = true; executed (the execution status of this line is deduced): d->has_alpha_clut = true; | - |
1359 | break; executed: break; Execution Count:10 | 10 |
1360 | } | - |
1361 | } executed: } Execution Count:2845 | 2845 |
1362 | } executed: } Execution Count:24 | 24 |
1363 | | - |
1364 | /*! | - |
1365 | Returns a list of the colors contained in the image's color table, | - |
1366 | or an empty list if the image does not have a color table | - |
1367 | | - |
1368 | \sa setColorTable(), colorCount(), color() | - |
1369 | */ | - |
1370 | QVector<QRgb> QImage::colorTable() const | - |
1371 | { | - |
1372 | return d ? d->colortable : QVector<QRgb>(); executed: return d ? d->colortable : QVector<QRgb>(); Execution Count:524 | 524 |
1373 | } | - |
1374 | | - |
1375 | /*! | - |
1376 | Returns the device pixel ratio for the image. This is the | - |
1377 | ratio between image pixels and device-independent pixels. | - |
1378 | | - |
1379 | Use this function when calculating layout geometry based on | - |
1380 | the image size: QSize layoutSize = image.size() / image.devicePixelRatio() | - |
1381 | | - |
1382 | The default value is 1.0. | - |
1383 | | - |
1384 | \sa setDevicePixelRatio() | - |
1385 | */ | - |
1386 | qreal QImage::devicePixelRatio() const | - |
1387 | { | - |
1388 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:25947 |
| 0-25947 |
1389 | return 1.0; never executed: return 1.0; | 0 |
1390 | return d->devicePixelRatio; executed: return d->devicePixelRatio; Execution Count:25947 | 25947 |
1391 | } | - |
1392 | | - |
1393 | /*! | - |
1394 | Sets the the device pixel ratio for the image. This is the | - |
1395 | ratio between image pixels and device-independent pixels. | - |
1396 | | - |
1397 | The default value is 1.0. Setting it to something else has | - |
1398 | two effects: | - |
1399 | | - |
1400 | QPainters that are opened on the image will be scaled. For | - |
1401 | example, painting on a 200x200 image if with a ratio of 2.0 | - |
1402 | will result in effective (device-independent) painting bounds | - |
1403 | of 100x100. | - |
1404 | | - |
1405 | Code paths in Qt that calculate layout geometry based on the | - |
1406 | image size will take the ratio into account: | - |
1407 | QSize layoutSize = image.size() / image.devicePixelRatio() | - |
1408 | The net effect of this is that the image is displayed as | - |
1409 | high-dpi image rather than a large image. | - |
1410 | | - |
1411 | \sa devicePixelRatio() | - |
1412 | */ | - |
1413 | void QImage::setDevicePixelRatio(qreal scaleFactor) | - |
1414 | { | - |
1415 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:9278 |
| 0-9278 |
1416 | return; | 0 |
1417 | detach(); executed (the execution status of this line is deduced): detach(); | - |
1418 | d->devicePixelRatio = scaleFactor; executed (the execution status of this line is deduced): d->devicePixelRatio = scaleFactor; | - |
1419 | } executed: } Execution Count:9278 | 9278 |
1420 | | - |
1421 | /*! | - |
1422 | \since 4.6 | - |
1423 | Returns the number of bytes occupied by the image data. | - |
1424 | | - |
1425 | \sa bytesPerLine(), bits(), {QImage#Image Information}{Image | - |
1426 | Information} | - |
1427 | */ | - |
1428 | int QImage::byteCount() const | - |
1429 | { | - |
1430 | return d ? d->nbytes : 0; executed: return d ? d->nbytes : 0; Execution Count:197 | 197 |
1431 | } | - |
1432 | | - |
1433 | /*! | - |
1434 | Returns the number of bytes per image scanline. | - |
1435 | | - |
1436 | This is equivalent to byteCount() / height(). | - |
1437 | | - |
1438 | \sa scanLine() | - |
1439 | */ | - |
1440 | int QImage::bytesPerLine() const | - |
1441 | { | - |
1442 | return (d && d->height) ? d->nbytes / d->height : 0; executed: return (d && d->height) ? d->nbytes / d->height : 0; Execution Count:136597 | 136597 |
1443 | } | - |
1444 | | - |
1445 | | - |
1446 | /*! | - |
1447 | Returns the color in the color table at index \a i. The first | - |
1448 | color is at index 0. | - |
1449 | | - |
1450 | The colors in an image's color table are specified as ARGB | - |
1451 | quadruplets (QRgb). Use the qAlpha(), qRed(), qGreen(), and | - |
1452 | qBlue() functions to get the color value components. | - |
1453 | | - |
1454 | \sa setColor(), pixelIndex(), {QImage#Pixel Manipulation}{Pixel | - |
1455 | Manipulation} | - |
1456 | */ | - |
1457 | QRgb QImage::color(int i) const | - |
1458 | { | - |
1459 | Q_ASSERT(i < colorCount()); executed (the execution status of this line is deduced): qt_noop(); | - |
1460 | return d ? d->colortable.at(i) : QRgb(uint(-1)); executed: return d ? d->colortable.at(i) : QRgb(uint(-1)); Execution Count:788 | 788 |
1461 | } | - |
1462 | | - |
1463 | /*! | - |
1464 | \fn void QImage::setColor(int index, QRgb colorValue) | - |
1465 | | - |
1466 | Sets the color at the given \a index in the color table, to the | - |
1467 | given to \a colorValue. The color value is an ARGB quadruplet. | - |
1468 | | - |
1469 | If \a index is outside the current size of the color table, it is | - |
1470 | expanded with setColorCount(). | - |
1471 | | - |
1472 | \sa color(), colorCount(), setColorTable(), {QImage#Pixel Manipulation}{Pixel | - |
1473 | Manipulation} | - |
1474 | */ | - |
1475 | void QImage::setColor(int i, QRgb c) | - |
1476 | { | - |
1477 | if (!d) evaluated: !d yes Evaluation Count:1 | yes Evaluation Count:89951 |
| 1-89951 |
1478 | return; executed: return; Execution Count:1 | 1 |
1479 | if (i < 0 || d->depth > 8 || i >= 1<<d->depth) { partially evaluated: i < 0 no Evaluation Count:0 | yes Evaluation Count:89951 |
partially evaluated: d->depth > 8 no Evaluation Count:0 | yes Evaluation Count:89951 |
partially evaluated: i >= 1<<d->depth no Evaluation Count:0 | yes Evaluation Count:89951 |
| 0-89951 |
1480 | qWarning("QImage::setColor: Index out of bound %d", i); never executed (the execution status of this line is deduced): QMessageLogger("image/qimage.cpp", 1480, __PRETTY_FUNCTION__).warning("QImage::setColor: Index out of bound %d", i); | - |
1481 | return; | 0 |
1482 | } | - |
1483 | detach(); executed (the execution status of this line is deduced): detach(); | - |
1484 | | - |
1485 | // In case detach() run out of memory | - |
1486 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:89951 |
| 0-89951 |
1487 | return; | 0 |
1488 | | - |
1489 | if (i >= d->colortable.size()) evaluated: i >= d->colortable.size() yes Evaluation Count:1 | yes Evaluation Count:89950 |
| 1-89950 |
1490 | setColorCount(i+1); executed: setColorCount(i+1); Execution Count:1 | 1 |
1491 | d->colortable[i] = c; executed (the execution status of this line is deduced): d->colortable[i] = c; | - |
1492 | d->has_alpha_clut |= (qAlpha(c) != 255); executed (the execution status of this line is deduced): d->has_alpha_clut |= (qAlpha(c) != 255); | - |
1493 | } executed: } Execution Count:89951 | 89951 |
1494 | | - |
1495 | /*! | - |
1496 | Returns a pointer to the pixel data at the scanline with index \a | - |
1497 | i. The first scanline is at index 0. | - |
1498 | | - |
1499 | The scanline data is aligned on a 32-bit boundary. | - |
1500 | | - |
1501 | \warning If you are accessing 32-bpp image data, cast the returned | - |
1502 | pointer to \c{QRgb*} (QRgb has a 32-bit size) and use it to | - |
1503 | read/write the pixel value. You cannot use the \c{uchar*} pointer | - |
1504 | directly, because the pixel format depends on the byte order on | - |
1505 | the underlying platform. Use qRed(), qGreen(), qBlue(), and | - |
1506 | qAlpha() to access the pixels. | - |
1507 | | - |
1508 | \sa bytesPerLine(), bits(), {QImage#Pixel Manipulation}{Pixel | - |
1509 | Manipulation}, constScanLine() | - |
1510 | */ | - |
1511 | uchar *QImage::scanLine(int i) | - |
1512 | { | - |
1513 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:3951331 |
| 0-3951331 |
1514 | return 0; never executed: return 0; | 0 |
1515 | | - |
1516 | detach(); executed (the execution status of this line is deduced): detach(); | - |
1517 | | - |
1518 | // In case detach() ran out of memory | - |
1519 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:3951331 |
| 0-3951331 |
1520 | return 0; never executed: return 0; | 0 |
1521 | | - |
1522 | return d->data + i * d->bytes_per_line; executed: return d->data + i * d->bytes_per_line; Execution Count:3951331 | 3951331 |
1523 | } | - |
1524 | | - |
1525 | /*! | - |
1526 | \overload | - |
1527 | */ | - |
1528 | const uchar *QImage::scanLine(int i) const | - |
1529 | { | - |
1530 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:12257881 |
| 0-12257881 |
1531 | return 0; never executed: return 0; | 0 |
1532 | | - |
1533 | Q_ASSERT(i >= 0 && i < height()); executed (the execution status of this line is deduced): qt_noop(); | - |
1534 | return d->data + i * d->bytes_per_line; executed: return d->data + i * d->bytes_per_line; Execution Count:12257881 | 12257881 |
1535 | } | - |
1536 | | - |
1537 | | - |
1538 | /*! | - |
1539 | Returns a pointer to the pixel data at the scanline with index \a | - |
1540 | i. The first scanline is at index 0. | - |
1541 | | - |
1542 | The scanline data is aligned on a 32-bit boundary. | - |
1543 | | - |
1544 | Note that QImage uses \l{Implicit Data Sharing} {implicit data | - |
1545 | sharing}, but this function does \e not perform a deep copy of the | - |
1546 | shared pixel data, because the returned data is const. | - |
1547 | | - |
1548 | \sa scanLine(), constBits() | - |
1549 | \since 4.7 | - |
1550 | */ | - |
1551 | const uchar *QImage::constScanLine(int i) const | - |
1552 | { | - |
1553 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:15737025 |
| 0-15737025 |
1554 | return 0; never executed: return 0; | 0 |
1555 | | - |
1556 | Q_ASSERT(i >= 0 && i < height()); executed (the execution status of this line is deduced): qt_noop(); | - |
1557 | return d->data + i * d->bytes_per_line; executed: return d->data + i * d->bytes_per_line; Execution Count:15737025 | 15737025 |
1558 | } | - |
1559 | | - |
1560 | /*! | - |
1561 | Returns a pointer to the first pixel data. This is equivalent to | - |
1562 | scanLine(0). | - |
1563 | | - |
1564 | Note that QImage uses \l{Implicit Data Sharing} {implicit data | - |
1565 | sharing}. This function performs a deep copy of the shared pixel | - |
1566 | data, thus ensuring that this QImage is the only one using the | - |
1567 | current return value. | - |
1568 | | - |
1569 | \sa scanLine(), byteCount(), constBits() | - |
1570 | */ | - |
1571 | uchar *QImage::bits() | - |
1572 | { | - |
1573 | if (!d) evaluated: !d yes Evaluation Count:186 | yes Evaluation Count:119609 |
| 186-119609 |
1574 | return 0; executed: return 0; Execution Count:186 | 186 |
1575 | detach(); executed (the execution status of this line is deduced): detach(); | - |
1576 | | - |
1577 | // In case detach ran out of memory... | - |
1578 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:119609 |
| 0-119609 |
1579 | return 0; never executed: return 0; | 0 |
1580 | | - |
1581 | return d->data; executed: return d->data; Execution Count:119609 | 119609 |
1582 | } | - |
1583 | | - |
1584 | /*! | - |
1585 | \overload | - |
1586 | | - |
1587 | Note that QImage uses \l{Implicit Data Sharing} {implicit data | - |
1588 | sharing}, but this function does \e not perform a deep copy of the | - |
1589 | shared pixel data, because the returned data is const. | - |
1590 | */ | - |
1591 | const uchar *QImage::bits() const | - |
1592 | { | - |
1593 | return d ? d->data : 0; executed: return d ? d->data : 0; Execution Count:9089 | 9089 |
1594 | } | - |
1595 | | - |
1596 | | - |
1597 | /*! | - |
1598 | Returns a pointer to the first pixel data. | - |
1599 | | - |
1600 | Note that QImage uses \l{Implicit Data Sharing} {implicit data | - |
1601 | sharing}, but this function does \e not perform a deep copy of the | - |
1602 | shared pixel data, because the returned data is const. | - |
1603 | | - |
1604 | \sa bits(), constScanLine() | - |
1605 | \since 4.7 | - |
1606 | */ | - |
1607 | const uchar *QImage::constBits() const | - |
1608 | { | - |
1609 | return d ? d->data : 0; executed: return d ? d->data : 0; Execution Count:26 | 26 |
1610 | } | - |
1611 | | - |
1612 | /*! | - |
1613 | \fn void QImage::fill(uint pixelValue) | - |
1614 | | - |
1615 | Fills the entire image with the given \a pixelValue. | - |
1616 | | - |
1617 | If the depth of this image is 1, only the lowest bit is used. If | - |
1618 | you say fill(0), fill(2), etc., the image is filled with 0s. If | - |
1619 | you say fill(1), fill(3), etc., the image is filled with 1s. If | - |
1620 | the depth is 8, the lowest 8 bits are used and if the depth is 16 | - |
1621 | the lowest 16 bits are used. | - |
1622 | | - |
1623 | Note: QImage::pixel() returns the color of the pixel at the given | - |
1624 | coordinates while QColor::pixel() returns the pixel value of the | - |
1625 | underlying window system (essentially an index value), so normally | - |
1626 | you will want to use QImage::pixel() to use a color from an | - |
1627 | existing image or QColor::rgb() to use a specific color. | - |
1628 | | - |
1629 | \sa depth(), {QImage#Image Transformations}{Image Transformations} | - |
1630 | */ | - |
1631 | | - |
1632 | void QImage::fill(uint pixel) | - |
1633 | { | - |
1634 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:5208 |
| 0-5208 |
1635 | return; | 0 |
1636 | | - |
1637 | detach(); executed (the execution status of this line is deduced): detach(); | - |
1638 | | - |
1639 | // In case detach() ran out of memory | - |
1640 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:5208 |
| 0-5208 |
1641 | return; | 0 |
1642 | | - |
1643 | if (d->depth == 1 || d->depth == 8) { evaluated: d->depth == 1 yes Evaluation Count:141 | yes Evaluation Count:5067 |
evaluated: d->depth == 8 yes Evaluation Count:33 | yes Evaluation Count:5034 |
| 33-5067 |
1644 | int w = d->width; executed (the execution status of this line is deduced): int w = d->width; | - |
1645 | if (d->depth == 1) { evaluated: d->depth == 1 yes Evaluation Count:141 | yes Evaluation Count:33 |
| 33-141 |
1646 | if (pixel & 1) evaluated: pixel & 1 yes Evaluation Count:13 | yes Evaluation Count:128 |
| 13-128 |
1647 | pixel = 0xffffffff; executed: pixel = 0xffffffff; Execution Count:13 | 13 |
1648 | else | - |
1649 | pixel = 0; executed: pixel = 0; Execution Count:128 | 128 |
1650 | w = (w + 7) / 8; executed (the execution status of this line is deduced): w = (w + 7) / 8; | - |
1651 | } else { executed: } Execution Count:141 | 141 |
1652 | pixel &= 0xff; executed (the execution status of this line is deduced): pixel &= 0xff; | - |
1653 | } executed: } Execution Count:33 | 33 |
1654 | qt_rectfill<quint8>(d->data, pixel, 0, 0, executed (the execution status of this line is deduced): qt_rectfill<quint8>(d->data, pixel, 0, 0, | - |
1655 | w, d->height, d->bytes_per_line); executed (the execution status of this line is deduced): w, d->height, d->bytes_per_line); | - |
1656 | return; executed: return; Execution Count:174 | 174 |
1657 | } else if (d->depth == 16) { evaluated: d->depth == 16 yes Evaluation Count:38 | yes Evaluation Count:4996 |
| 38-4996 |
1658 | qt_rectfill<quint16>(reinterpret_cast<quint16*>(d->data), pixel, executed (the execution status of this line is deduced): qt_rectfill<quint16>(reinterpret_cast<quint16*>(d->data), pixel, | - |
1659 | 0, 0, d->width, d->height, d->bytes_per_line); executed (the execution status of this line is deduced): 0, 0, d->width, d->height, d->bytes_per_line); | - |
1660 | return; executed: return; Execution Count:38 | 38 |
1661 | } else if (d->depth == 24) { evaluated: d->depth == 24 yes Evaluation Count:61 | yes Evaluation Count:4935 |
| 61-4935 |
1662 | qt_rectfill<quint24>(reinterpret_cast<quint24*>(d->data), pixel, executed (the execution status of this line is deduced): qt_rectfill<quint24>(reinterpret_cast<quint24*>(d->data), pixel, | - |
1663 | 0, 0, d->width, d->height, d->bytes_per_line); executed (the execution status of this line is deduced): 0, 0, d->width, d->height, d->bytes_per_line); | - |
1664 | return; executed: return; Execution Count:61 | 61 |
1665 | } | - |
1666 | | - |
1667 | if (d->format == Format_RGB32) evaluated: d->format == Format_RGB32 yes Evaluation Count:2059 | yes Evaluation Count:2876 |
| 2059-2876 |
1668 | pixel |= 0xff000000; executed: pixel |= 0xff000000; Execution Count:2059 | 2059 |
1669 | | - |
1670 | qt_rectfill<uint>(reinterpret_cast<uint*>(d->data), pixel, executed (the execution status of this line is deduced): qt_rectfill<uint>(reinterpret_cast<uint*>(d->data), pixel, | - |
1671 | 0, 0, d->width, d->height, d->bytes_per_line); executed (the execution status of this line is deduced): 0, 0, d->width, d->height, d->bytes_per_line); | - |
1672 | } executed: } Execution Count:4935 | 4935 |
1673 | | - |
1674 | | - |
1675 | /*! | - |
1676 | \fn void QImage::fill(Qt::GlobalColor color) | - |
1677 | \overload | - |
1678 | \since 4.8 | - |
1679 | | - |
1680 | Fills the image with the given \a color, described as a standard global | - |
1681 | color. | - |
1682 | */ | - |
1683 | | - |
1684 | void QImage::fill(Qt::GlobalColor color) | - |
1685 | { | - |
1686 | fill(QColor(color)); executed (the execution status of this line is deduced): fill(QColor(color)); | - |
1687 | } executed: } Execution Count:81 | 81 |
1688 | | - |
1689 | | - |
1690 | | - |
1691 | /*! | - |
1692 | \fn void QImage::fill(const QColor &color) | - |
1693 | | - |
1694 | \overload | - |
1695 | | - |
1696 | Fills the entire image with the given \a color. | - |
1697 | | - |
1698 | If the depth of the image is 1, the image will be filled with 1 if | - |
1699 | \a color equals Qt::color1; it will otherwise be filled with 0. | - |
1700 | | - |
1701 | If the depth of the image is 8, the image will be filled with the | - |
1702 | index corresponding the \a color in the color table if present; it | - |
1703 | will otherwise be filled with 0. | - |
1704 | | - |
1705 | \since 4.8 | - |
1706 | */ | - |
1707 | | - |
1708 | void QImage::fill(const QColor &color) | - |
1709 | { | - |
1710 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:173 |
| 0-173 |
1711 | return; | 0 |
1712 | detach(); executed (the execution status of this line is deduced): detach(); | - |
1713 | | - |
1714 | // In case we run out of memory | - |
1715 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:173 |
| 0-173 |
1716 | return; | 0 |
1717 | | - |
1718 | if (d->depth == 32) { evaluated: d->depth == 32 yes Evaluation Count:44 | yes Evaluation Count:129 |
| 44-129 |
1719 | uint pixel = color.rgba(); executed (the execution status of this line is deduced): uint pixel = color.rgba(); | - |
1720 | if (d->format == QImage::Format_ARGB32_Premultiplied) evaluated: d->format == QImage::Format_ARGB32_Premultiplied yes Evaluation Count:16 | yes Evaluation Count:28 |
| 16-28 |
1721 | pixel = PREMUL(pixel); executed: pixel = PREMUL(pixel); Execution Count:16 | 16 |
1722 | fill((uint) pixel); executed (the execution status of this line is deduced): fill((uint) pixel); | - |
1723 | | - |
1724 | } else if (d->format == QImage::Format_RGB16) { executed: } Execution Count:44 evaluated: d->format == QImage::Format_RGB16 yes Evaluation Count:12 | yes Evaluation Count:117 |
| 12-117 |
1725 | fill((uint) qConvertRgb32To16(color.rgba())); executed (the execution status of this line is deduced): fill((uint) qConvertRgb32To16(color.rgba())); | - |
1726 | | - |
1727 | } else if (d->depth == 1) { executed: } Execution Count:12 evaluated: d->depth == 1 yes Evaluation Count:10 | yes Evaluation Count:107 |
| 10-107 |
1728 | if (color == Qt::color1) evaluated: color == Qt::color1 yes Evaluation Count:4 | yes Evaluation Count:6 |
| 4-6 |
1729 | fill((uint) 1); executed: fill((uint) 1); Execution Count:4 | 4 |
1730 | else | - |
1731 | fill((uint) 0); executed: fill((uint) 0); Execution Count:6 | 6 |
1732 | | - |
1733 | } else if (d->depth == 8) { evaluated: d->depth == 8 yes Evaluation Count:10 | yes Evaluation Count:97 |
| 10-97 |
1734 | uint pixel = 0; executed (the execution status of this line is deduced): uint pixel = 0; | - |
1735 | for (int i=0; i<d->colortable.size(); ++i) { partially evaluated: i<d->colortable.size() yes Evaluation Count:30 | no Evaluation Count:0 |
| 0-30 |
1736 | if (color.rgba() == d->colortable.at(i)) { evaluated: color.rgba() == d->colortable.at(i) yes Evaluation Count:10 | yes Evaluation Count:20 |
| 10-20 |
1737 | pixel = i; executed (the execution status of this line is deduced): pixel = i; | - |
1738 | break; executed: break; Execution Count:10 | 10 |
1739 | } | - |
1740 | } executed: } Execution Count:20 | 20 |
1741 | fill(pixel); executed (the execution status of this line is deduced): fill(pixel); | - |
1742 | | - |
1743 | } else { executed: } Execution Count:10 | 10 |
1744 | QPainter p(this); executed (the execution status of this line is deduced): QPainter p(this); | - |
1745 | p.setCompositionMode(QPainter::CompositionMode_Source); executed (the execution status of this line is deduced): p.setCompositionMode(QPainter::CompositionMode_Source); | - |
1746 | p.fillRect(rect(), color); executed (the execution status of this line is deduced): p.fillRect(rect(), color); | - |
1747 | } executed: } Execution Count:97 | 97 |
1748 | | - |
1749 | } | - |
1750 | | - |
1751 | | - |
1752 | | - |
1753 | | - |
1754 | | - |
1755 | | - |
1756 | /*! | - |
1757 | Inverts all pixel values in the image. | - |
1758 | | - |
1759 | The given invert \a mode only have a meaning when the image's | - |
1760 | depth is 32. The default \a mode is InvertRgb, which leaves the | - |
1761 | alpha channel unchanged. If the \a mode is InvertRgba, the alpha | - |
1762 | bits are also inverted. | - |
1763 | | - |
1764 | Inverting an 8-bit image means to replace all pixels using color | - |
1765 | index \e i with a pixel using color index 255 minus \e i. The same | - |
1766 | is the case for a 1-bit image. Note that the color table is \e not | - |
1767 | changed. | - |
1768 | | - |
1769 | \sa {QImage#Image Transformations}{Image Transformations} | - |
1770 | */ | - |
1771 | | - |
1772 | void QImage::invertPixels(InvertMode mode) | - |
1773 | { | - |
1774 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1775 | return; | 0 |
1776 | | - |
1777 | detach(); executed (the execution status of this line is deduced): detach(); | - |
1778 | | - |
1779 | // In case detach() ran out of memory | - |
1780 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1781 | return; | 0 |
1782 | | - |
1783 | if (depth() != 32) { evaluated: depth() != 32 yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
1784 | // number of used bytes pr line | - |
1785 | int bpl = (d->width * d->depth + 7) / 8; executed (the execution status of this line is deduced): int bpl = (d->width * d->depth + 7) / 8; | - |
1786 | int pad = d->bytes_per_line - bpl; executed (the execution status of this line is deduced): int pad = d->bytes_per_line - bpl; | - |
1787 | uchar *sl = d->data; executed (the execution status of this line is deduced): uchar *sl = d->data; | - |
1788 | for (int y=0; y<d->height; ++y) { evaluated: y<d->height yes Evaluation Count:9 | yes Evaluation Count:3 |
| 3-9 |
1789 | for (int x=0; x<bpl; ++x) evaluated: x<bpl yes Evaluation Count:9 | yes Evaluation Count:9 |
| 9 |
1790 | *sl++ ^= 0xff; executed: *sl++ ^= 0xff; Execution Count:9 | 9 |
1791 | sl += pad; executed (the execution status of this line is deduced): sl += pad; | - |
1792 | } executed: } Execution Count:9 | 9 |
1793 | } else { executed: } Execution Count:3 | 3 |
1794 | quint32 *p = (quint32*)d->data; executed (the execution status of this line is deduced): quint32 *p = (quint32*)d->data; | - |
1795 | quint32 *end = (quint32*)(d->data + d->nbytes); executed (the execution status of this line is deduced): quint32 *end = (quint32*)(d->data + d->nbytes); | - |
1796 | uint xorbits = (mode == InvertRgba) ? 0xffffffff : 0x00ffffff; partially evaluated: (mode == InvertRgba) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1797 | while (p < end) evaluated: p < end yes Evaluation Count:10000 | yes Evaluation Count:1 |
| 1-10000 |
1798 | *p++ ^= xorbits; executed: *p++ ^= xorbits; Execution Count:10000 | 10000 |
1799 | } executed: } Execution Count:1 | 1 |
1800 | } | - |
1801 | | - |
1802 | // Windows defines these | - |
1803 | #if defined(write) | - |
1804 | # undef write | - |
1805 | #endif | - |
1806 | #if defined(close) | - |
1807 | # undef close | - |
1808 | #endif | - |
1809 | #if defined(read) | - |
1810 | # undef read | - |
1811 | #endif | - |
1812 | | - |
1813 | /*! | - |
1814 | \since 4.6 | - |
1815 | Resizes the color table to contain \a colorCount entries. | - |
1816 | | - |
1817 | If the color table is expanded, all the extra colors will be set to | - |
1818 | transparent (i.e qRgba(0, 0, 0, 0)). | - |
1819 | | - |
1820 | When the image is used, the color table must be large enough to | - |
1821 | have entries for all the pixel/index values present in the image, | - |
1822 | otherwise the results are undefined. | - |
1823 | | - |
1824 | \sa colorCount(), colorTable(), setColor(), {QImage#Image | - |
1825 | Transformations}{Image Transformations} | - |
1826 | */ | - |
1827 | | - |
1828 | void QImage::setColorCount(int colorCount) | - |
1829 | { | - |
1830 | if (!d) { evaluated: !d yes Evaluation Count:2 | yes Evaluation Count:2918 |
| 2-2918 |
1831 | qWarning("QImage::setColorCount: null image"); executed (the execution status of this line is deduced): QMessageLogger("image/qimage.cpp", 1831, __PRETTY_FUNCTION__).warning("QImage::setColorCount: null image"); | - |
1832 | return; executed: return; Execution Count:2 | 2 |
1833 | } | - |
1834 | | - |
1835 | detach(); executed (the execution status of this line is deduced): detach(); | - |
1836 | | - |
1837 | // In case detach() ran out of memory | - |
1838 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:2918 |
| 0-2918 |
1839 | return; | 0 |
1840 | | - |
1841 | if (colorCount == d->colortable.size()) evaluated: colorCount == d->colortable.size() yes Evaluation Count:204 | yes Evaluation Count:2714 |
| 204-2714 |
1842 | return; executed: return; Execution Count:204 | 204 |
1843 | if (colorCount <= 0) { // use no color table partially evaluated: colorCount <= 0 no Evaluation Count:0 | yes Evaluation Count:2714 |
| 0-2714 |
1844 | d->colortable = QVector<QRgb>(); never executed (the execution status of this line is deduced): d->colortable = QVector<QRgb>(); | - |
1845 | return; | 0 |
1846 | } | - |
1847 | int nc = d->colortable.size(); executed (the execution status of this line is deduced): int nc = d->colortable.size(); | - |
1848 | d->colortable.resize(colorCount); executed (the execution status of this line is deduced): d->colortable.resize(colorCount); | - |
1849 | for (int i = nc; i < colorCount; ++i) evaluated: i < colorCount yes Evaluation Count:95053 | yes Evaluation Count:2714 |
| 2714-95053 |
1850 | d->colortable[i] = 0; executed: d->colortable[i] = 0; Execution Count:95053 | 95053 |
1851 | } executed: } Execution Count:2714 | 2714 |
1852 | | - |
1853 | /*! | - |
1854 | Returns the format of the image. | - |
1855 | | - |
1856 | \sa {QImage#Image Formats}{Image Formats} | - |
1857 | */ | - |
1858 | QImage::Format QImage::format() const | - |
1859 | { | - |
1860 | return d ? d->format : Format_Invalid; executed: return d ? d->format : Format_Invalid; Execution Count:59710 | 59710 |
1861 | } | - |
1862 | | - |
1863 | | - |
1864 | | - |
1865 | /***************************************************************************** | - |
1866 | Internal routines for converting image depth. | - |
1867 | *****************************************************************************/ | - |
1868 | | - |
1869 | typedef void (*Image_Converter)(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); | - |
1870 | | - |
1871 | typedef bool (*InPlace_Image_Converter)(QImageData *data, Qt::ImageConversionFlags); | - |
1872 | | - |
1873 | static void convert_ARGB_to_ARGB_PM(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - |
1874 | { | - |
1875 | Q_ASSERT(src->format == QImage::Format_ARGB32); executed (the execution status of this line is deduced): qt_noop(); | - |
1876 | Q_ASSERT(dest->format == QImage::Format_ARGB32_Premultiplied); executed (the execution status of this line is deduced): qt_noop(); | - |
1877 | Q_ASSERT(src->width == dest->width); executed (the execution status of this line is deduced): qt_noop(); | - |
1878 | Q_ASSERT(src->height == dest->height); executed (the execution status of this line is deduced): qt_noop(); | - |
1879 | | - |
1880 | const int src_pad = (src->bytes_per_line >> 2) - src->width; executed (the execution status of this line is deduced): const int src_pad = (src->bytes_per_line >> 2) - src->width; | - |
1881 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; executed (the execution status of this line is deduced): const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - |
1882 | const QRgb *src_data = (QRgb *) src->data; executed (the execution status of this line is deduced): const QRgb *src_data = (QRgb *) src->data; | - |
1883 | QRgb *dest_data = (QRgb *) dest->data; executed (the execution status of this line is deduced): QRgb *dest_data = (QRgb *) dest->data; | - |
1884 | | - |
1885 | for (int i = 0; i < src->height; ++i) { evaluated: i < src->height yes Evaluation Count:208412 | yes Evaluation Count:190 |
| 190-208412 |
1886 | const QRgb *end = src_data + src->width; executed (the execution status of this line is deduced): const QRgb *end = src_data + src->width; | - |
1887 | while (src_data < end) { evaluated: src_data < end yes Evaluation Count:2611589 | yes Evaluation Count:208412 |
| 208412-2611589 |
1888 | *dest_data = PREMUL(*src_data); executed (the execution status of this line is deduced): *dest_data = PREMUL(*src_data); | - |
1889 | ++src_data; executed (the execution status of this line is deduced): ++src_data; | - |
1890 | ++dest_data; executed (the execution status of this line is deduced): ++dest_data; | - |
1891 | } executed: } Execution Count:2611589 | 2611589 |
1892 | src_data += src_pad; executed (the execution status of this line is deduced): src_data += src_pad; | - |
1893 | dest_data += dest_pad; executed (the execution status of this line is deduced): dest_data += dest_pad; | - |
1894 | } executed: } Execution Count:208412 | 208412 |
1895 | } executed: } Execution Count:190 | 190 |
1896 | | - |
1897 | static bool convert_ARGB_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversionFlags) | - |
1898 | { | - |
1899 | Q_ASSERT(data->format == QImage::Format_ARGB32); never executed (the execution status of this line is deduced): qt_noop(); | - |
1900 | | - |
1901 | const int pad = (data->bytes_per_line >> 2) - data->width; never executed (the execution status of this line is deduced): const int pad = (data->bytes_per_line >> 2) - data->width; | - |
1902 | QRgb *rgb_data = (QRgb *) data->data; never executed (the execution status of this line is deduced): QRgb *rgb_data = (QRgb *) data->data; | - |
1903 | | - |
1904 | for (int i = 0; i < data->height; ++i) { never evaluated: i < data->height | 0 |
1905 | const QRgb *end = rgb_data + data->width; never executed (the execution status of this line is deduced): const QRgb *end = rgb_data + data->width; | - |
1906 | while (rgb_data < end) { never evaluated: rgb_data < end | 0 |
1907 | *rgb_data = PREMUL(*rgb_data); never executed (the execution status of this line is deduced): *rgb_data = PREMUL(*rgb_data); | - |
1908 | ++rgb_data; never executed (the execution status of this line is deduced): ++rgb_data; | - |
1909 | } | 0 |
1910 | rgb_data += pad; never executed (the execution status of this line is deduced): rgb_data += pad; | - |
1911 | } | 0 |
1912 | data->format = QImage::Format_ARGB32_Premultiplied; never executed (the execution status of this line is deduced): data->format = QImage::Format_ARGB32_Premultiplied; | - |
1913 | return true; never executed: return true; | 0 |
1914 | } | - |
1915 | | - |
1916 | static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversionFlags) | - |
1917 | { | - |
1918 | Q_ASSERT(data->format == QImage::Format_Indexed8); executed (the execution status of this line is deduced): qt_noop(); | - |
1919 | const int depth = 32; executed (the execution status of this line is deduced): const int depth = 32; | - |
1920 | | - |
1921 | const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; executed (the execution status of this line is deduced): const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; | - |
1922 | const int nbytes = dst_bytes_per_line * data->height; executed (the execution status of this line is deduced): const int nbytes = dst_bytes_per_line * data->height; | - |
1923 | uchar *const newData = (uchar *)realloc(data->data, nbytes); executed (the execution status of this line is deduced): uchar *const newData = (uchar *)realloc(data->data, nbytes); | - |
1924 | if (!newData) partially evaluated: !newData no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1925 | return false; never executed: return false; | 0 |
1926 | | - |
1927 | data->data = newData; executed (the execution status of this line is deduced): data->data = newData; | - |
1928 | | - |
1929 | // start converting from the end because the end image is bigger than the source | - |
1930 | uchar *src_data = newData + data->nbytes; // end of src executed (the execution status of this line is deduced): uchar *src_data = newData + data->nbytes; | - |
1931 | quint32 *dest_data = (quint32 *) (newData + nbytes); // end of dest > end of src executed (the execution status of this line is deduced): quint32 *dest_data = (quint32 *) (newData + nbytes); | - |
1932 | const int width = data->width; executed (the execution status of this line is deduced): const int width = data->width; | - |
1933 | const int src_pad = data->bytes_per_line - width; executed (the execution status of this line is deduced): const int src_pad = data->bytes_per_line - width; | - |
1934 | const int dest_pad = (dst_bytes_per_line >> 2) - width; executed (the execution status of this line is deduced): const int dest_pad = (dst_bytes_per_line >> 2) - width; | - |
1935 | if (data->colortable.size() == 0) { partially evaluated: data->colortable.size() == 0 no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1936 | data->colortable.resize(256); never executed (the execution status of this line is deduced): data->colortable.resize(256); | - |
1937 | for (int i = 0; i < 256; ++i) | 0 |
1938 | data->colortable[i] = qRgb(i, i, i); never executed: data->colortable[i] = qRgb(i, i, i); | 0 |
1939 | } else { | 0 |
1940 | for (int i = 0; i < data->colortable.size(); ++i) evaluated: i < data->colortable.size() yes Evaluation Count:66 | yes Evaluation Count:2 |
| 2-66 |
1941 | data->colortable[i] = PREMUL(data->colortable.at(i)); executed: data->colortable[i] = PREMUL(data->colortable.at(i)); Execution Count:66 | 66 |
1942 | | - |
1943 | // Fill the rest of the table in case src_data > colortable.size() | - |
1944 | const int oldSize = data->colortable.size(); executed (the execution status of this line is deduced): const int oldSize = data->colortable.size(); | - |
1945 | const QRgb lastColor = data->colortable.at(oldSize - 1); executed (the execution status of this line is deduced): const QRgb lastColor = data->colortable.at(oldSize - 1); | - |
1946 | data->colortable.insert(oldSize, 256 - oldSize, lastColor); executed (the execution status of this line is deduced): data->colortable.insert(oldSize, 256 - oldSize, lastColor); | - |
1947 | } executed: } Execution Count:2 | 2 |
1948 | | - |
1949 | for (int i = 0; i < data->height; ++i) { evaluated: i < data->height yes Evaluation Count:256 | yes Evaluation Count:2 |
| 2-256 |
1950 | src_data -= src_pad; executed (the execution status of this line is deduced): src_data -= src_pad; | - |
1951 | dest_data -= dest_pad; executed (the execution status of this line is deduced): dest_data -= dest_pad; | - |
1952 | for (int pixI = 0; pixI < width; ++pixI) { evaluated: pixI < width yes Evaluation Count:32768 | yes Evaluation Count:256 |
| 256-32768 |
1953 | --src_data; executed (the execution status of this line is deduced): --src_data; | - |
1954 | --dest_data; executed (the execution status of this line is deduced): --dest_data; | - |
1955 | *dest_data = data->colortable.at(*src_data); executed (the execution status of this line is deduced): *dest_data = data->colortable.at(*src_data); | - |
1956 | } executed: } Execution Count:32768 | 32768 |
1957 | } executed: } Execution Count:256 | 256 |
1958 | | - |
1959 | data->colortable = QVector<QRgb>(); executed (the execution status of this line is deduced): data->colortable = QVector<QRgb>(); | - |
1960 | data->format = QImage::Format_ARGB32_Premultiplied; executed (the execution status of this line is deduced): data->format = QImage::Format_ARGB32_Premultiplied; | - |
1961 | data->bytes_per_line = dst_bytes_per_line; executed (the execution status of this line is deduced): data->bytes_per_line = dst_bytes_per_line; | - |
1962 | data->depth = depth; executed (the execution status of this line is deduced): data->depth = depth; | - |
1963 | data->nbytes = nbytes; executed (the execution status of this line is deduced): data->nbytes = nbytes; | - |
1964 | | - |
1965 | return true; executed: return true; Execution Count:2 | 2 |
1966 | } | - |
1967 | | - |
1968 | static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversionFlags) | - |
1969 | { | - |
1970 | Q_ASSERT(data->format == QImage::Format_Indexed8); never executed (the execution status of this line is deduced): qt_noop(); | - |
1971 | const int depth = 32; never executed (the execution status of this line is deduced): const int depth = 32; | - |
1972 | | - |
1973 | const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; never executed (the execution status of this line is deduced): const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; | - |
1974 | const int nbytes = dst_bytes_per_line * data->height; never executed (the execution status of this line is deduced): const int nbytes = dst_bytes_per_line * data->height; | - |
1975 | uchar *const newData = (uchar *)realloc(data->data, nbytes); never executed (the execution status of this line is deduced): uchar *const newData = (uchar *)realloc(data->data, nbytes); | - |
1976 | if (!newData) never evaluated: !newData | 0 |
1977 | return false; never executed: return false; | 0 |
1978 | | - |
1979 | data->data = newData; never executed (the execution status of this line is deduced): data->data = newData; | - |
1980 | | - |
1981 | // start converting from the end because the end image is bigger than the source | - |
1982 | uchar *src_data = newData + data->nbytes; never executed (the execution status of this line is deduced): uchar *src_data = newData + data->nbytes; | - |
1983 | quint32 *dest_data = (quint32 *) (newData + nbytes); never executed (the execution status of this line is deduced): quint32 *dest_data = (quint32 *) (newData + nbytes); | - |
1984 | const int width = data->width; never executed (the execution status of this line is deduced): const int width = data->width; | - |
1985 | const int src_pad = data->bytes_per_line - width; never executed (the execution status of this line is deduced): const int src_pad = data->bytes_per_line - width; | - |
1986 | const int dest_pad = (dst_bytes_per_line >> 2) - width; never executed (the execution status of this line is deduced): const int dest_pad = (dst_bytes_per_line >> 2) - width; | - |
1987 | if (data->colortable.size() == 0) { never evaluated: data->colortable.size() == 0 | 0 |
1988 | data->colortable.resize(256); never executed (the execution status of this line is deduced): data->colortable.resize(256); | - |
1989 | for (int i = 0; i < 256; ++i) | 0 |
1990 | data->colortable[i] = qRgb(i, i, i); never executed: data->colortable[i] = qRgb(i, i, i); | 0 |
1991 | } else { | 0 |
1992 | // Fill the rest of the table in case src_data > colortable.size() | - |
1993 | const int oldSize = data->colortable.size(); never executed (the execution status of this line is deduced): const int oldSize = data->colortable.size(); | - |
1994 | const QRgb lastColor = data->colortable.at(oldSize - 1); never executed (the execution status of this line is deduced): const QRgb lastColor = data->colortable.at(oldSize - 1); | - |
1995 | data->colortable.insert(oldSize, 256 - oldSize, lastColor); never executed (the execution status of this line is deduced): data->colortable.insert(oldSize, 256 - oldSize, lastColor); | - |
1996 | } | 0 |
1997 | | - |
1998 | for (int i = 0; i < data->height; ++i) { never evaluated: i < data->height | 0 |
1999 | src_data -= src_pad; never executed (the execution status of this line is deduced): src_data -= src_pad; | - |
2000 | dest_data -= dest_pad; never executed (the execution status of this line is deduced): dest_data -= dest_pad; | - |
2001 | for (int pixI = 0; pixI < width; ++pixI) { never evaluated: pixI < width | 0 |
2002 | --src_data; never executed (the execution status of this line is deduced): --src_data; | - |
2003 | --dest_data; never executed (the execution status of this line is deduced): --dest_data; | - |
2004 | *dest_data = (quint32) data->colortable.at(*src_data); never executed (the execution status of this line is deduced): *dest_data = (quint32) data->colortable.at(*src_data); | - |
2005 | } | 0 |
2006 | } | 0 |
2007 | | - |
2008 | data->colortable = QVector<QRgb>(); never executed (the execution status of this line is deduced): data->colortable = QVector<QRgb>(); | - |
2009 | data->format = QImage::Format_RGB32; never executed (the execution status of this line is deduced): data->format = QImage::Format_RGB32; | - |
2010 | data->bytes_per_line = dst_bytes_per_line; never executed (the execution status of this line is deduced): data->bytes_per_line = dst_bytes_per_line; | - |
2011 | data->depth = depth; never executed (the execution status of this line is deduced): data->depth = depth; | - |
2012 | data->nbytes = nbytes; never executed (the execution status of this line is deduced): data->nbytes = nbytes; | - |
2013 | | - |
2014 | return true; never executed: return true; | 0 |
2015 | } | - |
2016 | | - |
2017 | static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) | - |
2018 | { | - |
2019 | Q_ASSERT(data->format == QImage::Format_Indexed8); never executed (the execution status of this line is deduced): qt_noop(); | - |
2020 | const int depth = 16; never executed (the execution status of this line is deduced): const int depth = 16; | - |
2021 | | - |
2022 | const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; never executed (the execution status of this line is deduced): const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; | - |
2023 | const int nbytes = dst_bytes_per_line * data->height; never executed (the execution status of this line is deduced): const int nbytes = dst_bytes_per_line * data->height; | - |
2024 | uchar *const newData = (uchar *)realloc(data->data, nbytes); never executed (the execution status of this line is deduced): uchar *const newData = (uchar *)realloc(data->data, nbytes); | - |
2025 | if (!newData) never evaluated: !newData | 0 |
2026 | return false; never executed: return false; | 0 |
2027 | | - |
2028 | data->data = newData; never executed (the execution status of this line is deduced): data->data = newData; | - |
2029 | | - |
2030 | // start converting from the end because the end image is bigger than the source | - |
2031 | uchar *src_data = newData + data->nbytes; never executed (the execution status of this line is deduced): uchar *src_data = newData + data->nbytes; | - |
2032 | quint16 *dest_data = (quint16 *) (newData + nbytes); never executed (the execution status of this line is deduced): quint16 *dest_data = (quint16 *) (newData + nbytes); | - |
2033 | const int width = data->width; never executed (the execution status of this line is deduced): const int width = data->width; | - |
2034 | const int src_pad = data->bytes_per_line - width; never executed (the execution status of this line is deduced): const int src_pad = data->bytes_per_line - width; | - |
2035 | const int dest_pad = (dst_bytes_per_line >> 1) - width; never executed (the execution status of this line is deduced): const int dest_pad = (dst_bytes_per_line >> 1) - width; | - |
2036 | | - |
2037 | quint16 colorTableRGB16[256]; never executed (the execution status of this line is deduced): quint16 colorTableRGB16[256]; | - |
2038 | if (data->colortable.isEmpty()) { never evaluated: data->colortable.isEmpty() | 0 |
2039 | for (int i = 0; i < 256; ++i) | 0 |
2040 | colorTableRGB16[i] = qConvertRgb32To16(qRgb(i, i, i)); never executed: colorTableRGB16[i] = qConvertRgb32To16(qRgb(i, i, i)); | 0 |
2041 | } else { | 0 |
2042 | // 1) convert the existing colors to RGB16 | - |
2043 | const int tableSize = data->colortable.size(); never executed (the execution status of this line is deduced): const int tableSize = data->colortable.size(); | - |
2044 | for (int i = 0; i < tableSize; ++i) never evaluated: i < tableSize | 0 |
2045 | colorTableRGB16[i] = qConvertRgb32To16(data->colortable.at(i)); never executed: colorTableRGB16[i] = qConvertRgb32To16(data->colortable.at(i)); | 0 |
2046 | data->colortable = QVector<QRgb>(); never executed (the execution status of this line is deduced): data->colortable = QVector<QRgb>(); | - |
2047 | | - |
2048 | // 2) fill the rest of the table in case src_data > colortable.size() | - |
2049 | const quint16 lastColor = colorTableRGB16[tableSize - 1]; never executed (the execution status of this line is deduced): const quint16 lastColor = colorTableRGB16[tableSize - 1]; | - |
2050 | for (int i = tableSize; i < 256; ++i) | 0 |
2051 | colorTableRGB16[i] = lastColor; never executed: colorTableRGB16[i] = lastColor; | 0 |
2052 | } | 0 |
2053 | | - |
2054 | for (int i = 0; i < data->height; ++i) { never evaluated: i < data->height | 0 |
2055 | src_data -= src_pad; never executed (the execution status of this line is deduced): src_data -= src_pad; | - |
2056 | dest_data -= dest_pad; never executed (the execution status of this line is deduced): dest_data -= dest_pad; | - |
2057 | for (int pixI = 0; pixI < width; ++pixI) { never evaluated: pixI < width | 0 |
2058 | --src_data; never executed (the execution status of this line is deduced): --src_data; | - |
2059 | --dest_data; never executed (the execution status of this line is deduced): --dest_data; | - |
2060 | *dest_data = colorTableRGB16[*src_data]; never executed (the execution status of this line is deduced): *dest_data = colorTableRGB16[*src_data]; | - |
2061 | } | 0 |
2062 | } | 0 |
2063 | | - |
2064 | data->format = QImage::Format_RGB16; never executed (the execution status of this line is deduced): data->format = QImage::Format_RGB16; | - |
2065 | data->bytes_per_line = dst_bytes_per_line; never executed (the execution status of this line is deduced): data->bytes_per_line = dst_bytes_per_line; | - |
2066 | data->depth = depth; never executed (the execution status of this line is deduced): data->depth = depth; | - |
2067 | data->nbytes = nbytes; never executed (the execution status of this line is deduced): data->nbytes = nbytes; | - |
2068 | | - |
2069 | return true; never executed: return true; | 0 |
2070 | } | - |
2071 | | - |
2072 | static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) | - |
2073 | { | - |
2074 | Q_ASSERT(data->format == QImage::Format_RGB32); never executed (the execution status of this line is deduced): qt_noop(); | - |
2075 | const int depth = 16; never executed (the execution status of this line is deduced): const int depth = 16; | - |
2076 | | - |
2077 | const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; never executed (the execution status of this line is deduced): const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; | - |
2078 | const int src_bytes_per_line = data->bytes_per_line; never executed (the execution status of this line is deduced): const int src_bytes_per_line = data->bytes_per_line; | - |
2079 | quint32 *src_data = (quint32 *) data->data; never executed (the execution status of this line is deduced): quint32 *src_data = (quint32 *) data->data; | - |
2080 | quint16 *dst_data = (quint16 *) data->data; never executed (the execution status of this line is deduced): quint16 *dst_data = (quint16 *) data->data; | - |
2081 | | - |
2082 | for (int i = 0; i < data->height; ++i) { never evaluated: i < data->height | 0 |
2083 | for (int j = 0; j < data->width; ++j) never evaluated: j < data->width | 0 |
2084 | dst_data[j] = qConvertRgb32To16(src_data[j]); never executed: dst_data[j] = qConvertRgb32To16(src_data[j]); | 0 |
2085 | src_data = (quint32 *) (((char*)src_data) + src_bytes_per_line); never executed (the execution status of this line is deduced): src_data = (quint32 *) (((char*)src_data) + src_bytes_per_line); | - |
2086 | dst_data = (quint16 *) (((char*)dst_data) + dst_bytes_per_line); never executed (the execution status of this line is deduced): dst_data = (quint16 *) (((char*)dst_data) + dst_bytes_per_line); | - |
2087 | } | 0 |
2088 | data->format = QImage::Format_RGB16; never executed (the execution status of this line is deduced): data->format = QImage::Format_RGB16; | - |
2089 | data->bytes_per_line = dst_bytes_per_line; never executed (the execution status of this line is deduced): data->bytes_per_line = dst_bytes_per_line; | - |
2090 | data->depth = depth; never executed (the execution status of this line is deduced): data->depth = depth; | - |
2091 | data->nbytes = dst_bytes_per_line * data->height; never executed (the execution status of this line is deduced): data->nbytes = dst_bytes_per_line * data->height; | - |
2092 | uchar *const newData = (uchar *)realloc(data->data, data->nbytes); never executed (the execution status of this line is deduced): uchar *const newData = (uchar *)realloc(data->data, data->nbytes); | - |
2093 | if (newData) { | 0 |
2094 | data->data = newData; never executed (the execution status of this line is deduced): data->data = newData; | - |
2095 | return true; never executed: return true; | 0 |
2096 | } else { | - |
2097 | return false; never executed: return false; | 0 |
2098 | } | - |
2099 | } | - |
2100 | | - |
2101 | static void convert_ARGB_PM_to_ARGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - |
2102 | { | - |
2103 | Q_ASSERT(src->format == QImage::Format_ARGB32_Premultiplied); executed (the execution status of this line is deduced): qt_noop(); | - |
2104 | Q_ASSERT(dest->format == QImage::Format_ARGB32); executed (the execution status of this line is deduced): qt_noop(); | - |
2105 | Q_ASSERT(src->width == dest->width); executed (the execution status of this line is deduced): qt_noop(); | - |
2106 | Q_ASSERT(src->height == dest->height); executed (the execution status of this line is deduced): qt_noop(); | - |
2107 | | - |
2108 | const int src_pad = (src->bytes_per_line >> 2) - src->width; executed (the execution status of this line is deduced): const int src_pad = (src->bytes_per_line >> 2) - src->width; | - |
2109 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; executed (the execution status of this line is deduced): const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - |
2110 | const QRgb *src_data = (QRgb *) src->data; executed (the execution status of this line is deduced): const QRgb *src_data = (QRgb *) src->data; | - |
2111 | QRgb *dest_data = (QRgb *) dest->data; executed (the execution status of this line is deduced): QRgb *dest_data = (QRgb *) dest->data; | - |
2112 | | - |
2113 | for (int i = 0; i < src->height; ++i) { evaluated: i < src->height yes Evaluation Count:11438 | yes Evaluation Count:2255 |
| 2255-11438 |
2114 | const QRgb *end = src_data + src->width; executed (the execution status of this line is deduced): const QRgb *end = src_data + src->width; | - |
2115 | while (src_data < end) { evaluated: src_data < end yes Evaluation Count:2087894 | yes Evaluation Count:11438 |
| 11438-2087894 |
2116 | *dest_data = INV_PREMUL(*src_data); evaluated: qAlpha(*src_data) == 0 yes Evaluation Count:206750 | yes Evaluation Count:1881144 |
| 206750-1881144 |
2117 | ++src_data; executed (the execution status of this line is deduced): ++src_data; | - |
2118 | ++dest_data; executed (the execution status of this line is deduced): ++dest_data; | - |
2119 | } executed: } Execution Count:2087894 | 2087894 |
2120 | src_data += src_pad; executed (the execution status of this line is deduced): src_data += src_pad; | - |
2121 | dest_data += dest_pad; executed (the execution status of this line is deduced): dest_data += dest_pad; | - |
2122 | } executed: } Execution Count:11438 | 11438 |
2123 | } executed: } Execution Count:2255 | 2255 |
2124 | | - |
2125 | static void convert_ARGB_PM_to_RGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - |
2126 | { | - |
2127 | Q_ASSERT(src->format == QImage::Format_ARGB32_Premultiplied); executed (the execution status of this line is deduced): qt_noop(); | - |
2128 | Q_ASSERT(dest->format == QImage::Format_RGB32); executed (the execution status of this line is deduced): qt_noop(); | - |
2129 | Q_ASSERT(src->width == dest->width); executed (the execution status of this line is deduced): qt_noop(); | - |
2130 | Q_ASSERT(src->height == dest->height); executed (the execution status of this line is deduced): qt_noop(); | - |
2131 | | - |
2132 | const int src_pad = (src->bytes_per_line >> 2) - src->width; executed (the execution status of this line is deduced): const int src_pad = (src->bytes_per_line >> 2) - src->width; | - |
2133 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; executed (the execution status of this line is deduced): const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - |
2134 | const QRgb *src_data = (QRgb *) src->data; executed (the execution status of this line is deduced): const QRgb *src_data = (QRgb *) src->data; | - |
2135 | QRgb *dest_data = (QRgb *) dest->data; executed (the execution status of this line is deduced): QRgb *dest_data = (QRgb *) dest->data; | - |
2136 | | - |
2137 | for (int i = 0; i < src->height; ++i) { evaluated: i < src->height yes Evaluation Count:643 | yes Evaluation Count:16 |
| 16-643 |
2138 | const QRgb *end = src_data + src->width; executed (the execution status of this line is deduced): const QRgb *end = src_data + src->width; | - |
2139 | while (src_data < end) { evaluated: src_data < end yes Evaluation Count:40050 | yes Evaluation Count:643 |
| 643-40050 |
2140 | *dest_data = 0xff000000 | INV_PREMUL(*src_data); executed (the execution status of this line is deduced): *dest_data = 0xff000000 | (qAlpha(*src_data) == 0 ? 0 : ((qAlpha(*src_data) << 24) | (((255*qRed(*src_data))/ qAlpha(*src_data)) << 16) | (((255*qGreen(*src_data)) / qAlpha(*src_data)) << 8) | ((255*qBlue(*src_data)) / qAlpha(*src_data)))); | - |
2141 | ++src_data; executed (the execution status of this line is deduced): ++src_data; | - |
2142 | ++dest_data; executed (the execution status of this line is deduced): ++dest_data; | - |
2143 | } executed: } Execution Count:40050 | 40050 |
2144 | src_data += src_pad; executed (the execution status of this line is deduced): src_data += src_pad; | - |
2145 | dest_data += dest_pad; executed (the execution status of this line is deduced): dest_data += dest_pad; | - |
2146 | } executed: } Execution Count:643 | 643 |
2147 | } executed: } Execution Count:16 | 16 |
2148 | | - |
2149 | static void swap_bit_order(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - |
2150 | { | - |
2151 | Q_ASSERT(src->format == QImage::Format_Mono || src->format == QImage::Format_MonoLSB); executed (the execution status of this line is deduced): qt_noop(); | - |
2152 | Q_ASSERT(dest->format == QImage::Format_Mono || dest->format == QImage::Format_MonoLSB); executed (the execution status of this line is deduced): qt_noop(); | - |
2153 | Q_ASSERT(src->width == dest->width); executed (the execution status of this line is deduced): qt_noop(); | - |
2154 | Q_ASSERT(src->height == dest->height); executed (the execution status of this line is deduced): qt_noop(); | - |
2155 | Q_ASSERT(src->nbytes == dest->nbytes); executed (the execution status of this line is deduced): qt_noop(); | - |
2156 | Q_ASSERT(src->bytes_per_line == dest->bytes_per_line); executed (the execution status of this line is deduced): qt_noop(); | - |
2157 | | - |
2158 | dest->colortable = src->colortable; executed (the execution status of this line is deduced): dest->colortable = src->colortable; | - |
2159 | | - |
2160 | const uchar *src_data = src->data; executed (the execution status of this line is deduced): const uchar *src_data = src->data; | - |
2161 | const uchar *end = src->data + src->nbytes; executed (the execution status of this line is deduced): const uchar *end = src->data + src->nbytes; | - |
2162 | uchar *dest_data = dest->data; executed (the execution status of this line is deduced): uchar *dest_data = dest->data; | - |
2163 | while (src_data < end) { evaluated: src_data < end yes Evaluation Count:3712 | yes Evaluation Count:22 |
| 22-3712 |
2164 | *dest_data = bitflip[*src_data]; executed (the execution status of this line is deduced): *dest_data = bitflip[*src_data]; | - |
2165 | ++src_data; executed (the execution status of this line is deduced): ++src_data; | - |
2166 | ++dest_data; executed (the execution status of this line is deduced): ++dest_data; | - |
2167 | } executed: } Execution Count:3712 | 3712 |
2168 | } executed: } Execution Count:22 | 22 |
2169 | | - |
2170 | static void mask_alpha_converter(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - |
2171 | { | - |
2172 | Q_ASSERT(src->width == dest->width); executed (the execution status of this line is deduced): qt_noop(); | - |
2173 | Q_ASSERT(src->height == dest->height); executed (the execution status of this line is deduced): qt_noop(); | - |
2174 | | - |
2175 | const int src_pad = (src->bytes_per_line >> 2) - src->width; executed (the execution status of this line is deduced): const int src_pad = (src->bytes_per_line >> 2) - src->width; | - |
2176 | const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; executed (the execution status of this line is deduced): const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; | - |
2177 | const uint *src_data = (const uint *)src->data; executed (the execution status of this line is deduced): const uint *src_data = (const uint *)src->data; | - |
2178 | uint *dest_data = (uint *)dest->data; executed (the execution status of this line is deduced): uint *dest_data = (uint *)dest->data; | - |
2179 | | - |
2180 | for (int i = 0; i < src->height; ++i) { evaluated: i < src->height yes Evaluation Count:16495 | yes Evaluation Count:335 |
| 335-16495 |
2181 | const uint *end = src_data + src->width; executed (the execution status of this line is deduced): const uint *end = src_data + src->width; | - |
2182 | while (src_data < end) { evaluated: src_data < end yes Evaluation Count:2747612 | yes Evaluation Count:16495 |
| 16495-2747612 |
2183 | *dest_data = *src_data | 0xff000000; executed (the execution status of this line is deduced): *dest_data = *src_data | 0xff000000; | - |
2184 | ++src_data; executed (the execution status of this line is deduced): ++src_data; | - |
2185 | ++dest_data; executed (the execution status of this line is deduced): ++dest_data; | - |
2186 | } executed: } Execution Count:2747612 | 2747612 |
2187 | src_data += src_pad; executed (the execution status of this line is deduced): src_data += src_pad; | - |
2188 | dest_data += dest_pad; executed (the execution status of this line is deduced): dest_data += dest_pad; | - |
2189 | } executed: } Execution Count:16495 | 16495 |
2190 | } executed: } Execution Count:335 | 335 |
2191 | | - |
2192 | static QVector<QRgb> fix_color_table(const QVector<QRgb> &ctbl, QImage::Format format) | - |
2193 | { | - |
2194 | QVector<QRgb> colorTable = ctbl; executed (the execution status of this line is deduced): QVector<QRgb> colorTable = ctbl; | - |
2195 | if (format == QImage::Format_RGB32) { evaluated: format == QImage::Format_RGB32 yes Evaluation Count:161 | yes Evaluation Count:2394 |
| 161-2394 |
2196 | // check if the color table has alpha | - |
2197 | for (int i = 0; i < colorTable.size(); ++i) evaluated: i < colorTable.size() yes Evaluation Count:6294 | yes Evaluation Count:161 |
| 161-6294 |
2198 | if (qAlpha(colorTable.at(i) != 0xff)) partially evaluated: qAlpha(colorTable.at(i) != 0xff) no Evaluation Count:0 | yes Evaluation Count:6294 |
| 0-6294 |
2199 | colorTable[i] = colorTable.at(i) | 0xff000000; never executed: colorTable[i] = colorTable.at(i) | 0xff000000; | 0 |
2200 | } else if (format == QImage::Format_ARGB32_Premultiplied) { executed: } Execution Count:161 evaluated: format == QImage::Format_ARGB32_Premultiplied yes Evaluation Count:2375 | yes Evaluation Count:19 |
| 19-2375 |
2201 | // check if the color table has alpha | - |
2202 | for (int i = 0; i < colorTable.size(); ++i) evaluated: i < colorTable.size() yes Evaluation Count:35591 | yes Evaluation Count:2375 |
| 2375-35591 |
2203 | colorTable[i] = PREMUL(colorTable.at(i)); executed: colorTable[i] = PREMUL(colorTable.at(i)); Execution Count:35591 | 35591 |
2204 | } executed: } Execution Count:2375 | 2375 |
2205 | return colorTable; executed: return colorTable; Execution Count:2555 | 2555 |
2206 | } | - |
2207 | | - |
2208 | // | - |
2209 | // dither_to_1: Uses selected dithering algorithm. | - |
2210 | // | - |
2211 | | - |
2212 | static void dither_to_Mono(QImageData *dst, const QImageData *src, | - |
2213 | Qt::ImageConversionFlags flags, bool fromalpha) | - |
2214 | { | - |
2215 | Q_ASSERT(src->width == dst->width); executed (the execution status of this line is deduced): qt_noop(); | - |
2216 | Q_ASSERT(src->height == dst->height); executed (the execution status of this line is deduced): qt_noop(); | - |
2217 | Q_ASSERT(dst->format == QImage::Format_Mono || dst->format == QImage::Format_MonoLSB); executed (the execution status of this line is deduced): qt_noop(); | - |
2218 | | - |
2219 | dst->colortable.clear(); executed (the execution status of this line is deduced): dst->colortable.clear(); | - |
2220 | dst->colortable.append(0xffffffff); executed (the execution status of this line is deduced): dst->colortable.append(0xffffffff); | - |
2221 | dst->colortable.append(0xff000000); executed (the execution status of this line is deduced): dst->colortable.append(0xff000000); | - |
2222 | | - |
2223 | enum { Threshold, Ordered, Diffuse } dithermode; executed (the execution status of this line is deduced): enum { Threshold, Ordered, Diffuse } dithermode; | - |
2224 | | - |
2225 | if (fromalpha) { evaluated: fromalpha yes Evaluation Count:213 | yes Evaluation Count:311 |
| 213-311 |
2226 | if ((flags & Qt::AlphaDither_Mask) == Qt::DiffuseAlphaDither) partially evaluated: (flags & Qt::AlphaDither_Mask) == Qt::DiffuseAlphaDither no Evaluation Count:0 | yes Evaluation Count:213 |
| 0-213 |
2227 | dithermode = Diffuse; never executed: dithermode = Diffuse; | 0 |
2228 | else if ((flags & Qt::AlphaDither_Mask) == Qt::OrderedAlphaDither) evaluated: (flags & Qt::AlphaDither_Mask) == Qt::OrderedAlphaDither yes Evaluation Count:54 | yes Evaluation Count:159 |
| 54-159 |
2229 | dithermode = Ordered; executed: dithermode = Ordered; Execution Count:54 | 54 |
2230 | else | - |
2231 | dithermode = Threshold; executed: dithermode = Threshold; Execution Count:159 | 159 |
2232 | } else { | - |
2233 | if ((flags & Qt::Dither_Mask) == Qt::ThresholdDither) evaluated: (flags & Qt::Dither_Mask) == Qt::ThresholdDither yes Evaluation Count:54 | yes Evaluation Count:257 |
| 54-257 |
2234 | dithermode = Threshold; executed: dithermode = Threshold; Execution Count:54 | 54 |
2235 | else if ((flags & Qt::Dither_Mask) == Qt::OrderedDither) partially evaluated: (flags & Qt::Dither_Mask) == Qt::OrderedDither no Evaluation Count:0 | yes Evaluation Count:257 |
| 0-257 |
2236 | dithermode = Ordered; never executed: dithermode = Ordered; | 0 |
2237 | else | - |
2238 | dithermode = Diffuse; executed: dithermode = Diffuse; Execution Count:257 | 257 |
2239 | } | - |
2240 | | - |
2241 | int w = src->width; executed (the execution status of this line is deduced): int w = src->width; | - |
2242 | int h = src->height; executed (the execution status of this line is deduced): int h = src->height; | - |
2243 | int d = src->depth; executed (the execution status of this line is deduced): int d = src->depth; | - |
2244 | uchar gray[256]; // gray map for 8 bit images executed (the execution status of this line is deduced): uchar gray[256]; | - |
2245 | bool use_gray = (d == 8); executed (the execution status of this line is deduced): bool use_gray = (d == 8); | - |
2246 | if (use_gray) { // make gray map evaluated: use_gray yes Evaluation Count:160 | yes Evaluation Count:364 |
| 160-364 |
2247 | if (fromalpha) { evaluated: fromalpha yes Evaluation Count:103 | yes Evaluation Count:57 |
| 57-103 |
2248 | // Alpha 0x00 -> 0 pixels (white) | - |
2249 | // Alpha 0xFF -> 1 pixels (black) | - |
2250 | for (int i = 0; i < src->colortable.size(); i++) evaluated: i < src->colortable.size() yes Evaluation Count:206 | yes Evaluation Count:103 |
| 103-206 |
2251 | gray[i] = (255 - (src->colortable.at(i) >> 24)); executed: gray[i] = (255 - (src->colortable.at(i) >> 24)); Execution Count:206 | 206 |
2252 | } else { executed: } Execution Count:103 | 103 |
2253 | // Pixel 0x00 -> 1 pixels (black) | - |
2254 | // Pixel 0xFF -> 0 pixels (white) | - |
2255 | for (int i = 0; i < src->colortable.size(); i++) evaluated: i < src->colortable.size() yes Evaluation Count:13830 | yes Evaluation Count:57 |
| 57-13830 |
2256 | gray[i] = qGray(src->colortable.at(i)); executed: gray[i] = qGray(src->colortable.at(i)); Execution Count:13830 | 13830 |
2257 | } executed: } Execution Count:57 | 57 |
2258 | } | - |
2259 | | - |
2260 | uchar *dst_data = dst->data; executed (the execution status of this line is deduced): uchar *dst_data = dst->data; | - |
2261 | int dst_bpl = dst->bytes_per_line; executed (the execution status of this line is deduced): int dst_bpl = dst->bytes_per_line; | - |
2262 | const uchar *src_data = src->data; executed (the execution status of this line is deduced): const uchar *src_data = src->data; | - |
2263 | int src_bpl = src->bytes_per_line; executed (the execution status of this line is deduced): int src_bpl = src->bytes_per_line; | - |
2264 | | - |
2265 | switch (dithermode) { | - |
2266 | case Diffuse: { | - |
2267 | QScopedArrayPointer<int> lineBuffer(new int[w * 2]); executed (the execution status of this line is deduced): QScopedArrayPointer<int> lineBuffer(new int[w * 2]); | - |
2268 | int *line1 = lineBuffer.data(); executed (the execution status of this line is deduced): int *line1 = lineBuffer.data(); | - |
2269 | int *line2 = lineBuffer.data() + w; executed (the execution status of this line is deduced): int *line2 = lineBuffer.data() + w; | - |
2270 | int bmwidth = (w+7)/8; executed (the execution status of this line is deduced): int bmwidth = (w+7)/8; | - |
2271 | | - |
2272 | int *b1, *b2; executed (the execution status of this line is deduced): int *b1, *b2; | - |
2273 | int wbytes = w * (d/8); executed (the execution status of this line is deduced): int wbytes = w * (d/8); | - |
2274 | register const uchar *p = src->data; executed (the execution status of this line is deduced): register const uchar *p = src->data; | - |
2275 | const uchar *end = p + wbytes; executed (the execution status of this line is deduced): const uchar *end = p + wbytes; | - |
2276 | b2 = line2; executed (the execution status of this line is deduced): b2 = line2; | - |
2277 | if (use_gray) { // 8 bit image evaluated: use_gray yes Evaluation Count:3 | yes Evaluation Count:254 |
| 3-254 |
2278 | while (p < end) evaluated: p < end yes Evaluation Count:144 | yes Evaluation Count:3 |
| 3-144 |
2279 | *b2++ = gray[*p++]; executed: *b2++ = gray[*p++]; Execution Count:144 | 144 |
2280 | } else { // 32 bit image executed: } Execution Count:3 | 3 |
2281 | if (fromalpha) { partially evaluated: fromalpha no Evaluation Count:0 | yes Evaluation Count:254 |
| 0-254 |
2282 | while (p < end) { | 0 |
2283 | *b2++ = 255 - (*(uint*)p >> 24); never executed (the execution status of this line is deduced): *b2++ = 255 - (*(uint*)p >> 24); | - |
2284 | p += 4; never executed (the execution status of this line is deduced): p += 4; | - |
2285 | } | 0 |
2286 | } else { | 0 |
2287 | while (p < end) { evaluated: p < end yes Evaluation Count:8598 | yes Evaluation Count:254 |
| 254-8598 |
2288 | *b2++ = qGray(*(uint*)p); executed (the execution status of this line is deduced): *b2++ = qGray(*(uint*)p); | - |
2289 | p += 4; executed (the execution status of this line is deduced): p += 4; | - |
2290 | } executed: } Execution Count:8598 | 8598 |
2291 | } executed: } Execution Count:254 | 254 |
2292 | } | - |
2293 | for (int y=0; y<h; y++) { // for each scan line... evaluated: y<h yes Evaluation Count:8098 | yes Evaluation Count:257 |
| 257-8098 |
2294 | int *tmp = line1; line1 = line2; line2 = tmp; executed (the execution status of this line is deduced): int *tmp = line1; line1 = line2; line2 = tmp; | - |
2295 | bool not_last_line = y < h - 1; executed (the execution status of this line is deduced): bool not_last_line = y < h - 1; | - |
2296 | if (not_last_line) { // calc. grayvals for next line evaluated: not_last_line yes Evaluation Count:7841 | yes Evaluation Count:257 |
| 257-7841 |
2297 | p = src->data + (y+1)*src->bytes_per_line; executed (the execution status of this line is deduced): p = src->data + (y+1)*src->bytes_per_line; | - |
2298 | end = p + wbytes; executed (the execution status of this line is deduced): end = p + wbytes; | - |
2299 | b2 = line2; executed (the execution status of this line is deduced): b2 = line2; | - |
2300 | if (use_gray) { // 8 bit image evaluated: use_gray yes Evaluation Count:141 | yes Evaluation Count:7700 |
| 141-7700 |
2301 | while (p < end) evaluated: p < end yes Evaluation Count:9672 | yes Evaluation Count:141 |
| 141-9672 |
2302 | *b2++ = gray[*p++]; executed: *b2++ = gray[*p++]; Execution Count:9672 | 9672 |
2303 | } else { // 24 bit image executed: } Execution Count:141 | 141 |
2304 | if (fromalpha) { partially evaluated: fromalpha no Evaluation Count:0 | yes Evaluation Count:7700 |
| 0-7700 |
2305 | while (p < end) { | 0 |
2306 | *b2++ = 255 - (*(uint*)p >> 24); never executed (the execution status of this line is deduced): *b2++ = 255 - (*(uint*)p >> 24); | - |
2307 | p += 4; never executed (the execution status of this line is deduced): p += 4; | - |
2308 | } | 0 |
2309 | } else { | 0 |
2310 | while (p < end) { evaluated: p < end yes Evaluation Count:399630 | yes Evaluation Count:7700 |
| 7700-399630 |
2311 | *b2++ = qGray(*(uint*)p); executed (the execution status of this line is deduced): *b2++ = qGray(*(uint*)p); | - |
2312 | p += 4; executed (the execution status of this line is deduced): p += 4; | - |
2313 | } executed: } Execution Count:399630 | 399630 |
2314 | } executed: } Execution Count:7700 | 7700 |
2315 | } | - |
2316 | } | - |
2317 | | - |
2318 | int err; executed (the execution status of this line is deduced): int err; | - |
2319 | uchar *p = dst->data + y*dst->bytes_per_line; executed (the execution status of this line is deduced): uchar *p = dst->data + y*dst->bytes_per_line; | - |
2320 | memset(p, 0, bmwidth); executed (the execution status of this line is deduced): memset(p, 0, bmwidth); | - |
2321 | b1 = line1; executed (the execution status of this line is deduced): b1 = line1; | - |
2322 | b2 = line2; executed (the execution status of this line is deduced): b2 = line2; | - |
2323 | int bit = 7; executed (the execution status of this line is deduced): int bit = 7; | - |
2324 | for (int x=1; x<=w; x++) { evaluated: x<=w yes Evaluation Count:418044 | yes Evaluation Count:8098 |
| 8098-418044 |
2325 | if (*b1 < 128) { // black pixel evaluated: *b1 < 128 yes Evaluation Count:211576 | yes Evaluation Count:206468 |
| 206468-211576 |
2326 | err = *b1++; executed (the execution status of this line is deduced): err = *b1++; | - |
2327 | *p |= 1 << bit; executed (the execution status of this line is deduced): *p |= 1 << bit; | - |
2328 | } else { // white pixel executed: } Execution Count:211576 | 211576 |
2329 | err = *b1++ - 255; executed (the execution status of this line is deduced): err = *b1++ - 255; | - |
2330 | } executed: } Execution Count:206468 | 206468 |
2331 | if (bit == 0) { evaluated: bit == 0 yes Evaluation Count:50506 | yes Evaluation Count:367538 |
| 50506-367538 |
2332 | p++; executed (the execution status of this line is deduced): p++; | - |
2333 | bit = 7; executed (the execution status of this line is deduced): bit = 7; | - |
2334 | } else { executed: } Execution Count:50506 | 50506 |
2335 | bit--; executed (the execution status of this line is deduced): bit--; | - |
2336 | } executed: } Execution Count:367538 | 367538 |
2337 | if (x < w) evaluated: x < w yes Evaluation Count:409946 | yes Evaluation Count:8098 |
| 8098-409946 |
2338 | *b1 += (err*7)>>4; // spread error to right pixel executed: *b1 += (err*7)>>4; Execution Count:409946 | 409946 |
2339 | if (not_last_line) { evaluated: not_last_line yes Evaluation Count:409302 | yes Evaluation Count:8742 |
| 8742-409302 |
2340 | b2[0] += (err*5)>>4; // pixel below executed (the execution status of this line is deduced): b2[0] += (err*5)>>4; | - |
2341 | if (x > 1) evaluated: x > 1 yes Evaluation Count:401461 | yes Evaluation Count:7841 |
| 7841-401461 |
2342 | b2[-1] += (err*3)>>4; // pixel below left executed: b2[-1] += (err*3)>>4; Execution Count:401461 | 401461 |
2343 | if (x < w) evaluated: x < w yes Evaluation Count:401461 | yes Evaluation Count:7841 |
| 7841-401461 |
2344 | b2[1] += err>>4; // pixel below right executed: b2[1] += err>>4; Execution Count:401461 | 401461 |
2345 | } executed: } Execution Count:409302 | 409302 |
2346 | b2++; executed (the execution status of this line is deduced): b2++; | - |
2347 | } executed: } Execution Count:418044 | 418044 |
2348 | } executed: } Execution Count:8098 | 8098 |
2349 | } break; executed: break; Execution Count:257 | 257 |
2350 | case Ordered: { | - |
2351 | | - |
2352 | memset(dst->data, 0, dst->nbytes); executed (the execution status of this line is deduced): memset(dst->data, 0, dst->nbytes); | - |
2353 | if (d == 32) { partially evaluated: d == 32 yes Evaluation Count:54 | no Evaluation Count:0 |
| 0-54 |
2354 | for (int i=0; i<h; i++) { evaluated: i<h yes Evaluation Count:13770 | yes Evaluation Count:54 |
| 54-13770 |
2355 | const uint *p = (const uint *)src_data; executed (the execution status of this line is deduced): const uint *p = (const uint *)src_data; | - |
2356 | const uint *end = p + w; executed (the execution status of this line is deduced): const uint *end = p + w; | - |
2357 | uchar *m = dst_data; executed (the execution status of this line is deduced): uchar *m = dst_data; | - |
2358 | int bit = 7; executed (the execution status of this line is deduced): int bit = 7; | - |
2359 | int j = 0; executed (the execution status of this line is deduced): int j = 0; | - |
2360 | if (fromalpha) { partially evaluated: fromalpha yes Evaluation Count:13770 | no Evaluation Count:0 |
| 0-13770 |
2361 | while (p < end) { evaluated: p < end yes Evaluation Count:3511350 | yes Evaluation Count:13770 |
| 13770-3511350 |
2362 | if ((*p++ >> 24) >= qt_bayer_matrix[j++&15][i&15]) evaluated: (*p++ >> 24) >= qt_bayer_matrix[j++&15][i&15] yes Evaluation Count:1755684 | yes Evaluation Count:1755666 |
| 1755666-1755684 |
2363 | *m |= 1 << bit; executed: *m |= 1 << bit; Execution Count:1755684 | 1755684 |
2364 | if (bit == 0) { evaluated: bit == 0 yes Evaluation Count:426870 | yes Evaluation Count:3084480 |
| 426870-3084480 |
2365 | m++; executed (the execution status of this line is deduced): m++; | - |
2366 | bit = 7; executed (the execution status of this line is deduced): bit = 7; | - |
2367 | } else { executed: } Execution Count:426870 | 426870 |
2368 | bit--; executed (the execution status of this line is deduced): bit--; | - |
2369 | } executed: } Execution Count:3084480 | 3084480 |
2370 | } | - |
2371 | } else { executed: } Execution Count:13770 | 13770 |
2372 | while (p < end) { | 0 |
2373 | if ((uint)qGray(*p++) < qt_bayer_matrix[j++&15][i&15]) never evaluated: (uint)qGray(*p++) < qt_bayer_matrix[j++&15][i&15] | 0 |
2374 | *m |= 1 << bit; never executed: *m |= 1 << bit; | 0 |
2375 | if (bit == 0) { never evaluated: bit == 0 | 0 |
2376 | m++; never executed (the execution status of this line is deduced): m++; | - |
2377 | bit = 7; never executed (the execution status of this line is deduced): bit = 7; | - |
2378 | } else { | 0 |
2379 | bit--; never executed (the execution status of this line is deduced): bit--; | - |
2380 | } | 0 |
2381 | } | - |
2382 | } | 0 |
2383 | dst_data += dst_bpl; executed (the execution status of this line is deduced): dst_data += dst_bpl; | - |
2384 | src_data += src_bpl; executed (the execution status of this line is deduced): src_data += src_bpl; | - |
2385 | } executed: } Execution Count:13770 | 13770 |
2386 | } else executed: } Execution Count:54 | 54 |
2387 | /* (d == 8) */ { | - |
2388 | for (int i=0; i<h; i++) { | 0 |
2389 | const uchar *p = src_data; never executed (the execution status of this line is deduced): const uchar *p = src_data; | - |
2390 | const uchar *end = p + w; never executed (the execution status of this line is deduced): const uchar *end = p + w; | - |
2391 | uchar *m = dst_data; never executed (the execution status of this line is deduced): uchar *m = dst_data; | - |
2392 | int bit = 7; never executed (the execution status of this line is deduced): int bit = 7; | - |
2393 | int j = 0; never executed (the execution status of this line is deduced): int j = 0; | - |
2394 | while (p < end) { | 0 |
2395 | if ((uint)gray[*p++] < qt_bayer_matrix[j++&15][i&15]) never evaluated: (uint)gray[*p++] < qt_bayer_matrix[j++&15][i&15] | 0 |
2396 | *m |= 1 << bit; never executed: *m |= 1 << bit; | 0 |
2397 | if (bit == 0) { never evaluated: bit == 0 | 0 |
2398 | m++; never executed (the execution status of this line is deduced): m++; | - |
2399 | bit = 7; never executed (the execution status of this line is deduced): bit = 7; | - |
2400 | } else { | 0 |
2401 | bit--; never executed (the execution status of this line is deduced): bit--; | - |
2402 | } | 0 |
2403 | } | - |
2404 | dst_data += dst_bpl; never executed (the execution status of this line is deduced): dst_data += dst_bpl; | - |
2405 | src_data += src_bpl; never executed (the execution status of this line is deduced): src_data += src_bpl; | - |
2406 | } | 0 |
2407 | } | 0 |
2408 | } break; executed: break; Execution Count:54 | 54 |
2409 | default: { // Threshold: | - |
2410 | memset(dst->data, 0, dst->nbytes); executed (the execution status of this line is deduced): memset(dst->data, 0, dst->nbytes); | - |
2411 | if (d == 32) { evaluated: d == 32 yes Evaluation Count:56 | yes Evaluation Count:157 |
| 56-157 |
2412 | for (int i=0; i<h; i++) { evaluated: i<h yes Evaluation Count:932 | yes Evaluation Count:56 |
| 56-932 |
2413 | const uint *p = (const uint *)src_data; executed (the execution status of this line is deduced): const uint *p = (const uint *)src_data; | - |
2414 | const uint *end = p + w; executed (the execution status of this line is deduced): const uint *end = p + w; | - |
2415 | uchar *m = dst_data; executed (the execution status of this line is deduced): uchar *m = dst_data; | - |
2416 | int bit = 7; executed (the execution status of this line is deduced): int bit = 7; | - |
2417 | if (fromalpha) { partially evaluated: fromalpha yes Evaluation Count:932 | no Evaluation Count:0 |
| 0-932 |
2418 | while (p < end) { evaluated: p < end yes Evaluation Count:85892 | yes Evaluation Count:932 |
| 932-85892 |
2419 | if ((*p++ >> 24) >= 128) evaluated: (*p++ >> 24) >= 128 yes Evaluation Count:26928 | yes Evaluation Count:58964 |
| 26928-58964 |
2420 | *m |= 1 << bit; // Set mask "on" executed: *m |= 1 << bit; Execution Count:26928 | 26928 |
2421 | if (bit == 0) { evaluated: bit == 0 yes Evaluation Count:10604 | yes Evaluation Count:75288 |
| 10604-75288 |
2422 | m++; executed (the execution status of this line is deduced): m++; | - |
2423 | bit = 7; executed (the execution status of this line is deduced): bit = 7; | - |
2424 | } else { executed: } Execution Count:10604 | 10604 |
2425 | bit--; executed (the execution status of this line is deduced): bit--; | - |
2426 | } executed: } Execution Count:75288 | 75288 |
2427 | } | - |
2428 | } else { executed: } Execution Count:932 | 932 |
2429 | while (p < end) { | 0 |
2430 | if (qGray(*p++) < 128) never evaluated: qGray(*p++) < 128 | 0 |
2431 | *m |= 1 << bit; // Set pixel "black" never executed: *m |= 1 << bit; | 0 |
2432 | if (bit == 0) { never evaluated: bit == 0 | 0 |
2433 | m++; never executed (the execution status of this line is deduced): m++; | - |
2434 | bit = 7; never executed (the execution status of this line is deduced): bit = 7; | - |
2435 | } else { | 0 |
2436 | bit--; never executed (the execution status of this line is deduced): bit--; | - |
2437 | } | 0 |
2438 | } | - |
2439 | } | 0 |
2440 | dst_data += dst_bpl; executed (the execution status of this line is deduced): dst_data += dst_bpl; | - |
2441 | src_data += src_bpl; executed (the execution status of this line is deduced): src_data += src_bpl; | - |
2442 | } executed: } Execution Count:932 | 932 |
2443 | } else executed: } Execution Count:56 | 56 |
2444 | if (d == 8) { partially evaluated: d == 8 yes Evaluation Count:157 | no Evaluation Count:0 |
| 0-157 |
2445 | for (int i=0; i<h; i++) { evaluated: i<h yes Evaluation Count:805 | yes Evaluation Count:157 |
| 157-805 |
2446 | const uchar *p = src_data; executed (the execution status of this line is deduced): const uchar *p = src_data; | - |
2447 | const uchar *end = p + w; executed (the execution status of this line is deduced): const uchar *end = p + w; | - |
2448 | uchar *m = dst_data; executed (the execution status of this line is deduced): uchar *m = dst_data; | - |
2449 | int bit = 7; executed (the execution status of this line is deduced): int bit = 7; | - |
2450 | while (p < end) { evaluated: p < end yes Evaluation Count:12880 | yes Evaluation Count:805 |
| 805-12880 |
2451 | if (gray[*p++] < 128) evaluated: gray[*p++] < 128 yes Evaluation Count:4834 | yes Evaluation Count:8046 |
| 4834-8046 |
2452 | *m |= 1 << bit; // Set mask "on"/ pixel "black" executed: *m |= 1 << bit; Execution Count:4834 | 4834 |
2453 | if (bit == 0) { evaluated: bit == 0 yes Evaluation Count:1610 | yes Evaluation Count:11270 |
| 1610-11270 |
2454 | m++; executed (the execution status of this line is deduced): m++; | - |
2455 | bit = 7; executed (the execution status of this line is deduced): bit = 7; | - |
2456 | } else { executed: } Execution Count:1610 | 1610 |
2457 | bit--; executed (the execution status of this line is deduced): bit--; | - |
2458 | } executed: } Execution Count:11270 | 11270 |
2459 | } | - |
2460 | dst_data += dst_bpl; executed (the execution status of this line is deduced): dst_data += dst_bpl; | - |
2461 | src_data += src_bpl; executed (the execution status of this line is deduced): src_data += src_bpl; | - |
2462 | } executed: } Execution Count:805 | 805 |
2463 | } executed: } Execution Count:157 | 157 |
2464 | } | - |
2465 | } | - |
2466 | | - |
2467 | if (dst->format == QImage::Format_MonoLSB) { evaluated: dst->format == QImage::Format_MonoLSB yes Evaluation Count:347 | yes Evaluation Count:177 |
| 177-347 |
2468 | // need to swap bit order | - |
2469 | uchar *sl = dst->data; executed (the execution status of this line is deduced): uchar *sl = dst->data; | - |
2470 | int bpl = (dst->width + 7) * dst->depth / 8; executed (the execution status of this line is deduced): int bpl = (dst->width + 7) * dst->depth / 8; | - |
2471 | int pad = dst->bytes_per_line - bpl; executed (the execution status of this line is deduced): int pad = dst->bytes_per_line - bpl; | - |
2472 | for (int y=0; y<dst->height; ++y) { evaluated: y<dst->height yes Evaluation Count:18719 | yes Evaluation Count:347 |
| 347-18719 |
2473 | for (int x=0; x<bpl; ++x) { evaluated: x<bpl yes Evaluation Count:469208 | yes Evaluation Count:18719 |
| 18719-469208 |
2474 | *sl = bitflip[*sl]; executed (the execution status of this line is deduced): *sl = bitflip[*sl]; | - |
2475 | ++sl; executed (the execution status of this line is deduced): ++sl; | - |
2476 | } executed: } Execution Count:469208 | 469208 |
2477 | sl += pad; executed (the execution status of this line is deduced): sl += pad; | - |
2478 | } executed: } Execution Count:18719 | 18719 |
2479 | } executed: } Execution Count:347 | 347 |
2480 | } executed: } Execution Count:524 | 524 |
2481 | | - |
2482 | static void convert_X_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) | - |
2483 | { | - |
2484 | dither_to_Mono(dst, src, flags, false); executed (the execution status of this line is deduced): dither_to_Mono(dst, src, flags, false); | - |
2485 | } executed: } Execution Count:299 | 299 |
2486 | | - |
2487 | static void convert_ARGB_PM_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) | - |
2488 | { | - |
2489 | QScopedPointer<QImageData> tmp(QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32)); executed (the execution status of this line is deduced): QScopedPointer<QImageData> tmp(QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32)); | - |
2490 | convert_ARGB_PM_to_ARGB(tmp.data(), src, flags); executed (the execution status of this line is deduced): convert_ARGB_PM_to_ARGB(tmp.data(), src, flags); | - |
2491 | dither_to_Mono(dst, tmp.data(), flags, false); executed (the execution status of this line is deduced): dither_to_Mono(dst, tmp.data(), flags, false); | - |
2492 | } executed: } Execution Count:12 | 12 |
2493 | | - |
2494 | // | - |
2495 | // convert_32_to_8: Converts a 32 bits depth (true color) to an 8 bit | - |
2496 | // image with a colormap. If the 32 bit image has more than 256 colors, | - |
2497 | // we convert the red,green and blue bytes into a single byte encoded | - |
2498 | // as 6 shades of each of red, green and blue. | - |
2499 | // | - |
2500 | // if dithering is needed, only 1 color at most is available for alpha. | - |
2501 | // | - |
2502 | struct QRgbMap { | - |
2503 | inline QRgbMap() : used(0) { } executed: } Execution Count:113658 | 113658 |
2504 | uchar pix; | - |
2505 | uchar used; | - |
2506 | QRgb rgb; | - |
2507 | }; | - |
2508 | | - |
2509 | static void convert_RGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) | - |
2510 | { | - |
2511 | Q_ASSERT(src->format == QImage::Format_RGB32 || src->format == QImage::Format_ARGB32); executed (the execution status of this line is deduced): qt_noop(); | - |
2512 | Q_ASSERT(dst->format == QImage::Format_Indexed8); executed (the execution status of this line is deduced): qt_noop(); | - |
2513 | Q_ASSERT(src->width == dst->width); executed (the execution status of this line is deduced): qt_noop(); | - |
2514 | Q_ASSERT(src->height == dst->height); executed (the execution status of this line is deduced): qt_noop(); | - |
2515 | | - |
2516 | bool do_quant = (flags & Qt::DitherMode_Mask) == Qt::PreferDither partially evaluated: (flags & Qt::DitherMode_Mask) == Qt::PreferDither no Evaluation Count:0 | yes Evaluation Count:114 |
| 0-114 |
2517 | || src->format == QImage::Format_ARGB32; evaluated: src->format == QImage::Format_ARGB32 yes Evaluation Count:56 | yes Evaluation Count:58 |
| 56-58 |
2518 | uint alpha_mask = src->format == QImage::Format_RGB32 ? 0xff000000 : 0; evaluated: src->format == QImage::Format_RGB32 yes Evaluation Count:58 | yes Evaluation Count:56 |
| 56-58 |
2519 | | - |
2520 | const int tablesize = 997; // prime executed (the execution status of this line is deduced): const int tablesize = 997; | - |
2521 | QRgbMap table[tablesize]; executed (the execution status of this line is deduced): QRgbMap table[tablesize]; | - |
2522 | int pix=0; executed (the execution status of this line is deduced): int pix=0; | - |
2523 | | - |
2524 | if (!dst->colortable.isEmpty()) { partially evaluated: !dst->colortable.isEmpty() no Evaluation Count:0 | yes Evaluation Count:114 |
| 0-114 |
2525 | QVector<QRgb> ctbl = dst->colortable; never executed (the execution status of this line is deduced): QVector<QRgb> ctbl = dst->colortable; | - |
2526 | dst->colortable.resize(256); never executed (the execution status of this line is deduced): dst->colortable.resize(256); | - |
2527 | // Preload palette into table. | - |
2528 | // Almost same code as pixel insertion below | - |
2529 | for (int i = 0; i < dst->colortable.size(); ++i) { never evaluated: i < dst->colortable.size() | 0 |
2530 | // Find in table... | - |
2531 | QRgb p = ctbl.at(i) | alpha_mask; never executed (the execution status of this line is deduced): QRgb p = ctbl.at(i) | alpha_mask; | - |
2532 | int hash = p % tablesize; never executed (the execution status of this line is deduced): int hash = p % tablesize; | - |
2533 | for (;;) { never executed (the execution status of this line is deduced): for (;;) { | - |
2534 | if (table[hash].used) { never evaluated: table[hash].used | 0 |
2535 | if (table[hash].rgb == p) { never evaluated: table[hash].rgb == p | 0 |
2536 | // Found previous insertion - use it | - |
2537 | break; | 0 |
2538 | } else { | - |
2539 | // Keep searching... | - |
2540 | if (++hash == tablesize) hash = 0; never executed: hash = 0; never evaluated: ++hash == tablesize | 0 |
2541 | } | 0 |
2542 | } else { | - |
2543 | // Cannot be in table | - |
2544 | Q_ASSERT (pix != 256); // too many colors never executed (the execution status of this line is deduced): qt_noop(); | - |
2545 | // Insert into table at this unused position | - |
2546 | dst->colortable[pix] = p; never executed (the execution status of this line is deduced): dst->colortable[pix] = p; | - |
2547 | table[hash].pix = pix++; never executed (the execution status of this line is deduced): table[hash].pix = pix++; | - |
2548 | table[hash].rgb = p; never executed (the execution status of this line is deduced): table[hash].rgb = p; | - |
2549 | table[hash].used = 1; never executed (the execution status of this line is deduced): table[hash].used = 1; | - |
2550 | break; | 0 |
2551 | } | - |
2552 | } | - |
2553 | } | 0 |
2554 | } | 0 |
2555 | | - |
2556 | if ((flags & Qt::DitherMode_Mask) != Qt::PreferDither) { partially evaluated: (flags & Qt::DitherMode_Mask) != Qt::PreferDither yes Evaluation Count:114 | no Evaluation Count:0 |
| 0-114 |
2557 | dst->colortable.resize(256); executed (the execution status of this line is deduced): dst->colortable.resize(256); | - |
2558 | const uchar *src_data = src->data; executed (the execution status of this line is deduced): const uchar *src_data = src->data; | - |
2559 | uchar *dest_data = dst->data; executed (the execution status of this line is deduced): uchar *dest_data = dst->data; | - |
2560 | for (int y = 0; y < src->height; y++) { // check if <= 256 colors evaluated: y < src->height yes Evaluation Count:2087 | yes Evaluation Count:114 |
| 114-2087 |
2561 | const QRgb *s = (const QRgb *)src_data; executed (the execution status of this line is deduced): const QRgb *s = (const QRgb *)src_data; | - |
2562 | uchar *b = dest_data; executed (the execution status of this line is deduced): uchar *b = dest_data; | - |
2563 | for (int x = 0; x < src->width; ++x) { evaluated: x < src->width yes Evaluation Count:64740 | yes Evaluation Count:2087 |
| 2087-64740 |
2564 | QRgb p = s[x] | alpha_mask; executed (the execution status of this line is deduced): QRgb p = s[x] | alpha_mask; | - |
2565 | int hash = p % tablesize; executed (the execution status of this line is deduced): int hash = p % tablesize; | - |
2566 | for (;;) { executed (the execution status of this line is deduced): for (;;) { | - |
2567 | if (table[hash].used) { evaluated: table[hash].used yes Evaluation Count:64177 | yes Evaluation Count:641 |
| 641-64177 |
2568 | if (table[hash].rgb == (p)) { evaluated: table[hash].rgb == (p) yes Evaluation Count:64099 | yes Evaluation Count:78 |
| 78-64099 |
2569 | // Found previous insertion - use it | - |
2570 | break; executed: break; Execution Count:64099 | 64099 |
2571 | } else { | - |
2572 | // Keep searching... | - |
2573 | if (++hash == tablesize) hash = 0; never executed: hash = 0; partially evaluated: ++hash == tablesize no Evaluation Count:0 | yes Evaluation Count:78 |
| 0-78 |
2574 | } executed: } Execution Count:78 | 78 |
2575 | } else { | - |
2576 | // Cannot be in table | - |
2577 | if (pix == 256) { // too many colors evaluated: pix == 256 yes Evaluation Count:1 | yes Evaluation Count:640 |
| 1-640 |
2578 | do_quant = true; executed (the execution status of this line is deduced): do_quant = true; | - |
2579 | // Break right out | - |
2580 | x = src->width; executed (the execution status of this line is deduced): x = src->width; | - |
2581 | y = src->height; executed (the execution status of this line is deduced): y = src->height; | - |
2582 | } else { executed: } Execution Count:1 | 1 |
2583 | // Insert into table at this unused position | - |
2584 | dst->colortable[pix] = p; executed (the execution status of this line is deduced): dst->colortable[pix] = p; | - |
2585 | table[hash].pix = pix++; executed (the execution status of this line is deduced): table[hash].pix = pix++; | - |
2586 | table[hash].rgb = p; executed (the execution status of this line is deduced): table[hash].rgb = p; | - |
2587 | table[hash].used = 1; executed (the execution status of this line is deduced): table[hash].used = 1; | - |
2588 | } executed: } Execution Count:640 | 640 |
2589 | break; executed: break; Execution Count:641 | 641 |
2590 | } | - |
2591 | } | - |
2592 | *b++ = table[hash].pix; // May occur once incorrectly executed (the execution status of this line is deduced): *b++ = table[hash].pix; | - |
2593 | } executed: } Execution Count:64740 | 64740 |
2594 | src_data += src->bytes_per_line; executed (the execution status of this line is deduced): src_data += src->bytes_per_line; | - |
2595 | dest_data += dst->bytes_per_line; executed (the execution status of this line is deduced): dest_data += dst->bytes_per_line; | - |
2596 | } executed: } Execution Count:2087 | 2087 |
2597 | } executed: } Execution Count:114 | 114 |
2598 | int numColors = do_quant ? 256 : pix; evaluated: do_quant yes Evaluation Count:56 | yes Evaluation Count:58 |
| 56-58 |
2599 | | - |
2600 | dst->colortable.resize(numColors); executed (the execution status of this line is deduced): dst->colortable.resize(numColors); | - |
2601 | | - |
2602 | if (do_quant) { // quantization needed evaluated: do_quant yes Evaluation Count:56 | yes Evaluation Count:58 |
| 56-58 |
2603 | | - |
2604 | #define MAX_R 5 | - |
2605 | #define MAX_G 5 | - |
2606 | #define MAX_B 5 | - |
2607 | #define INDEXOF(r,g,b) (((r)*(MAX_G+1)+(g))*(MAX_B+1)+(b)) | - |
2608 | | - |
2609 | for (int rc=0; rc<=MAX_R; rc++) // build 6x6x6 color cube evaluated: rc<=5 yes Evaluation Count:336 | yes Evaluation Count:56 |
| 56-336 |
2610 | for (int gc=0; gc<=MAX_G; gc++) evaluated: gc<=5 yes Evaluation Count:2016 | yes Evaluation Count:336 |
| 336-2016 |
2611 | for (int bc=0; bc<=MAX_B; bc++) evaluated: bc<=5 yes Evaluation Count:12096 | yes Evaluation Count:2016 |
| 2016-12096 |
2612 | dst->colortable[INDEXOF(rc,gc,bc)] = 0xff000000 | qRgb(rc*255/MAX_R, gc*255/MAX_G, bc*255/MAX_B); executed: dst->colortable[(((rc)*(5 +1)+(gc))*(5 +1)+(bc))] = 0xff000000 | qRgb(rc*255/5, gc*255/5, bc*255/5); Execution Count:12096 | 12096 |
2613 | | - |
2614 | const uchar *src_data = src->data; executed (the execution status of this line is deduced): const uchar *src_data = src->data; | - |
2615 | uchar *dest_data = dst->data; executed (the execution status of this line is deduced): uchar *dest_data = dst->data; | - |
2616 | if ((flags & Qt::Dither_Mask) == Qt::ThresholdDither) { evaluated: (flags & Qt::Dither_Mask) == Qt::ThresholdDither yes Evaluation Count:54 | yes Evaluation Count:2 |
| 2-54 |
2617 | for (int y = 0; y < src->height; y++) { evaluated: y < src->height yes Evaluation Count:702 | yes Evaluation Count:54 |
| 54-702 |
2618 | const QRgb *p = (const QRgb *)src_data; executed (the execution status of this line is deduced): const QRgb *p = (const QRgb *)src_data; | - |
2619 | const QRgb *end = p + src->width; executed (the execution status of this line is deduced): const QRgb *end = p + src->width; | - |
2620 | uchar *b = dest_data; executed (the execution status of this line is deduced): uchar *b = dest_data; | - |
2621 | | - |
2622 | while (p < end) { evaluated: p < end yes Evaluation Count:11232 | yes Evaluation Count:702 |
| 702-11232 |
2623 | #define DITHER(p,m) ((uchar) ((p * (m) + 127) / 255)) | - |
2624 | *b++ = executed (the execution status of this line is deduced): *b++ = | - |
2625 | INDEXOF( executed (the execution status of this line is deduced): (((((uchar) ((qRed(*p) * (5) + 127) / 255)))*(5 +1)+(((uchar) ((qGreen(*p) * (5) + 127) / 255))))*(5 +1)+(((uchar) ((qBlue(*p) * (5) + 127) / 255)))); | - |
2626 | DITHER(qRed(*p), MAX_R), | - |
2627 | DITHER(qGreen(*p), MAX_G), | - |
2628 | DITHER(qBlue(*p), MAX_B) | - |
2629 | ); | - |
2630 | #undef DITHER | - |
2631 | p++; executed (the execution status of this line is deduced): p++; | - |
2632 | } executed: } Execution Count:11232 | 11232 |
2633 | src_data += src->bytes_per_line; executed (the execution status of this line is deduced): src_data += src->bytes_per_line; | - |
2634 | dest_data += dst->bytes_per_line; executed (the execution status of this line is deduced): dest_data += dst->bytes_per_line; | - |
2635 | } executed: } Execution Count:702 | 702 |
2636 | } else if ((flags & Qt::Dither_Mask) == Qt::DiffuseDither) { executed: } Execution Count:54 partially evaluated: (flags & Qt::Dither_Mask) == Qt::DiffuseDither yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-54 |
2637 | int* line1[3]; executed (the execution status of this line is deduced): int* line1[3]; | - |
2638 | int* line2[3]; executed (the execution status of this line is deduced): int* line2[3]; | - |
2639 | int* pv[3]; executed (the execution status of this line is deduced): int* pv[3]; | - |
2640 | QScopedArrayPointer<int> lineBuffer(new int[src->width * 9]); executed (the execution status of this line is deduced): QScopedArrayPointer<int> lineBuffer(new int[src->width * 9]); | - |
2641 | line1[0] = lineBuffer.data(); executed (the execution status of this line is deduced): line1[0] = lineBuffer.data(); | - |
2642 | line2[0] = lineBuffer.data() + src->width; executed (the execution status of this line is deduced): line2[0] = lineBuffer.data() + src->width; | - |
2643 | line1[1] = lineBuffer.data() + src->width * 2; executed (the execution status of this line is deduced): line1[1] = lineBuffer.data() + src->width * 2; | - |
2644 | line2[1] = lineBuffer.data() + src->width * 3; executed (the execution status of this line is deduced): line2[1] = lineBuffer.data() + src->width * 3; | - |
2645 | line1[2] = lineBuffer.data() + src->width * 4; executed (the execution status of this line is deduced): line1[2] = lineBuffer.data() + src->width * 4; | - |
2646 | line2[2] = lineBuffer.data() + src->width * 5; executed (the execution status of this line is deduced): line2[2] = lineBuffer.data() + src->width * 5; | - |
2647 | pv[0] = lineBuffer.data() + src->width * 6; executed (the execution status of this line is deduced): pv[0] = lineBuffer.data() + src->width * 6; | - |
2648 | pv[1] = lineBuffer.data() + src->width * 7; executed (the execution status of this line is deduced): pv[1] = lineBuffer.data() + src->width * 7; | - |
2649 | pv[2] = lineBuffer.data() + src->width * 8; executed (the execution status of this line is deduced): pv[2] = lineBuffer.data() + src->width * 8; | - |
2650 | | - |
2651 | int endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian); executed (the execution status of this line is deduced): int endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian); | - |
2652 | for (int y = 0; y < src->height; y++) { evaluated: y < src->height yes Evaluation Count:230 | yes Evaluation Count:2 |
| 2-230 |
2653 | const uchar* q = src_data; executed (the execution status of this line is deduced): const uchar* q = src_data; | - |
2654 | const uchar* q2 = y < src->height - 1 ? q + src->bytes_per_line : src->data; evaluated: y < src->height - 1 yes Evaluation Count:228 | yes Evaluation Count:2 |
| 2-228 |
2655 | uchar *b = dest_data; executed (the execution status of this line is deduced): uchar *b = dest_data; | - |
2656 | for (int chan = 0; chan < 3; chan++) { evaluated: chan < 3 yes Evaluation Count:690 | yes Evaluation Count:230 |
| 230-690 |
2657 | int *l1 = (y&1) ? line2[chan] : line1[chan]; evaluated: (y&1) yes Evaluation Count:345 | yes Evaluation Count:345 |
| 345 |
2658 | int *l2 = (y&1) ? line1[chan] : line2[chan]; evaluated: (y&1) yes Evaluation Count:345 | yes Evaluation Count:345 |
| 345 |
2659 | if (y == 0) { evaluated: y == 0 yes Evaluation Count:6 | yes Evaluation Count:684 |
| 6-684 |
2660 | for (int i = 0; i < src->width; i++) evaluated: i < src->width yes Evaluation Count:1518 | yes Evaluation Count:6 |
| 6-1518 |
2661 | l1[i] = q[i*4+chan+endian]; executed: l1[i] = q[i*4+chan+endian]; Execution Count:1518 | 1518 |
2662 | } executed: } Execution Count:6 | 6 |
2663 | if (y+1 < src->height) { evaluated: y+1 < src->height yes Evaluation Count:684 | yes Evaluation Count:6 |
| 6-684 |
2664 | for (int i = 0; i < src->width; i++) evaluated: i < src->width yes Evaluation Count:222462 | yes Evaluation Count:684 |
| 684-222462 |
2665 | l2[i] = q2[i*4+chan+endian]; executed: l2[i] = q2[i*4+chan+endian]; Execution Count:222462 | 222462 |
2666 | } executed: } Execution Count:684 | 684 |
2667 | // Bi-directional error diffusion | - |
2668 | if (y&1) { evaluated: y&1 yes Evaluation Count:345 | yes Evaluation Count:345 |
| 345 |
2669 | for (int x = 0; x < src->width; x++) { evaluated: x < src->width yes Evaluation Count:111990 | yes Evaluation Count:345 |
| 345-111990 |
2670 | int pix = qMax(qMin(5, (l1[x] * 5 + 128)/ 255), 0); executed (the execution status of this line is deduced): int pix = qMax(qMin(5, (l1[x] * 5 + 128)/ 255), 0); | - |
2671 | int err = l1[x] - pix * 255 / 5; executed (the execution status of this line is deduced): int err = l1[x] - pix * 255 / 5; | - |
2672 | pv[chan][x] = pix; executed (the execution status of this line is deduced): pv[chan][x] = pix; | - |
2673 | | - |
2674 | // Spread the error around... | - |
2675 | if (x + 1< src->width) { evaluated: x + 1< src->width yes Evaluation Count:111645 | yes Evaluation Count:345 |
| 345-111645 |
2676 | l1[x+1] += (err*7)>>4; executed (the execution status of this line is deduced): l1[x+1] += (err*7)>>4; | - |
2677 | l2[x+1] += err>>4; executed (the execution status of this line is deduced): l2[x+1] += err>>4; | - |
2678 | } executed: } Execution Count:111645 | 111645 |
2679 | l2[x]+=(err*5)>>4; executed (the execution status of this line is deduced): l2[x]+=(err*5)>>4; | - |
2680 | if (x>1) evaluated: x>1 yes Evaluation Count:111300 | yes Evaluation Count:690 |
| 690-111300 |
2681 | l2[x-1]+=(err*3)>>4; executed: l2[x-1]+=(err*3)>>4; Execution Count:111300 | 111300 |
2682 | } executed: } Execution Count:111990 | 111990 |
2683 | } else { executed: } Execution Count:345 | 345 |
2684 | for (int x = src->width; x-- > 0;) { evaluated: x-- > 0 yes Evaluation Count:111990 | yes Evaluation Count:345 |
| 345-111990 |
2685 | int pix = qMax(qMin(5, (l1[x] * 5 + 128)/ 255), 0); executed (the execution status of this line is deduced): int pix = qMax(qMin(5, (l1[x] * 5 + 128)/ 255), 0); | - |
2686 | int err = l1[x] - pix * 255 / 5; executed (the execution status of this line is deduced): int err = l1[x] - pix * 255 / 5; | - |
2687 | pv[chan][x] = pix; executed (the execution status of this line is deduced): pv[chan][x] = pix; | - |
2688 | | - |
2689 | // Spread the error around... | - |
2690 | if (x > 0) { evaluated: x > 0 yes Evaluation Count:111645 | yes Evaluation Count:345 |
| 345-111645 |
2691 | l1[x-1] += (err*7)>>4; executed (the execution status of this line is deduced): l1[x-1] += (err*7)>>4; | - |
2692 | l2[x-1] += err>>4; executed (the execution status of this line is deduced): l2[x-1] += err>>4; | - |
2693 | } executed: } Execution Count:111645 | 111645 |
2694 | l2[x]+=(err*5)>>4; executed (the execution status of this line is deduced): l2[x]+=(err*5)>>4; | - |
2695 | if (x + 1 < src->width) evaluated: x + 1 < src->width yes Evaluation Count:111645 | yes Evaluation Count:345 |
| 345-111645 |
2696 | l2[x+1]+=(err*3)>>4; executed: l2[x+1]+=(err*3)>>4; Execution Count:111645 | 111645 |
2697 | } executed: } Execution Count:111990 | 111990 |
2698 | } executed: } Execution Count:345 | 345 |
2699 | } | - |
2700 | if (endian) { partially evaluated: endian no Evaluation Count:0 | yes Evaluation Count:230 |
| 0-230 |
2701 | for (int x = 0; x < src->width; x++) { never evaluated: x < src->width | 0 |
2702 | *b++ = INDEXOF(pv[0][x],pv[1][x],pv[2][x]); never executed (the execution status of this line is deduced): *b++ = (((pv[0][x])*(5 +1)+(pv[1][x]))*(5 +1)+(pv[2][x])); | - |
2703 | } | 0 |
2704 | } else { | 0 |
2705 | for (int x = 0; x < src->width; x++) { evaluated: x < src->width yes Evaluation Count:74660 | yes Evaluation Count:230 |
| 230-74660 |
2706 | *b++ = INDEXOF(pv[2][x],pv[1][x],pv[0][x]); executed (the execution status of this line is deduced): *b++ = (((pv[2][x])*(5 +1)+(pv[1][x]))*(5 +1)+(pv[0][x])); | - |
2707 | } executed: } Execution Count:74660 | 74660 |
2708 | } executed: } Execution Count:230 | 230 |
2709 | src_data += src->bytes_per_line; executed (the execution status of this line is deduced): src_data += src->bytes_per_line; | - |
2710 | dest_data += dst->bytes_per_line; executed (the execution status of this line is deduced): dest_data += dst->bytes_per_line; | - |
2711 | } executed: } Execution Count:230 | 230 |
2712 | } else { // OrderedDither executed: } Execution Count:2 | 2 |
2713 | for (int y = 0; y < src->height; y++) { never evaluated: y < src->height | 0 |
2714 | const QRgb *p = (const QRgb *)src_data; never executed (the execution status of this line is deduced): const QRgb *p = (const QRgb *)src_data; | - |
2715 | const QRgb *end = p + src->width; never executed (the execution status of this line is deduced): const QRgb *end = p + src->width; | - |
2716 | uchar *b = dest_data; never executed (the execution status of this line is deduced): uchar *b = dest_data; | - |
2717 | | - |
2718 | int x = 0; never executed (the execution status of this line is deduced): int x = 0; | - |
2719 | while (p < end) { | 0 |
2720 | uint d = qt_bayer_matrix[y & 15][x & 15] << 8; never executed (the execution status of this line is deduced): uint d = qt_bayer_matrix[y & 15][x & 15] << 8; | - |
2721 | | - |
2722 | #define DITHER(p, d, m) ((uchar) ((((256 * (m) + (m) + 1)) * (p) + (d)) >> 16)) | - |
2723 | *b++ = never executed (the execution status of this line is deduced): *b++ = | - |
2724 | INDEXOF( never executed (the execution status of this line is deduced): (((((uchar) ((((256 * (5) + (5) + 1)) * (qRed(*p)) + (d)) >> 16)))*(5 +1)+(((uchar) ((((256 * (5) + (5) + 1)) * (qGreen(*p)) + (d)) >> 16))))*(5 +1)+(((uchar) ((((256 * (5) + (5) + 1)) * (qBlue(*p)) + (d)) >> 16)))); | - |
2725 | DITHER(qRed(*p), d, MAX_R), | - |
2726 | DITHER(qGreen(*p), d, MAX_G), | - |
2727 | DITHER(qBlue(*p), d, MAX_B) | - |
2728 | ); | - |
2729 | #undef DITHER | - |
2730 | | - |
2731 | p++; never executed (the execution status of this line is deduced): p++; | - |
2732 | x++; never executed (the execution status of this line is deduced): x++; | - |
2733 | } | 0 |
2734 | src_data += src->bytes_per_line; never executed (the execution status of this line is deduced): src_data += src->bytes_per_line; | - |
2735 | dest_data += dst->bytes_per_line; never executed (the execution status of this line is deduced): dest_data += dst->bytes_per_line; | - |
2736 | } | 0 |
2737 | } | 0 |
2738 | | - |
2739 | if (src->format != QImage::Format_RGB32 partially evaluated: src->format != QImage::Format_RGB32 yes Evaluation Count:56 | no Evaluation Count:0 |
| 0-56 |
2740 | && src->format != QImage::Format_RGB16) { partially evaluated: src->format != QImage::Format_RGB16 yes Evaluation Count:56 | no Evaluation Count:0 |
| 0-56 |
2741 | const int trans = 216; executed (the execution status of this line is deduced): const int trans = 216; | - |
2742 | Q_ASSERT(dst->colortable.size() > trans); executed (the execution status of this line is deduced): qt_noop(); | - |
2743 | dst->colortable[trans] = 0; executed (the execution status of this line is deduced): dst->colortable[trans] = 0; | - |
2744 | QScopedPointer<QImageData> mask(QImageData::create(QSize(src->width, src->height), QImage::Format_Mono)); executed (the execution status of this line is deduced): QScopedPointer<QImageData> mask(QImageData::create(QSize(src->width, src->height), QImage::Format_Mono)); | - |
2745 | dither_to_Mono(mask.data(), src, flags, true); executed (the execution status of this line is deduced): dither_to_Mono(mask.data(), src, flags, true); | - |
2746 | uchar *dst_data = dst->data; executed (the execution status of this line is deduced): uchar *dst_data = dst->data; | - |
2747 | const uchar *mask_data = mask->data; executed (the execution status of this line is deduced): const uchar *mask_data = mask->data; | - |
2748 | for (int y = 0; y < src->height; y++) { evaluated: y < src->height yes Evaluation Count:932 | yes Evaluation Count:56 |
| 56-932 |
2749 | for (int x = 0; x < src->width ; x++) { evaluated: x < src->width yes Evaluation Count:85892 | yes Evaluation Count:932 |
| 932-85892 |
2750 | if (!(mask_data[x>>3] & (0x80 >> (x & 7)))) evaluated: !(mask_data[x>>3] & (0x80 >> (x & 7))) yes Evaluation Count:58964 | yes Evaluation Count:26928 |
| 26928-58964 |
2751 | dst_data[x] = trans; executed: dst_data[x] = trans; Execution Count:58964 | 58964 |
2752 | } executed: } Execution Count:85892 | 85892 |
2753 | mask_data += mask->bytes_per_line; executed (the execution status of this line is deduced): mask_data += mask->bytes_per_line; | - |
2754 | dst_data += dst->bytes_per_line; executed (the execution status of this line is deduced): dst_data += dst->bytes_per_line; | - |
2755 | } executed: } Execution Count:932 | 932 |
2756 | dst->has_alpha_clut = true; executed (the execution status of this line is deduced): dst->has_alpha_clut = true; | - |
2757 | } executed: } Execution Count:56 | 56 |
2758 | | - |
2759 | #undef MAX_R | - |
2760 | #undef MAX_G | - |
2761 | #undef MAX_B | - |
2762 | #undef INDEXOF | - |
2763 | | - |
2764 | } executed: } Execution Count:56 | 56 |
2765 | } executed: } Execution Count:114 | 114 |
2766 | | - |
2767 | static void convert_ARGB_PM_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) | - |
2768 | { | - |
2769 | QScopedPointer<QImageData> tmp(QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32)); executed (the execution status of this line is deduced): QScopedPointer<QImageData> tmp(QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32)); | - |
2770 | convert_ARGB_PM_to_ARGB(tmp.data(), src, flags); executed (the execution status of this line is deduced): convert_ARGB_PM_to_ARGB(tmp.data(), src, flags); | - |
2771 | convert_RGB_to_Indexed8(dst, tmp.data(), flags); executed (the execution status of this line is deduced): convert_RGB_to_Indexed8(dst, tmp.data(), flags); | - |
2772 | } executed: } Execution Count:54 | 54 |
2773 | | - |
2774 | static void convert_ARGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) | - |
2775 | { | - |
2776 | convert_RGB_to_Indexed8(dst, src, flags); executed (the execution status of this line is deduced): convert_RGB_to_Indexed8(dst, src, flags); | - |
2777 | } executed: } Execution Count:2 | 2 |
2778 | | - |
2779 | static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - |
2780 | { | - |
2781 | Q_ASSERT(src->format == QImage::Format_Indexed8); executed (the execution status of this line is deduced): qt_noop(); | - |
2782 | Q_ASSERT(dest->format == QImage::Format_RGB32 executed (the execution status of this line is deduced): qt_noop(); | - |
2783 | || dest->format == QImage::Format_ARGB32 | - |
2784 | || dest->format == QImage::Format_ARGB32_Premultiplied); | - |
2785 | Q_ASSERT(src->width == dest->width); executed (the execution status of this line is deduced): qt_noop(); | - |
2786 | Q_ASSERT(src->height == dest->height); executed (the execution status of this line is deduced): qt_noop(); | - |
2787 | | - |
2788 | QVector<QRgb> colorTable = fix_color_table(src->colortable, dest->format); executed (the execution status of this line is deduced): QVector<QRgb> colorTable = fix_color_table(src->colortable, dest->format); | - |
2789 | if (colorTable.size() == 0) { evaluated: colorTable.size() == 0 yes Evaluation Count:1 | yes Evaluation Count:2282 |
| 1-2282 |
2790 | colorTable.resize(256); executed (the execution status of this line is deduced): colorTable.resize(256); | - |
2791 | for (int i=0; i<256; ++i) evaluated: i<256 yes Evaluation Count:256 | yes Evaluation Count:1 |
| 1-256 |
2792 | colorTable[i] = qRgb(i, i, i); executed: colorTable[i] = qRgb(i, i, i); Execution Count:256 | 256 |
2793 | } executed: } Execution Count:1 | 1 |
2794 | | - |
2795 | int w = src->width; executed (the execution status of this line is deduced): int w = src->width; | - |
2796 | const uchar *src_data = src->data; executed (the execution status of this line is deduced): const uchar *src_data = src->data; | - |
2797 | uchar *dest_data = dest->data; executed (the execution status of this line is deduced): uchar *dest_data = dest->data; | - |
2798 | int tableSize = colorTable.size() - 1; executed (the execution status of this line is deduced): int tableSize = colorTable.size() - 1; | - |
2799 | for (int y = 0; y < src->height; y++) { evaluated: y < src->height yes Evaluation Count:33840 | yes Evaluation Count:2283 |
| 2283-33840 |
2800 | uint *p = (uint *)dest_data; executed (the execution status of this line is deduced): uint *p = (uint *)dest_data; | - |
2801 | const uchar *b = src_data; executed (the execution status of this line is deduced): const uchar *b = src_data; | - |
2802 | uint *end = p + w; executed (the execution status of this line is deduced): uint *end = p + w; | - |
2803 | | - |
2804 | while (p < end) evaluated: p < end yes Evaluation Count:2057689 | yes Evaluation Count:33840 |
| 33840-2057689 |
2805 | *p++ = colorTable.at(qMin<int>(tableSize, *b++)); executed: *p++ = colorTable.at(qMin<int>(tableSize, *b++)); Execution Count:2057689 | 2057689 |
2806 | | - |
2807 | src_data += src->bytes_per_line; executed (the execution status of this line is deduced): src_data += src->bytes_per_line; | - |
2808 | dest_data += dest->bytes_per_line; executed (the execution status of this line is deduced): dest_data += dest->bytes_per_line; | - |
2809 | } executed: } Execution Count:33840 | 33840 |
2810 | } executed: } Execution Count:2283 | 2283 |
2811 | | - |
2812 | static void convert_Mono_to_X32(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - |
2813 | { | - |
2814 | Q_ASSERT(src->format == QImage::Format_Mono || src->format == QImage::Format_MonoLSB); executed (the execution status of this line is deduced): qt_noop(); | - |
2815 | Q_ASSERT(dest->format == QImage::Format_RGB32 executed (the execution status of this line is deduced): qt_noop(); | - |
2816 | || dest->format == QImage::Format_ARGB32 | - |
2817 | || dest->format == QImage::Format_ARGB32_Premultiplied); | - |
2818 | Q_ASSERT(src->width == dest->width); executed (the execution status of this line is deduced): qt_noop(); | - |
2819 | Q_ASSERT(src->height == dest->height); executed (the execution status of this line is deduced): qt_noop(); | - |
2820 | | - |
2821 | QVector<QRgb> colorTable = fix_color_table(src->colortable, dest->format); executed (the execution status of this line is deduced): QVector<QRgb> colorTable = fix_color_table(src->colortable, dest->format); | - |
2822 | | - |
2823 | // Default to black / white colors | - |
2824 | if (colorTable.size() < 2) { partially evaluated: colorTable.size() < 2 no Evaluation Count:0 | yes Evaluation Count:272 |
| 0-272 |
2825 | if (colorTable.size() == 0) never evaluated: colorTable.size() == 0 | 0 |
2826 | colorTable << 0xff000000; never executed: colorTable << 0xff000000; | 0 |
2827 | colorTable << 0xffffffff; never executed (the execution status of this line is deduced): colorTable << 0xffffffff; | - |
2828 | } | 0 |
2829 | | - |
2830 | const uchar *src_data = src->data; executed (the execution status of this line is deduced): const uchar *src_data = src->data; | - |
2831 | uchar *dest_data = dest->data; executed (the execution status of this line is deduced): uchar *dest_data = dest->data; | - |
2832 | if (src->format == QImage::Format_Mono) { evaluated: src->format == QImage::Format_Mono yes Evaluation Count:137 | yes Evaluation Count:135 |
| 135-137 |
2833 | for (int y = 0; y < dest->height; y++) { evaluated: y < dest->height yes Evaluation Count:1038 | yes Evaluation Count:137 |
| 137-1038 |
2834 | register uint *p = (uint *)dest_data; executed (the execution status of this line is deduced): register uint *p = (uint *)dest_data; | - |
2835 | for (int x = 0; x < dest->width; x++) evaluated: x < dest->width yes Evaluation Count:231397 | yes Evaluation Count:1038 |
| 1038-231397 |
2836 | *p++ = colorTable.at((src_data[x>>3] >> (7 - (x & 7))) & 1); executed: *p++ = colorTable.at((src_data[x>>3] >> (7 - (x & 7))) & 1); Execution Count:231397 | 231397 |
2837 | | - |
2838 | src_data += src->bytes_per_line; executed (the execution status of this line is deduced): src_data += src->bytes_per_line; | - |
2839 | dest_data += dest->bytes_per_line; executed (the execution status of this line is deduced): dest_data += dest->bytes_per_line; | - |
2840 | } executed: } Execution Count:1038 | 1038 |
2841 | } else { executed: } Execution Count:137 | 137 |
2842 | for (int y = 0; y < dest->height; y++) { evaluated: y < dest->height yes Evaluation Count:2190 | yes Evaluation Count:135 |
| 135-2190 |
2843 | register uint *p = (uint *)dest_data; executed (the execution status of this line is deduced): register uint *p = (uint *)dest_data; | - |
2844 | for (int x = 0; x < dest->width; x++) evaluated: x < dest->width yes Evaluation Count:630537 | yes Evaluation Count:2190 |
| 2190-630537 |
2845 | *p++ = colorTable.at((src_data[x>>3] >> (x & 7)) & 1); executed: *p++ = colorTable.at((src_data[x>>3] >> (x & 7)) & 1); Execution Count:630537 | 630537 |
2846 | | - |
2847 | src_data += src->bytes_per_line; executed (the execution status of this line is deduced): src_data += src->bytes_per_line; | - |
2848 | dest_data += dest->bytes_per_line; executed (the execution status of this line is deduced): dest_data += dest->bytes_per_line; | - |
2849 | } executed: } Execution Count:2190 | 2190 |
2850 | } executed: } Execution Count:135 | 135 |
2851 | } | - |
2852 | | - |
2853 | | - |
2854 | static void convert_Mono_to_Indexed8(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - |
2855 | { | - |
2856 | Q_ASSERT(src->format == QImage::Format_Mono || src->format == QImage::Format_MonoLSB); executed (the execution status of this line is deduced): qt_noop(); | - |
2857 | Q_ASSERT(dest->format == QImage::Format_Indexed8); executed (the execution status of this line is deduced): qt_noop(); | - |
2858 | Q_ASSERT(src->width == dest->width); executed (the execution status of this line is deduced): qt_noop(); | - |
2859 | Q_ASSERT(src->height == dest->height); executed (the execution status of this line is deduced): qt_noop(); | - |
2860 | | - |
2861 | QVector<QRgb> ctbl = src->colortable; executed (the execution status of this line is deduced): QVector<QRgb> ctbl = src->colortable; | - |
2862 | if (ctbl.size() > 2) { partially evaluated: ctbl.size() > 2 no Evaluation Count:0 | yes Evaluation Count:105 |
| 0-105 |
2863 | ctbl.resize(2); never executed (the execution status of this line is deduced): ctbl.resize(2); | - |
2864 | } else if (ctbl.size() < 2) { never executed: } partially evaluated: ctbl.size() < 2 no Evaluation Count:0 | yes Evaluation Count:105 |
| 0-105 |
2865 | if (ctbl.size() == 0) never evaluated: ctbl.size() == 0 | 0 |
2866 | ctbl << 0xff000000; never executed: ctbl << 0xff000000; | 0 |
2867 | ctbl << 0xffffffff; never executed (the execution status of this line is deduced): ctbl << 0xffffffff; | - |
2868 | } | 0 |
2869 | dest->colortable = ctbl; executed (the execution status of this line is deduced): dest->colortable = ctbl; | - |
2870 | dest->has_alpha_clut = src->has_alpha_clut; executed (the execution status of this line is deduced): dest->has_alpha_clut = src->has_alpha_clut; | - |
2871 | | - |
2872 | | - |
2873 | const uchar *src_data = src->data; executed (the execution status of this line is deduced): const uchar *src_data = src->data; | - |
2874 | uchar *dest_data = dest->data; executed (the execution status of this line is deduced): uchar *dest_data = dest->data; | - |
2875 | if (src->format == QImage::Format_Mono) { evaluated: src->format == QImage::Format_Mono yes Evaluation Count:104 | yes Evaluation Count:1 |
| 1-104 |
2876 | for (int y = 0; y < dest->height; y++) { evaluated: y < dest->height yes Evaluation Count:173 | yes Evaluation Count:104 |
| 104-173 |
2877 | register uchar *p = dest_data; executed (the execution status of this line is deduced): register uchar *p = dest_data; | - |
2878 | for (int x = 0; x < dest->width; x++) evaluated: x < dest->width yes Evaluation Count:6548 | yes Evaluation Count:173 |
| 173-6548 |
2879 | *p++ = (src_data[x>>3] >> (7 - (x & 7))) & 1; executed: *p++ = (src_data[x>>3] >> (7 - (x & 7))) & 1; Execution Count:6548 | 6548 |
2880 | src_data += src->bytes_per_line; executed (the execution status of this line is deduced): src_data += src->bytes_per_line; | - |
2881 | dest_data += dest->bytes_per_line; executed (the execution status of this line is deduced): dest_data += dest->bytes_per_line; | - |
2882 | } executed: } Execution Count:173 | 173 |
2883 | } else { executed: } Execution Count:104 | 104 |
2884 | for (int y = 0; y < dest->height; y++) { evaluated: y < dest->height yes Evaluation Count:70 | yes Evaluation Count:1 |
| 1-70 |
2885 | register uchar *p = dest_data; executed (the execution status of this line is deduced): register uchar *p = dest_data; | - |
2886 | for (int x = 0; x < dest->width; x++) evaluated: x < dest->width yes Evaluation Count:4900 | yes Evaluation Count:70 |
| 70-4900 |
2887 | *p++ = (src_data[x>>3] >> (x & 7)) & 1; executed: *p++ = (src_data[x>>3] >> (x & 7)) & 1; Execution Count:4900 | 4900 |
2888 | src_data += src->bytes_per_line; executed (the execution status of this line is deduced): src_data += src->bytes_per_line; | - |
2889 | dest_data += dest->bytes_per_line; executed (the execution status of this line is deduced): dest_data += dest->bytes_per_line; | - |
2890 | } executed: } Execution Count:70 | 70 |
2891 | } executed: } Execution Count:1 | 1 |
2892 | } | - |
2893 | | - |
2894 | // Cannot be used with indexed formats. | - |
2895 | static void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) | - |
2896 | { | - |
2897 | const int buffer_size = 2048; executed (the execution status of this line is deduced): const int buffer_size = 2048; | - |
2898 | uint buffer[buffer_size]; executed (the execution status of this line is deduced): uint buffer[buffer_size]; | - |
2899 | const QPixelLayout *srcLayout = &qPixelLayouts[src->format]; executed (the execution status of this line is deduced): const QPixelLayout *srcLayout = &qPixelLayouts[src->format]; | - |
2900 | const QPixelLayout *destLayout = &qPixelLayouts[dest->format]; executed (the execution status of this line is deduced): const QPixelLayout *destLayout = &qPixelLayouts[dest->format]; | - |
2901 | const uchar *srcData = src->data; executed (the execution status of this line is deduced): const uchar *srcData = src->data; | - |
2902 | uchar *destData = dest->data; executed (the execution status of this line is deduced): uchar *destData = dest->data; | - |
2903 | | - |
2904 | FetchPixelsFunc fetch = qFetchPixels[srcLayout->bpp]; executed (the execution status of this line is deduced): FetchPixelsFunc fetch = qFetchPixels[srcLayout->bpp]; | - |
2905 | StorePixelsFunc store = qStorePixels[destLayout->bpp]; executed (the execution status of this line is deduced): StorePixelsFunc store = qStorePixels[destLayout->bpp]; | - |
2906 | | - |
2907 | for (int y = 0; y < src->height; ++y) { evaluated: y < src->height yes Evaluation Count:53586 | yes Evaluation Count:3376 |
| 3376-53586 |
2908 | int x = 0; executed (the execution status of this line is deduced): int x = 0; | - |
2909 | while (x < src->width) { evaluated: x < src->width yes Evaluation Count:53586 | yes Evaluation Count:53586 |
| 53586 |
2910 | int l = qMin(src->width - x, buffer_size); executed (the execution status of this line is deduced): int l = qMin(src->width - x, buffer_size); | - |
2911 | const uint *ptr = fetch(buffer, srcData, x, l); executed (the execution status of this line is deduced): const uint *ptr = fetch(buffer, srcData, x, l); | - |
2912 | ptr = srcLayout->convertToARGB32PM(buffer, ptr, l, srcLayout, 0); executed (the execution status of this line is deduced): ptr = srcLayout->convertToARGB32PM(buffer, ptr, l, srcLayout, 0); | - |
2913 | ptr = destLayout->convertFromARGB32PM(buffer, ptr, l, destLayout, 0); executed (the execution status of this line is deduced): ptr = destLayout->convertFromARGB32PM(buffer, ptr, l, destLayout, 0); | - |
2914 | store(destData, ptr, x, l); executed (the execution status of this line is deduced): store(destData, ptr, x, l); | - |
2915 | x += l; executed (the execution status of this line is deduced): x += l; | - |
2916 | } executed: } Execution Count:53586 | 53586 |
2917 | srcData += src->bytes_per_line; executed (the execution status of this line is deduced): srcData += src->bytes_per_line; | - |
2918 | destData += dest->bytes_per_line; executed (the execution status of this line is deduced): destData += dest->bytes_per_line; | - |
2919 | } executed: } Execution Count:53586 | 53586 |
2920 | } executed: } Execution Count:3376 | 3376 |
2921 | | - |
2922 | | - |
2923 | // first index source, second dest | - |
2924 | static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormats] = | - |
2925 | { | - |
2926 | { | - |
2927 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - |
2928 | }, | - |
2929 | { | - |
2930 | 0, | - |
2931 | 0, | - |
2932 | swap_bit_order, | - |
2933 | convert_Mono_to_Indexed8, | - |
2934 | convert_Mono_to_X32, | - |
2935 | convert_Mono_to_X32, | - |
2936 | convert_Mono_to_X32, | - |
2937 | 0, | - |
2938 | 0, | - |
2939 | 0, | - |
2940 | 0, | - |
2941 | 0, | - |
2942 | 0, | - |
2943 | 0, | - |
2944 | 0, | - |
2945 | 0 | - |
2946 | }, // Format_Mono | - |
2947 | | - |
2948 | { | - |
2949 | 0, | - |
2950 | swap_bit_order, | - |
2951 | 0, | - |
2952 | convert_Mono_to_Indexed8, | - |
2953 | convert_Mono_to_X32, | - |
2954 | convert_Mono_to_X32, | - |
2955 | convert_Mono_to_X32, | - |
2956 | 0, | - |
2957 | 0, | - |
2958 | 0, | - |
2959 | 0, | - |
2960 | 0, | - |
2961 | 0, | - |
2962 | 0, | - |
2963 | 0, | - |
2964 | 0 | - |
2965 | }, // Format_MonoLSB | - |
2966 | | - |
2967 | { | - |
2968 | 0, | - |
2969 | convert_X_to_Mono, | - |
2970 | convert_X_to_Mono, | - |
2971 | 0, | - |
2972 | convert_Indexed8_to_X32, | - |
2973 | convert_Indexed8_to_X32, | - |
2974 | convert_Indexed8_to_X32, | - |
2975 | 0, | - |
2976 | 0, | - |
2977 | 0, | - |
2978 | 0, | - |
2979 | 0, | - |
2980 | 0, | - |
2981 | 0, | - |
2982 | 0, | - |
2983 | 0 | - |
2984 | }, // Format_Indexed8 | - |
2985 | | - |
2986 | { | - |
2987 | 0, | - |
2988 | convert_X_to_Mono, | - |
2989 | convert_X_to_Mono, | - |
2990 | convert_RGB_to_Indexed8, | - |
2991 | 0, | - |
2992 | mask_alpha_converter, | - |
2993 | mask_alpha_converter, | - |
2994 | convert_generic, | - |
2995 | convert_generic, | - |
2996 | convert_generic, | - |
2997 | convert_generic, | - |
2998 | convert_generic, | - |
2999 | convert_generic, | - |
3000 | convert_generic, | - |
3001 | convert_generic, | - |
3002 | convert_generic | - |
3003 | }, // Format_RGB32 | - |
3004 | | - |
3005 | { | - |
3006 | 0, | - |
3007 | convert_X_to_Mono, | - |
3008 | convert_X_to_Mono, | - |
3009 | convert_ARGB_to_Indexed8, | - |
3010 | mask_alpha_converter, | - |
3011 | 0, | - |
3012 | convert_ARGB_to_ARGB_PM, | - |
3013 | convert_generic, | - |
3014 | convert_generic, | - |
3015 | convert_generic, | - |
3016 | convert_generic, | - |
3017 | convert_generic, | - |
3018 | convert_generic, | - |
3019 | convert_generic, | - |
3020 | convert_generic, | - |
3021 | convert_generic | - |
3022 | }, // Format_ARGB32 | - |
3023 | | - |
3024 | { | - |
3025 | 0, | - |
3026 | convert_ARGB_PM_to_Mono, | - |
3027 | convert_ARGB_PM_to_Mono, | - |
3028 | convert_ARGB_PM_to_Indexed8, | - |
3029 | convert_ARGB_PM_to_RGB, | - |
3030 | convert_ARGB_PM_to_ARGB, | - |
3031 | 0, | - |
3032 | 0, | - |
3033 | 0, | - |
3034 | 0, | - |
3035 | 0, | - |
3036 | 0, | - |
3037 | 0, | - |
3038 | 0, | - |
3039 | 0, | - |
3040 | 0 | - |
3041 | }, // Format_ARGB32_Premultiplied | - |
3042 | | - |
3043 | { | - |
3044 | 0, | - |
3045 | 0, | - |
3046 | 0, | - |
3047 | 0, | - |
3048 | convert_generic, | - |
3049 | convert_generic, | - |
3050 | convert_generic, | - |
3051 | 0, | - |
3052 | 0, | - |
3053 | 0, | - |
3054 | 0, | - |
3055 | #if defined(QT_QWS_DEPTH_15) && defined(QT_QWS_DEPTH_16) | - |
3056 | convert_generic, | - |
3057 | #else | - |
3058 | 0, | - |
3059 | #endif | - |
3060 | 0, | - |
3061 | 0, | - |
3062 | 0, | - |
3063 | 0 | - |
3064 | }, // Format_RGB16 | - |
3065 | | - |
3066 | { | - |
3067 | 0, | - |
3068 | 0, | - |
3069 | 0, | - |
3070 | 0, | - |
3071 | convert_generic, | - |
3072 | convert_generic, | - |
3073 | convert_generic, | - |
3074 | 0, | - |
3075 | 0, | - |
3076 | 0, | - |
3077 | 0, | - |
3078 | 0, | - |
3079 | 0, | - |
3080 | 0, | - |
3081 | 0, | - |
3082 | 0 | - |
3083 | }, // Format_ARGB8565_Premultiplied | - |
3084 | | - |
3085 | { | - |
3086 | 0, | - |
3087 | 0, | - |
3088 | 0, | - |
3089 | 0, | - |
3090 | convert_generic, | - |
3091 | convert_generic, | - |
3092 | convert_generic, | - |
3093 | 0, | - |
3094 | 0, | - |
3095 | 0, | - |
3096 | 0, | - |
3097 | 0, | - |
3098 | 0, | - |
3099 | 0, | - |
3100 | 0, | - |
3101 | 0 | - |
3102 | }, // Format_RGB666 | - |
3103 | | - |
3104 | { | - |
3105 | 0, | - |
3106 | 0, | - |
3107 | 0, | - |
3108 | 0, | - |
3109 | convert_generic, | - |
3110 | convert_generic, | - |
3111 | convert_generic, | - |
3112 | 0, | - |
3113 | 0, | - |
3114 | 0, | - |
3115 | 0, | - |
3116 | 0, | - |
3117 | 0, | - |
3118 | 0, | - |
3119 | 0, | - |
3120 | 0 | - |
3121 | }, // Format_ARGB6666_Premultiplied | - |
3122 | | - |
3123 | { | - |
3124 | 0, | - |
3125 | 0, | - |
3126 | 0, | - |
3127 | 0, | - |
3128 | convert_generic, | - |
3129 | convert_generic, | - |
3130 | convert_generic, | - |
3131 | #if defined(QT_QWS_DEPTH_15) && defined(QT_QWS_DEPTH_16) | - |
3132 | convert_generic, | - |
3133 | #else | - |
3134 | 0, | - |
3135 | #endif | - |
3136 | 0, | - |
3137 | 0, | - |
3138 | 0, | - |
3139 | 0, | - |
3140 | 0, | - |
3141 | 0, | - |
3142 | 0, | - |
3143 | 0 | - |
3144 | }, // Format_RGB555 | - |
3145 | | - |
3146 | { | - |
3147 | 0, | - |
3148 | 0, | - |
3149 | 0, | - |
3150 | 0, | - |
3151 | convert_generic, | - |
3152 | convert_generic, | - |
3153 | convert_generic, | - |
3154 | 0, | - |
3155 | 0, | - |
3156 | 0, | - |
3157 | 0, | - |
3158 | 0, | - |
3159 | 0, | - |
3160 | 0, | - |
3161 | 0, | - |
3162 | 0 | - |
3163 | }, // Format_ARGB8555_Premultiplied | - |
3164 | | - |
3165 | { | - |
3166 | 0, | - |
3167 | 0, | - |
3168 | 0, | - |
3169 | 0, | - |
3170 | convert_generic, | - |
3171 | convert_generic, | - |
3172 | convert_generic, | - |
3173 | 0, | - |
3174 | 0, | - |
3175 | 0, | - |
3176 | 0, | - |
3177 | 0, | - |
3178 | 0, | - |
3179 | 0, | - |
3180 | 0, | - |
3181 | 0 | - |
3182 | }, // Format_RGB888 | - |
3183 | | - |
3184 | { | - |
3185 | 0, | - |
3186 | 0, | - |
3187 | 0, | - |
3188 | 0, | - |
3189 | convert_generic, | - |
3190 | convert_generic, | - |
3191 | convert_generic, | - |
3192 | 0, | - |
3193 | 0, | - |
3194 | 0, | - |
3195 | 0, | - |
3196 | 0, | - |
3197 | 0, | - |
3198 | 0, | - |
3199 | 0, | - |
3200 | 0 | - |
3201 | }, // Format_RGB444 | - |
3202 | | - |
3203 | { | - |
3204 | 0, | - |
3205 | 0, | - |
3206 | 0, | - |
3207 | 0, | - |
3208 | convert_generic, | - |
3209 | convert_generic, | - |
3210 | convert_generic, | - |
3211 | 0, | - |
3212 | 0, | - |
3213 | 0, | - |
3214 | 0, | - |
3215 | 0, | - |
3216 | 0, | - |
3217 | 0, | - |
3218 | 0, | - |
3219 | 0 | - |
3220 | } // Format_ARGB4444_Premultiplied | - |
3221 | }; | - |
3222 | | - |
3223 | static InPlace_Image_Converter inplace_converter_map[QImage::NImageFormats][QImage::NImageFormats] = | - |
3224 | { | - |
3225 | { | - |
3226 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - |
3227 | }, | - |
3228 | { | - |
3229 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - |
3230 | }, // Format_Mono | - |
3231 | { | - |
3232 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - |
3233 | }, // Format_MonoLSB | - |
3234 | { | - |
3235 | 0, | - |
3236 | 0, | - |
3237 | 0, | - |
3238 | 0, | - |
3239 | 0, | - |
3240 | convert_indexed8_to_RGB_inplace, | - |
3241 | convert_indexed8_to_ARGB_PM_inplace, | - |
3242 | convert_indexed8_to_RGB16_inplace, | - |
3243 | 0, | - |
3244 | 0, | - |
3245 | 0, | - |
3246 | 0, | - |
3247 | 0, | - |
3248 | 0, | - |
3249 | 0, | - |
3250 | 0, | - |
3251 | }, // Format_Indexed8 | - |
3252 | { | - |
3253 | 0, | - |
3254 | 0, | - |
3255 | 0, | - |
3256 | 0, | - |
3257 | 0, | - |
3258 | 0, | - |
3259 | 0, | - |
3260 | convert_RGB_to_RGB16_inplace, | - |
3261 | 0, | - |
3262 | 0, | - |
3263 | 0, | - |
3264 | 0, | - |
3265 | 0, | - |
3266 | 0, | - |
3267 | 0, | - |
3268 | 0, | - |
3269 | }, // Format_ARGB32 | - |
3270 | { | - |
3271 | 0, | - |
3272 | 0, | - |
3273 | 0, | - |
3274 | 0, | - |
3275 | 0, | - |
3276 | 0, | - |
3277 | convert_ARGB_to_ARGB_PM_inplace, | - |
3278 | 0, | - |
3279 | 0, | - |
3280 | 0, | - |
3281 | 0, | - |
3282 | 0, | - |
3283 | 0, | - |
3284 | 0, | - |
3285 | 0, | - |
3286 | 0, | - |
3287 | }, // Format_ARGB32 | - |
3288 | { | - |
3289 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - |
3290 | }, // Format_ARGB32_Premultiplied | - |
3291 | { | - |
3292 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - |
3293 | }, // Format_RGB16 | - |
3294 | { | - |
3295 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - |
3296 | }, // Format_ARGB8565_Premultiplied | - |
3297 | { | - |
3298 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - |
3299 | }, // Format_RGB666 | - |
3300 | { | - |
3301 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - |
3302 | }, // Format_ARGB6666_Premultiplied | - |
3303 | { | - |
3304 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - |
3305 | }, // Format_RGB555 | - |
3306 | { | - |
3307 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - |
3308 | }, // Format_ARGB8555_Premultiplied | - |
3309 | { | - |
3310 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - |
3311 | }, // Format_RGB888 | - |
3312 | { | - |
3313 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - |
3314 | }, // Format_RGB444 | - |
3315 | { | - |
3316 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - |
3317 | } // Format_ARGB4444_Premultiplied | - |
3318 | }; | - |
3319 | | - |
3320 | void qInitImageConversions() | - |
3321 | { | - |
3322 | #ifdef QT_COMPILER_SUPPORTS_AVX | - |
3323 | if (qCpuHasFeature(AVX)) { partially evaluated: qCpuHasFeature(AVX) no Evaluation Count:0 | yes Evaluation Count:276 |
| 0-276 |
3324 | extern bool convert_ARGB_to_ARGB_PM_inplace_avx(QImageData *data, Qt::ImageConversionFlags); never executed (the execution status of this line is deduced): extern bool convert_ARGB_to_ARGB_PM_inplace_avx(QImageData *data, Qt::ImageConversionFlags); | - |
3325 | inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_avx; never executed (the execution status of this line is deduced): inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_avx; | - |
3326 | | - |
3327 | extern void convert_RGB888_to_RGB32_avx(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); never executed (the execution status of this line is deduced): extern void convert_RGB888_to_RGB32_avx(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); | - |
3328 | converter_map[QImage::Format_RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_avx; never executed (the execution status of this line is deduced): converter_map[QImage::Format_RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_avx; | - |
3329 | converter_map[QImage::Format_RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_avx; never executed (the execution status of this line is deduced): converter_map[QImage::Format_RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_avx; | - |
3330 | converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_avx; never executed (the execution status of this line is deduced): converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_avx; | - |
3331 | return; | 0 |
3332 | } | - |
3333 | #endif | - |
3334 | | - |
3335 | #if defined(QT_COMPILER_SUPPORTS_SSE2) && !defined(__AVX__) | - |
3336 | if (qCpuHasFeature(SSE2)) { partially evaluated: qCpuHasFeature(SSE2) yes Evaluation Count:276 | no Evaluation Count:0 |
| 0-276 |
3337 | extern bool convert_ARGB_to_ARGB_PM_inplace_sse2(QImageData *data, Qt::ImageConversionFlags); executed (the execution status of this line is deduced): extern bool convert_ARGB_to_ARGB_PM_inplace_sse2(QImageData *data, Qt::ImageConversionFlags); | - |
3338 | inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_sse2; executed (the execution status of this line is deduced): inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_sse2; | - |
3339 | #ifdef QT_COMPILER_SUPPORTS_SSSE3 | - |
3340 | if (qCpuHasFeature(SSSE3)) { partially evaluated: qCpuHasFeature(SSSE3) yes Evaluation Count:276 | no Evaluation Count:0 |
| 0-276 |
3341 | extern void convert_RGB888_to_RGB32_ssse3(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); executed (the execution status of this line is deduced): extern void convert_RGB888_to_RGB32_ssse3(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); | - |
3342 | converter_map[QImage::Format_RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_ssse3; executed (the execution status of this line is deduced): converter_map[QImage::Format_RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_ssse3; | - |
3343 | converter_map[QImage::Format_RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_ssse3; executed (the execution status of this line is deduced): converter_map[QImage::Format_RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_ssse3; | - |
3344 | converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_ssse3; executed (the execution status of this line is deduced): converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_ssse3; | - |
3345 | } executed: } Execution Count:276 | 276 |
3346 | #endif | - |
3347 | return; executed: return; Execution Count:276 | 276 |
3348 | } | - |
3349 | #endif // SSE2 | - |
3350 | | - |
3351 | #ifdef QT_COMPILER_SUPPORTS_NEON | - |
3352 | if (qCpuHasFeature(NEON)) { | - |
3353 | extern void convert_RGB888_to_RGB32_neon(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); | - |
3354 | converter_map[QImage::Format_RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_neon; | - |
3355 | converter_map[QImage::Format_RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_neon; | - |
3356 | converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_neon; | - |
3357 | return; | - |
3358 | } | - |
3359 | #endif | - |
3360 | } | 0 |
3361 | | - |
3362 | extern const uchar *qt_pow_rgb_gamma(); | - |
3363 | | - |
3364 | void qGamma_correct_back_to_linear_cs(QImage *image) | - |
3365 | { | - |
3366 | const QDrawHelperGammaTables *tables = QGuiApplicationPrivate::instance()->gammaTables(); never executed (the execution status of this line is deduced): const QDrawHelperGammaTables *tables = QGuiApplicationPrivate::instance()->gammaTables(); | - |
3367 | if (!tables) | 0 |
3368 | return; | 0 |
3369 | const uchar *gamma = tables->qt_pow_rgb_gamma; never executed (the execution status of this line is deduced): const uchar *gamma = tables->qt_pow_rgb_gamma; | - |
3370 | // gamma correct the pixels back to linear color space... | - |
3371 | int h = image->height(); never executed (the execution status of this line is deduced): int h = image->height(); | - |
3372 | int w = image->width(); never executed (the execution status of this line is deduced): int w = image->width(); | - |
3373 | | - |
3374 | for (int y=0; y<h; ++y) { | 0 |
3375 | uint *pixels = (uint *) image->scanLine(y); never executed (the execution status of this line is deduced): uint *pixels = (uint *) image->scanLine(y); | - |
3376 | for (int x=0; x<w; ++x) { | 0 |
3377 | uint p = pixels[x]; never executed (the execution status of this line is deduced): uint p = pixels[x]; | - |
3378 | uint r = gamma[qRed(p)]; never executed (the execution status of this line is deduced): uint r = gamma[qRed(p)]; | - |
3379 | uint g = gamma[qGreen(p)]; never executed (the execution status of this line is deduced): uint g = gamma[qGreen(p)]; | - |
3380 | uint b = gamma[qBlue(p)]; never executed (the execution status of this line is deduced): uint b = gamma[qBlue(p)]; | - |
3381 | pixels[x] = (r << 16) | (g << 8) | b | 0xff000000; never executed (the execution status of this line is deduced): pixels[x] = (r << 16) | (g << 8) | b | 0xff000000; | - |
3382 | } | 0 |
3383 | } | 0 |
3384 | } | 0 |
3385 | | - |
3386 | /*! | - |
3387 | Returns a copy of the image in the given \a format. | - |
3388 | | - |
3389 | The specified image conversion \a flags control how the image data | - |
3390 | is handled during the conversion process. | - |
3391 | | - |
3392 | \sa {QImage#Image Format}{Image Format} | - |
3393 | */ | - |
3394 | QImage QImage::convertToFormat(Format format, Qt::ImageConversionFlags flags) const | - |
3395 | { | - |
3396 | if (!d || d->format == format) evaluated: !d yes Evaluation Count:5 | yes Evaluation Count:15031 |
evaluated: d->format == format yes Evaluation Count:5668 | yes Evaluation Count:9363 |
| 5-15031 |
3397 | return *this; executed: return *this; Execution Count:5673 | 5673 |
3398 | | - |
3399 | if (format == Format_Invalid || d->format == Format_Invalid) partially evaluated: format == Format_Invalid no Evaluation Count:0 | yes Evaluation Count:9363 |
partially evaluated: d->format == Format_Invalid no Evaluation Count:0 | yes Evaluation Count:9363 |
| 0-9363 |
3400 | return QImage(); never executed: return QImage(); | 0 |
3401 | | - |
3402 | const Image_Converter *converterPtr = &converter_map[d->format][format]; executed (the execution status of this line is deduced): const Image_Converter *converterPtr = &converter_map[d->format][format]; | - |
3403 | Image_Converter converter = *converterPtr; executed (the execution status of this line is deduced): Image_Converter converter = *converterPtr; | - |
3404 | if (converter) { evaluated: converter yes Evaluation Count:9256 | yes Evaluation Count:107 |
| 107-9256 |
3405 | QImage image(d->width, d->height, format); executed (the execution status of this line is deduced): QImage image(d->width, d->height, format); | - |
3406 | | - |
3407 | QIMAGE_SANITYCHECK_MEMORY(image); never executed: return QImage(); partially evaluated: (image).isNull() no Evaluation Count:0 | yes Evaluation Count:9256 |
| 0-9256 |
3408 | | - |
3409 | image.setDotsPerMeterY(dotsPerMeterY()); executed (the execution status of this line is deduced): image.setDotsPerMeterY(dotsPerMeterY()); | - |
3410 | image.setDotsPerMeterX(dotsPerMeterX()); executed (the execution status of this line is deduced): image.setDotsPerMeterX(dotsPerMeterX()); | - |
3411 | image.setDevicePixelRatio(devicePixelRatio()); executed (the execution status of this line is deduced): image.setDevicePixelRatio(devicePixelRatio()); | - |
3412 | | - |
3413 | image.d->text = d->text; executed (the execution status of this line is deduced): image.d->text = d->text; | - |
3414 | | - |
3415 | converter(image.d, d, flags); executed (the execution status of this line is deduced): converter(image.d, d, flags); | - |
3416 | return image; executed: return image; Execution Count:9256 | 9256 |
3417 | } | - |
3418 | | - |
3419 | Q_ASSERT(format != QImage::Format_ARGB32); executed (the execution status of this line is deduced): qt_noop(); | - |
3420 | Q_ASSERT(d->format != QImage::Format_ARGB32); executed (the execution status of this line is deduced): qt_noop(); | - |
3421 | | - |
3422 | QImage image = convertToFormat(Format_ARGB32, flags); executed (the execution status of this line is deduced): QImage image = convertToFormat(Format_ARGB32, flags); | - |
3423 | return image.convertToFormat(format, flags); executed: return image.convertToFormat(format, flags); Execution Count:107 | 107 |
3424 | } | - |
3425 | | - |
3426 | | - |
3427 | | - |
3428 | static inline int pixel_distance(QRgb p1, QRgb p2) { | - |
3429 | int r1 = qRed(p1); executed (the execution status of this line is deduced): int r1 = qRed(p1); | - |
3430 | int g1 = qGreen(p1); executed (the execution status of this line is deduced): int g1 = qGreen(p1); | - |
3431 | int b1 = qBlue(p1); executed (the execution status of this line is deduced): int b1 = qBlue(p1); | - |
3432 | int a1 = qAlpha(p1); executed (the execution status of this line is deduced): int a1 = qAlpha(p1); | - |
3433 | | - |
3434 | int r2 = qRed(p2); executed (the execution status of this line is deduced): int r2 = qRed(p2); | - |
3435 | int g2 = qGreen(p2); executed (the execution status of this line is deduced): int g2 = qGreen(p2); | - |
3436 | int b2 = qBlue(p2); executed (the execution status of this line is deduced): int b2 = qBlue(p2); | - |
3437 | int a2 = qAlpha(p2); executed (the execution status of this line is deduced): int a2 = qAlpha(p2); | - |
3438 | | - |
3439 | return abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2) + abs(a1 - a2); executed: return abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2) + abs(a1 - a2); Execution Count:2 | 2 |
3440 | } | - |
3441 | | - |
3442 | static inline int closestMatch(QRgb pixel, const QVector<QRgb> &clut) { | - |
3443 | int idx = 0; executed (the execution status of this line is deduced): int idx = 0; | - |
3444 | int current_distance = INT_MAX; executed (the execution status of this line is deduced): int current_distance = 2147483647; | - |
3445 | for (int i=0; i<clut.size(); ++i) { evaluated: i<clut.size() yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
3446 | int dist = pixel_distance(pixel, clut.at(i)); executed (the execution status of this line is deduced): int dist = pixel_distance(pixel, clut.at(i)); | - |
3447 | if (dist < current_distance) { evaluated: dist < current_distance yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
3448 | current_distance = dist; executed (the execution status of this line is deduced): current_distance = dist; | - |
3449 | idx = i; executed (the execution status of this line is deduced): idx = i; | - |
3450 | } executed: } Execution Count:1 | 1 |
3451 | } executed: } Execution Count:2 | 2 |
3452 | return idx; executed: return idx; Execution Count:1 | 1 |
3453 | } | - |
3454 | | - |
3455 | static QImage convertWithPalette(const QImage &src, QImage::Format format, | - |
3456 | const QVector<QRgb> &clut) { | - |
3457 | QImage dest(src.size(), format); executed (the execution status of this line is deduced): QImage dest(src.size(), format); | - |
3458 | dest.setColorTable(clut); executed (the execution status of this line is deduced): dest.setColorTable(clut); | - |
3459 | | - |
3460 | QString textsKeys = src.text(); executed (the execution status of this line is deduced): QString textsKeys = src.text(); | - |
3461 | QStringList textKeyList = textsKeys.split(QLatin1Char('\n'), QString::SkipEmptyParts); executed (the execution status of this line is deduced): QStringList textKeyList = textsKeys.split(QLatin1Char('\n'), QString::SkipEmptyParts); | - |
3462 | foreach (const QString &textKey, textKeyList) { executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(textKeyList)> _container_(textKeyList); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QString &textKey = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
3463 | QStringList textKeySplitted = textKey.split(QLatin1String(": ")); executed (the execution status of this line is deduced): QStringList textKeySplitted = textKey.split(QLatin1String(": ")); | - |
3464 | dest.setText(textKeySplitted[0], textKeySplitted[1]); executed (the execution status of this line is deduced): dest.setText(textKeySplitted[0], textKeySplitted[1]); | - |
3465 | } executed: } Execution Count:2 | 2 |
3466 | | - |
3467 | int h = src.height(); executed (the execution status of this line is deduced): int h = src.height(); | - |
3468 | int w = src.width(); executed (the execution status of this line is deduced): int w = src.width(); | - |
3469 | | - |
3470 | QHash<QRgb, int> cache; executed (the execution status of this line is deduced): QHash<QRgb, int> cache; | - |
3471 | | - |
3472 | if (format == QImage::Format_Indexed8) { partially evaluated: format == QImage::Format_Indexed8 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
3473 | for (int y=0; y<h; ++y) { | 0 |
3474 | QRgb *src_pixels = (QRgb *) src.scanLine(y); never executed (the execution status of this line is deduced): QRgb *src_pixels = (QRgb *) src.scanLine(y); | - |
3475 | uchar *dest_pixels = (uchar *) dest.scanLine(y); never executed (the execution status of this line is deduced): uchar *dest_pixels = (uchar *) dest.scanLine(y); | - |
3476 | for (int x=0; x<w; ++x) { | 0 |
3477 | int src_pixel = src_pixels[x]; never executed (the execution status of this line is deduced): int src_pixel = src_pixels[x]; | - |
3478 | int value = cache.value(src_pixel, -1); never executed (the execution status of this line is deduced): int value = cache.value(src_pixel, -1); | - |
3479 | if (value == -1) { never evaluated: value == -1 | 0 |
3480 | value = closestMatch(src_pixel, clut); never executed (the execution status of this line is deduced): value = closestMatch(src_pixel, clut); | - |
3481 | cache.insert(src_pixel, value); never executed (the execution status of this line is deduced): cache.insert(src_pixel, value); | - |
3482 | } | 0 |
3483 | dest_pixels[x] = (uchar) value; never executed (the execution status of this line is deduced): dest_pixels[x] = (uchar) value; | - |
3484 | } | 0 |
3485 | } | 0 |
3486 | } else { | 0 |
3487 | QVector<QRgb> table = clut; executed (the execution status of this line is deduced): QVector<QRgb> table = clut; | - |
3488 | table.resize(2); executed (the execution status of this line is deduced): table.resize(2); | - |
3489 | for (int y=0; y<h; ++y) { evaluated: y<h yes Evaluation Count:100 | yes Evaluation Count:1 |
| 1-100 |
3490 | QRgb *src_pixels = (QRgb *) src.scanLine(y); executed (the execution status of this line is deduced): QRgb *src_pixels = (QRgb *) src.scanLine(y); | - |
3491 | for (int x=0; x<w; ++x) { evaluated: x<w yes Evaluation Count:10000 | yes Evaluation Count:100 |
| 100-10000 |
3492 | int src_pixel = src_pixels[x]; executed (the execution status of this line is deduced): int src_pixel = src_pixels[x]; | - |
3493 | int value = cache.value(src_pixel, -1); executed (the execution status of this line is deduced): int value = cache.value(src_pixel, -1); | - |
3494 | if (value == -1) { evaluated: value == -1 yes Evaluation Count:1 | yes Evaluation Count:9999 |
| 1-9999 |
3495 | value = closestMatch(src_pixel, table); executed (the execution status of this line is deduced): value = closestMatch(src_pixel, table); | - |
3496 | cache.insert(src_pixel, value); executed (the execution status of this line is deduced): cache.insert(src_pixel, value); | - |
3497 | } executed: } Execution Count:1 | 1 |
3498 | dest.setPixel(x, y, value); executed (the execution status of this line is deduced): dest.setPixel(x, y, value); | - |
3499 | } executed: } Execution Count:10000 | 10000 |
3500 | } executed: } Execution Count:100 | 100 |
3501 | } executed: } Execution Count:1 | 1 |
3502 | | - |
3503 | return dest; executed: return dest; Execution Count:1 | 1 |
3504 | } | - |
3505 | | - |
3506 | /*! | - |
3507 | \overload | - |
3508 | | - |
3509 | Returns a copy of the image converted to the given \a format, | - |
3510 | using the specified \a colorTable. | - |
3511 | | - |
3512 | Conversion from 32 bit to 8 bit indexed is a slow operation and | - |
3513 | will use a straightforward nearest color approach, with no | - |
3514 | dithering. | - |
3515 | */ | - |
3516 | QImage QImage::convertToFormat(Format format, const QVector<QRgb> &colorTable, Qt::ImageConversionFlags flags) const | - |
3517 | { | - |
3518 | if (d->format == format) partially evaluated: d->format == format no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
3519 | return *this; never executed: return *this; | 0 |
3520 | | - |
3521 | if (format <= QImage::Format_Indexed8 && depth() == 32) { partially evaluated: format <= QImage::Format_Indexed8 yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: depth() == 32 yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
3522 | return convertWithPalette(*this, format, colorTable); executed: return convertWithPalette(*this, format, colorTable); Execution Count:1 | 1 |
3523 | } | - |
3524 | | - |
3525 | const Image_Converter *converterPtr = &converter_map[d->format][format]; never executed (the execution status of this line is deduced): const Image_Converter *converterPtr = &converter_map[d->format][format]; | - |
3526 | Image_Converter converter = *converterPtr; never executed (the execution status of this line is deduced): Image_Converter converter = *converterPtr; | - |
3527 | if (!converter) never evaluated: !converter | 0 |
3528 | return QImage(); never executed: return QImage(); | 0 |
3529 | | - |
3530 | QImage image(d->width, d->height, format); never executed (the execution status of this line is deduced): QImage image(d->width, d->height, format); | - |
3531 | QIMAGE_SANITYCHECK_MEMORY(image); never executed: return QImage(); never evaluated: (image).isNull() | 0 |
3532 | image.setDevicePixelRatio(devicePixelRatio()); never executed (the execution status of this line is deduced): image.setDevicePixelRatio(devicePixelRatio()); | - |
3533 | | - |
3534 | image.d->text = d->text; never executed (the execution status of this line is deduced): image.d->text = d->text; | - |
3535 | | - |
3536 | converter(image.d, d, flags); never executed (the execution status of this line is deduced): converter(image.d, d, flags); | - |
3537 | return image; never executed: return image; | 0 |
3538 | } | - |
3539 | | - |
3540 | /*! | - |
3541 | \fn bool QImage::valid(const QPoint &pos) const | - |
3542 | | - |
3543 | Returns true if \a pos is a valid coordinate pair within the | - |
3544 | image; otherwise returns false. | - |
3545 | | - |
3546 | \sa rect(), QRect::contains() | - |
3547 | */ | - |
3548 | | - |
3549 | /*! | - |
3550 | \overload | - |
3551 | | - |
3552 | Returns true if QPoint(\a x, \a y) is a valid coordinate pair | - |
3553 | within the image; otherwise returns false. | - |
3554 | */ | - |
3555 | bool QImage::valid(int x, int y) const | - |
3556 | { | - |
3557 | return d executed: return d && x >= 0 && x < d->width && y >= 0 && y < d->height; Execution Count:8 | 8 |
3558 | && x >= 0 && x < d->width executed: return d && x >= 0 && x < d->width && y >= 0 && y < d->height; Execution Count:8 | 8 |
3559 | && y >= 0 && y < d->height; executed: return d && x >= 0 && x < d->width && y >= 0 && y < d->height; Execution Count:8 | 8 |
3560 | } | - |
3561 | | - |
3562 | /*! | - |
3563 | \fn int QImage::pixelIndex(const QPoint &position) const | - |
3564 | | - |
3565 | Returns the pixel index at the given \a position. | - |
3566 | | - |
3567 | If \a position is not valid, or if the image is not a paletted | - |
3568 | image (depth() > 8), the results are undefined. | - |
3569 | | - |
3570 | \sa valid(), depth(), {QImage#Pixel Manipulation}{Pixel Manipulation} | - |
3571 | */ | - |
3572 | | - |
3573 | /*! | - |
3574 | \overload | - |
3575 | | - |
3576 | Returns the pixel index at (\a x, \a y). | - |
3577 | */ | - |
3578 | int QImage::pixelIndex(int x, int y) const | - |
3579 | { | - |
3580 | if (!d || x < 0 || x >= d->width || y < 0 || y >= height()) { partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:12036472 |
partially evaluated: x < 0 no Evaluation Count:0 | yes Evaluation Count:12036472 |
partially evaluated: x >= d->width no Evaluation Count:0 | yes Evaluation Count:12036472 |
partially evaluated: y < 0 no Evaluation Count:0 | yes Evaluation Count:12036472 |
partially evaluated: y >= height() no Evaluation Count:0 | yes Evaluation Count:12036472 |
| 0-12036472 |
3581 | qWarning("QImage::pixelIndex: coordinate (%d,%d) out of range", x, y); never executed (the execution status of this line is deduced): QMessageLogger("image/qimage.cpp", 3581, __PRETTY_FUNCTION__).warning("QImage::pixelIndex: coordinate (%d,%d) out of range", x, y); | - |
3582 | return -12345; never executed: return -12345; | 0 |
3583 | } | - |
3584 | const uchar * s = scanLine(y); executed (the execution status of this line is deduced): const uchar * s = scanLine(y); | - |
3585 | switch(d->format) { | - |
3586 | case Format_Mono: | - |
3587 | return (*(s + (x >> 3)) >> (7- (x & 7))) & 1; executed: return (*(s + (x >> 3)) >> (7- (x & 7))) & 1; Execution Count:42214 | 42214 |
3588 | case Format_MonoLSB: | - |
3589 | return (*(s + (x >> 3)) >> (x & 7)) & 1; executed: return (*(s + (x >> 3)) >> (x & 7)) & 1; Execution Count:4947834 | 4947834 |
3590 | case Format_Indexed8: | - |
3591 | return (int)s[x]; executed: return (int)s[x]; Execution Count:7046424 | 7046424 |
3592 | default: | - |
3593 | qWarning("QImage::pixelIndex: Not applicable for %d-bpp images (no palette)", d->depth); never executed (the execution status of this line is deduced): QMessageLogger("image/qimage.cpp", 3593, __PRETTY_FUNCTION__).warning("QImage::pixelIndex: Not applicable for %d-bpp images (no palette)", d->depth); | - |
3594 | } | 0 |
3595 | return 0; never executed: return 0; | 0 |
3596 | } | - |
3597 | | - |
3598 | | - |
3599 | /*! | - |
3600 | \fn QRgb QImage::pixel(const QPoint &position) const | - |
3601 | | - |
3602 | Returns the color of the pixel at the given \a position. | - |
3603 | | - |
3604 | If the \a position is not valid, the results are undefined. | - |
3605 | | - |
3606 | \warning This function is expensive when used for massive pixel | - |
3607 | manipulations. | - |
3608 | | - |
3609 | \sa setPixel(), valid(), {QImage#Pixel Manipulation}{Pixel | - |
3610 | Manipulation} | - |
3611 | */ | - |
3612 | | - |
3613 | /*! | - |
3614 | \overload | - |
3615 | | - |
3616 | Returns the color of the pixel at coordinates (\a x, \a y). | - |
3617 | */ | - |
3618 | QRgb QImage::pixel(int x, int y) const | - |
3619 | { | - |
3620 | if (!d || x < 0 || x >= d->width || y < 0 || y >= height()) { partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:15721910 |
partially evaluated: x < 0 no Evaluation Count:0 | yes Evaluation Count:15721910 |
partially evaluated: x >= d->width no Evaluation Count:0 | yes Evaluation Count:15721910 |
partially evaluated: y < 0 no Evaluation Count:0 | yes Evaluation Count:15721910 |
partially evaluated: y >= height() no Evaluation Count:0 | yes Evaluation Count:15721910 |
| 0-15721910 |
3621 | qWarning("QImage::pixel: coordinate (%d,%d) out of range", x, y); never executed (the execution status of this line is deduced): QMessageLogger("image/qimage.cpp", 3621, __PRETTY_FUNCTION__).warning("QImage::pixel: coordinate (%d,%d) out of range", x, y); | - |
3622 | return 12345; never executed: return 12345; | 0 |
3623 | } | - |
3624 | | - |
3625 | const uchar * s = constScanLine(y); executed (the execution status of this line is deduced): const uchar * s = constScanLine(y); | - |
3626 | switch(d->format) { | - |
3627 | case Format_Mono: | - |
3628 | return d->colortable.at((*(s + (x >> 3)) >> (~x & 7)) & 1); executed: return d->colortable.at((*(s + (x >> 3)) >> (~x & 7)) & 1); Execution Count:175484 | 175484 |
3629 | case Format_MonoLSB: | - |
3630 | return d->colortable.at((*(s + (x >> 3)) >> (x & 7)) & 1); executed: return d->colortable.at((*(s + (x >> 3)) >> (x & 7)) & 1); Execution Count:97109 | 97109 |
3631 | case Format_Indexed8: | - |
3632 | return d->colortable.at((int)s[x]); executed: return d->colortable.at((int)s[x]); Execution Count:78624 | 78624 |
3633 | case Format_RGB32: | - |
3634 | case Format_ARGB32: // Keep old behaviour. | - |
3635 | case Format_ARGB32_Premultiplied: | - |
3636 | return reinterpret_cast<const QRgb *>(s)[x]; executed: return reinterpret_cast<const QRgb *>(s)[x]; Execution Count:13820813 | 13820813 |
3637 | case Format_RGB16: | - |
3638 | return qConvertRgb16To32(reinterpret_cast<const quint16 *>(s)[x]); executed: return qConvertRgb16To32(reinterpret_cast<const quint16 *>(s)[x]); Execution Count:111681 | 111681 |
3639 | default: | - |
3640 | break; executed: break; Execution Count:1438199 | 1438199 |
3641 | } | - |
3642 | const QPixelLayout *layout = &qPixelLayouts[d->format]; executed (the execution status of this line is deduced): const QPixelLayout *layout = &qPixelLayouts[d->format]; | - |
3643 | uint result; executed (the execution status of this line is deduced): uint result; | - |
3644 | const uint *ptr = qFetchPixels[layout->bpp](&result, s, x, 1); executed (the execution status of this line is deduced): const uint *ptr = qFetchPixels[layout->bpp](&result, s, x, 1); | - |
3645 | return *layout->convertToARGB32PM(&result, ptr, 1, layout, 0); executed: return *layout->convertToARGB32PM(&result, ptr, 1, layout, 0); Execution Count:1438199 | 1438199 |
3646 | } | - |
3647 | | - |
3648 | | - |
3649 | /*! | - |
3650 | \fn void QImage::setPixel(const QPoint &position, uint index_or_rgb) | - |
3651 | | - |
3652 | Sets the pixel index or color at the given \a position to \a | - |
3653 | index_or_rgb. | - |
3654 | | - |
3655 | If the image's format is either monochrome or 8-bit, the given \a | - |
3656 | index_or_rgb value must be an index in the image's color table, | - |
3657 | otherwise the parameter must be a QRgb value. | - |
3658 | | - |
3659 | If \a position is not a valid coordinate pair in the image, or if | - |
3660 | \a index_or_rgb >= colorCount() in the case of monochrome and | - |
3661 | 8-bit images, the result is undefined. | - |
3662 | | - |
3663 | \warning This function is expensive due to the call of the internal | - |
3664 | \c{detach()} function called within; if performance is a concern, we | - |
3665 | recommend the use of \l{QImage::}{scanLine()} to access pixel data | - |
3666 | directly. | - |
3667 | | - |
3668 | \sa pixel(), {QImage#Pixel Manipulation}{Pixel Manipulation} | - |
3669 | */ | - |
3670 | | - |
3671 | /*! | - |
3672 | \overload | - |
3673 | | - |
3674 | Sets the pixel index or color at (\a x, \a y) to \a index_or_rgb. | - |
3675 | */ | - |
3676 | void QImage::setPixel(int x, int y, uint index_or_rgb) | - |
3677 | { | - |
3678 | if (!d || x < 0 || x >= width() || y < 0 || y >= height()) { partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:3691350 |
partially evaluated: x < 0 no Evaluation Count:0 | yes Evaluation Count:3691350 |
partially evaluated: x >= width() no Evaluation Count:0 | yes Evaluation Count:3691350 |
partially evaluated: y < 0 no Evaluation Count:0 | yes Evaluation Count:3691350 |
partially evaluated: y >= height() no Evaluation Count:0 | yes Evaluation Count:3691350 |
| 0-3691350 |
3679 | qWarning("QImage::setPixel: coordinate (%d,%d) out of range", x, y); never executed (the execution status of this line is deduced): QMessageLogger("image/qimage.cpp", 3679, __PRETTY_FUNCTION__).warning("QImage::setPixel: coordinate (%d,%d) out of range", x, y); | - |
3680 | return; | 0 |
3681 | } | - |
3682 | // detach is called from within scanLine | - |
3683 | uchar * s = scanLine(y); executed (the execution status of this line is deduced): uchar * s = scanLine(y); | - |
3684 | switch(d->format) { | - |
3685 | case Format_Mono: | - |
3686 | case Format_MonoLSB: | - |
3687 | if (index_or_rgb > 1) { partially evaluated: index_or_rgb > 1 no Evaluation Count:0 | yes Evaluation Count:14100 |
| 0-14100 |
3688 | qWarning("QImage::setPixel: Index %d out of range", index_or_rgb); never executed (the execution status of this line is deduced): QMessageLogger("image/qimage.cpp", 3688, __PRETTY_FUNCTION__).warning("QImage::setPixel: Index %d out of range", index_or_rgb); | - |
3689 | } else if (format() == Format_MonoLSB) { never executed: } evaluated: format() == Format_MonoLSB yes Evaluation Count:11024 | yes Evaluation Count:3076 |
| 0-11024 |
3690 | if (index_or_rgb==0) evaluated: index_or_rgb==0 yes Evaluation Count:10000 | yes Evaluation Count:1024 |
| 1024-10000 |
3691 | *(s + (x >> 3)) &= ~(1 << (x & 7)); executed: *(s + (x >> 3)) &= ~(1 << (x & 7)); Execution Count:10000 | 10000 |
3692 | else | - |
3693 | *(s + (x >> 3)) |= (1 << (x & 7)); executed: *(s + (x >> 3)) |= (1 << (x & 7)); Execution Count:1024 | 1024 |
3694 | } else { | - |
3695 | if (index_or_rgb==0) evaluated: index_or_rgb==0 yes Evaluation Count:1024 | yes Evaluation Count:2052 |
| 1024-2052 |
3696 | *(s + (x >> 3)) &= ~(1 << (7-(x & 7))); executed: *(s + (x >> 3)) &= ~(1 << (7-(x & 7))); Execution Count:1024 | 1024 |
3697 | else | - |
3698 | *(s + (x >> 3)) |= (1 << (7-(x & 7))); executed: *(s + (x >> 3)) |= (1 << (7-(x & 7))); Execution Count:2052 | 2052 |
3699 | } | - |
3700 | return; executed: return; Execution Count:14100 | 14100 |
3701 | case Format_Indexed8: | - |
3702 | if (index_or_rgb >= (uint)d->colortable.size()) { partially evaluated: index_or_rgb >= (uint)d->colortable.size() no Evaluation Count:0 | yes Evaluation Count:1187 |
| 0-1187 |
3703 | qWarning("QImage::setPixel: Index %d out of range", index_or_rgb); never executed (the execution status of this line is deduced): QMessageLogger("image/qimage.cpp", 3703, __PRETTY_FUNCTION__).warning("QImage::setPixel: Index %d out of range", index_or_rgb); | - |
3704 | return; | 0 |
3705 | } | - |
3706 | s[x] = index_or_rgb; executed (the execution status of this line is deduced): s[x] = index_or_rgb; | - |
3707 | return; executed: return; Execution Count:1187 | 1187 |
3708 | case Format_RGB32: | - |
3709 | //make sure alpha is 255, we depend on it in qdrawhelper for cases | - |
3710 | // when image is set as a texture pattern on a qbrush | - |
3711 | ((uint *)s)[x] = uint(255 << 24) | index_or_rgb; executed (the execution status of this line is deduced): ((uint *)s)[x] = uint(255 << 24) | index_or_rgb; | - |
3712 | return; executed: return; Execution Count:51621 | 51621 |
3713 | case Format_ARGB32: | - |
3714 | case Format_ARGB32_Premultiplied: | - |
3715 | ((uint *)s)[x] = index_or_rgb; executed (the execution status of this line is deduced): ((uint *)s)[x] = index_or_rgb; | - |
3716 | return; executed: return; Execution Count:3582900 | 3582900 |
3717 | case Format_RGB16: | - |
3718 | ((quint16 *)s)[x] = qConvertRgb32To16(INV_PREMUL(index_or_rgb)); executed (the execution status of this line is deduced): ((quint16 *)s)[x] = qConvertRgb32To16((qAlpha(index_or_rgb) == 0 ? 0 : ((qAlpha(index_or_rgb) << 24) | (((255*qRed(index_or_rgb))/ qAlpha(index_or_rgb)) << 16) | (((255*qGreen(index_or_rgb)) / qAlpha(index_or_rgb)) << 8) | ((255*qBlue(index_or_rgb)) / qAlpha(index_or_rgb))))); | - |
3719 | return; executed: return; Execution Count:20577 | 20577 |
3720 | case Format_Invalid: | - |
3721 | case NImageFormats: | - |
3722 | Q_ASSERT(false); never executed (the execution status of this line is deduced): qt_noop(); | - |
3723 | return; | 0 |
3724 | default: | - |
3725 | break; executed: break; Execution Count:20965 | 20965 |
3726 | } | - |
3727 | | - |
3728 | const QPixelLayout *layout = &qPixelLayouts[d->format]; executed (the execution status of this line is deduced): const QPixelLayout *layout = &qPixelLayouts[d->format]; | - |
3729 | uint result; executed (the execution status of this line is deduced): uint result; | - |
3730 | const uint *ptr = layout->convertFromARGB32PM(&result, &index_or_rgb, 1, layout, 0); executed (the execution status of this line is deduced): const uint *ptr = layout->convertFromARGB32PM(&result, &index_or_rgb, 1, layout, 0); | - |
3731 | qStorePixels[layout->bpp](s, ptr, x, 1); executed (the execution status of this line is deduced): qStorePixels[layout->bpp](s, ptr, x, 1); | - |
3732 | } executed: } Execution Count:20965 | 20965 |
3733 | | - |
3734 | /*! | - |
3735 | Returns true if all the colors in the image are shades of gray | - |
3736 | (i.e. their red, green and blue components are equal); otherwise | - |
3737 | false. | - |
3738 | | - |
3739 | Note that this function is slow for images without color table. | - |
3740 | | - |
3741 | \sa isGrayscale() | - |
3742 | */ | - |
3743 | bool QImage::allGray() const | - |
3744 | { | - |
3745 | if (!d) | 0 |
3746 | return true; never executed: return true; | 0 |
3747 | | - |
3748 | switch (d->format) { | - |
3749 | case Format_Mono: | - |
3750 | case Format_MonoLSB: | - |
3751 | case Format_Indexed8: | - |
3752 | for (int i = 0; i < d->colortable.size(); ++i) { never evaluated: i < d->colortable.size() | 0 |
3753 | if (!qIsGray(d->colortable.at(i))) never evaluated: !qIsGray(d->colortable.at(i)) | 0 |
3754 | return false; never executed: return false; | 0 |
3755 | } | 0 |
3756 | return true; never executed: return true; | 0 |
3757 | case Format_RGB32: | - |
3758 | case Format_ARGB32: | - |
3759 | case Format_ARGB32_Premultiplied: | - |
3760 | for (int j = 0; j < d->height; ++j) { never evaluated: j < d->height | 0 |
3761 | const QRgb *b = (const QRgb *)constScanLine(j); never executed (the execution status of this line is deduced): const QRgb *b = (const QRgb *)constScanLine(j); | - |
3762 | for (int i = 0; i < d->width; ++i) { never evaluated: i < d->width | 0 |
3763 | if (!qIsGray(b[i])) never evaluated: !qIsGray(b[i]) | 0 |
3764 | return false; never executed: return false; | 0 |
3765 | } | 0 |
3766 | } | 0 |
3767 | return true; never executed: return true; | 0 |
3768 | case Format_RGB16: | - |
3769 | for (int j = 0; j < d->height; ++j) { never evaluated: j < d->height | 0 |
3770 | const quint16 *b = (const quint16 *)constScanLine(j); never executed (the execution status of this line is deduced): const quint16 *b = (const quint16 *)constScanLine(j); | - |
3771 | for (int i = 0; i < d->width; ++i) { never evaluated: i < d->width | 0 |
3772 | if (!qIsGray(qConvertRgb16To32(b[i]))) never evaluated: !qIsGray(qConvertRgb16To32(b[i])) | 0 |
3773 | return false; never executed: return false; | 0 |
3774 | } | 0 |
3775 | } | 0 |
3776 | return true; never executed: return true; | 0 |
3777 | default: | - |
3778 | break; | 0 |
3779 | } | - |
3780 | | - |
3781 | const int buffer_size = 2048; never executed (the execution status of this line is deduced): const int buffer_size = 2048; | - |
3782 | uint buffer[buffer_size]; never executed (the execution status of this line is deduced): uint buffer[buffer_size]; | - |
3783 | const QPixelLayout *layout = &qPixelLayouts[d->format]; never executed (the execution status of this line is deduced): const QPixelLayout *layout = &qPixelLayouts[d->format]; | - |
3784 | FetchPixelsFunc fetch = qFetchPixels[layout->bpp]; never executed (the execution status of this line is deduced): FetchPixelsFunc fetch = qFetchPixels[layout->bpp]; | - |
3785 | for (int j = 0; j < d->height; ++j) { never evaluated: j < d->height | 0 |
3786 | const uchar *b = constScanLine(j); never executed (the execution status of this line is deduced): const uchar *b = constScanLine(j); | - |
3787 | int x = 0; never executed (the execution status of this line is deduced): int x = 0; | - |
3788 | while (x < d->width) { never evaluated: x < d->width | 0 |
3789 | int l = qMin(d->width - x, buffer_size); never executed (the execution status of this line is deduced): int l = qMin(d->width - x, buffer_size); | - |
3790 | const uint *ptr = fetch(buffer, b, x, l); never executed (the execution status of this line is deduced): const uint *ptr = fetch(buffer, b, x, l); | - |
3791 | ptr = layout->convertToARGB32PM(buffer, ptr, l, layout, 0); never executed (the execution status of this line is deduced): ptr = layout->convertToARGB32PM(buffer, ptr, l, layout, 0); | - |
3792 | for (int i = 0; i < l; ++i) { | 0 |
3793 | if (!qIsGray(ptr[i])) never evaluated: !qIsGray(ptr[i]) | 0 |
3794 | return false; never executed: return false; | 0 |
3795 | } | 0 |
3796 | x += l; never executed (the execution status of this line is deduced): x += l; | - |
3797 | } | 0 |
3798 | } | 0 |
3799 | return true; never executed: return true; | 0 |
3800 | } | - |
3801 | | - |
3802 | /*! | - |
3803 | For 32-bit images, this function is equivalent to allGray(). | - |
3804 | | - |
3805 | For 8-bpp images, this function returns true if color(i) is | - |
3806 | QRgb(i, i, i) for all indexes of the color table; otherwise | - |
3807 | returns false. | - |
3808 | | - |
3809 | \sa allGray(), {QImage#Image Formats}{Image Formats} | - |
3810 | */ | - |
3811 | bool QImage::isGrayscale() const | - |
3812 | { | - |
3813 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:37 |
| 0-37 |
3814 | return false; never executed: return false; | 0 |
3815 | | - |
3816 | switch (depth()) { | - |
3817 | case 32: | - |
3818 | case 24: | - |
3819 | case 16: | - |
3820 | return allGray(); never executed: return allGray(); | 0 |
3821 | case 8: { | - |
3822 | for (int i = 0; i < colorCount(); i++) evaluated: i < colorCount() yes Evaluation Count:3082 | yes Evaluation Count:12 |
| 12-3082 |
3823 | if (d->colortable.at(i) != qRgb(i,i,i)) evaluated: d->colortable.at(i) != qRgb(i,i,i) yes Evaluation Count:8 | yes Evaluation Count:3074 |
| 8-3074 |
3824 | return false; executed: return false; Execution Count:8 | 8 |
3825 | return true; executed: return true; Execution Count:12 | 12 |
3826 | } | - |
3827 | } | - |
3828 | return false; executed: return false; Execution Count:17 | 17 |
3829 | } | - |
3830 | | - |
3831 | /*! | - |
3832 | \fn QImage QImage::scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode, | - |
3833 | Qt::TransformationMode transformMode) const | - |
3834 | \overload | - |
3835 | | - |
3836 | Returns a copy of the image scaled to a rectangle with the given | - |
3837 | \a width and \a height according to the given \a aspectRatioMode | - |
3838 | and \a transformMode. | - |
3839 | | - |
3840 | If either the \a width or the \a height is zero or negative, this | - |
3841 | function returns a null image. | - |
3842 | */ | - |
3843 | | - |
3844 | /*! | - |
3845 | \fn QImage QImage::scaled(const QSize &size, Qt::AspectRatioMode aspectRatioMode, | - |
3846 | Qt::TransformationMode transformMode) const | - |
3847 | | - |
3848 | Returns a copy of the image scaled to a rectangle defined by the | - |
3849 | given \a size according to the given \a aspectRatioMode and \a | - |
3850 | transformMode. | - |
3851 | | - |
3852 | \image qimage-scaling.png | - |
3853 | | - |
3854 | \list | - |
3855 | \li If \a aspectRatioMode is Qt::IgnoreAspectRatio, the image | - |
3856 | is scaled to \a size. | - |
3857 | \li If \a aspectRatioMode is Qt::KeepAspectRatio, the image is | - |
3858 | scaled to a rectangle as large as possible inside \a size, preserving the aspect ratio. | - |
3859 | \li If \a aspectRatioMode is Qt::KeepAspectRatioByExpanding, | - |
3860 | the image is scaled to a rectangle as small as possible | - |
3861 | outside \a size, preserving the aspect ratio. | - |
3862 | \endlist | - |
3863 | | - |
3864 | If the given \a size is empty, this function returns a null image. | - |
3865 | | - |
3866 | \sa isNull(), {QImage#Image Transformations}{Image | - |
3867 | Transformations} | - |
3868 | */ | - |
3869 | QImage QImage::scaled(const QSize& s, Qt::AspectRatioMode aspectMode, Qt::TransformationMode mode) const | - |
3870 | { | - |
3871 | if (!d) { partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:169 |
| 0-169 |
3872 | qWarning("QImage::scaled: Image is a null image"); never executed (the execution status of this line is deduced): QMessageLogger("image/qimage.cpp", 3872, __PRETTY_FUNCTION__).warning("QImage::scaled: Image is a null image"); | - |
3873 | return QImage(); never executed: return QImage(); | 0 |
3874 | } | - |
3875 | if (s.isEmpty()) evaluated: s.isEmpty() yes Evaluation Count:19 | yes Evaluation Count:150 |
| 19-150 |
3876 | return QImage(); executed: return QImage(); Execution Count:19 | 19 |
3877 | | - |
3878 | QSize newSize = size(); executed (the execution status of this line is deduced): QSize newSize = size(); | - |
3879 | newSize.scale(s, aspectMode); executed (the execution status of this line is deduced): newSize.scale(s, aspectMode); | - |
3880 | newSize.rwidth() = qMax(newSize.width(), 1); executed (the execution status of this line is deduced): newSize.rwidth() = qMax(newSize.width(), 1); | - |
3881 | newSize.rheight() = qMax(newSize.height(), 1); executed (the execution status of this line is deduced): newSize.rheight() = qMax(newSize.height(), 1); | - |
3882 | if (newSize == size()) evaluated: newSize == size() yes Evaluation Count:2 | yes Evaluation Count:148 |
| 2-148 |
3883 | return *this; executed: return *this; Execution Count:2 | 2 |
3884 | | - |
3885 | QTransform wm = QTransform::fromScale((qreal)newSize.width() / width(), (qreal)newSize.height() / height()); executed (the execution status of this line is deduced): QTransform wm = QTransform::fromScale((qreal)newSize.width() / width(), (qreal)newSize.height() / height()); | - |
3886 | QImage img = transformed(wm, mode); executed (the execution status of this line is deduced): QImage img = transformed(wm, mode); | - |
3887 | return img; executed: return img; Execution Count:148 | 148 |
3888 | } | - |
3889 | | - |
3890 | /*! | - |
3891 | \fn QImage QImage::scaledToWidth(int width, Qt::TransformationMode mode) const | - |
3892 | | - |
3893 | Returns a scaled copy of the image. The returned image is scaled | - |
3894 | to the given \a width using the specified transformation \a | - |
3895 | mode. | - |
3896 | | - |
3897 | This function automatically calculates the height of the image so | - |
3898 | that its aspect ratio is preserved. | - |
3899 | | - |
3900 | If the given \a width is 0 or negative, a null image is returned. | - |
3901 | | - |
3902 | \sa {QImage#Image Transformations}{Image Transformations} | - |
3903 | */ | - |
3904 | QImage QImage::scaledToWidth(int w, Qt::TransformationMode mode) const | - |
3905 | { | - |
3906 | if (!d) { | 0 |
3907 | qWarning("QImage::scaleWidth: Image is a null image"); never executed (the execution status of this line is deduced): QMessageLogger("image/qimage.cpp", 3907, __PRETTY_FUNCTION__).warning("QImage::scaleWidth: Image is a null image"); | - |
3908 | return QImage(); never executed: return QImage(); | 0 |
3909 | } | - |
3910 | if (w <= 0) | 0 |
3911 | return QImage(); never executed: return QImage(); | 0 |
3912 | | - |
3913 | qreal factor = (qreal) w / width(); never executed (the execution status of this line is deduced): qreal factor = (qreal) w / width(); | - |
3914 | QTransform wm = QTransform::fromScale(factor, factor); never executed (the execution status of this line is deduced): QTransform wm = QTransform::fromScale(factor, factor); | - |
3915 | return transformed(wm, mode); never executed: return transformed(wm, mode); | 0 |
3916 | } | - |
3917 | | - |
3918 | /*! | - |
3919 | \fn QImage QImage::scaledToHeight(int height, Qt::TransformationMode mode) const | - |
3920 | | - |
3921 | Returns a scaled copy of the image. The returned image is scaled | - |
3922 | to the given \a height using the specified transformation \a | - |
3923 | mode. | - |
3924 | | - |
3925 | This function automatically calculates the width of the image so that | - |
3926 | the ratio of the image is preserved. | - |
3927 | | - |
3928 | If the given \a height is 0 or negative, a null image is returned. | - |
3929 | | - |
3930 | \sa {QImage#Image Transformations}{Image Transformations} | - |
3931 | */ | - |
3932 | QImage QImage::scaledToHeight(int h, Qt::TransformationMode mode) const | - |
3933 | { | - |
3934 | if (!d) { | 0 |
3935 | qWarning("QImage::scaleHeight: Image is a null image"); never executed (the execution status of this line is deduced): QMessageLogger("image/qimage.cpp", 3935, __PRETTY_FUNCTION__).warning("QImage::scaleHeight: Image is a null image"); | - |
3936 | return QImage(); never executed: return QImage(); | 0 |
3937 | } | - |
3938 | if (h <= 0) | 0 |
3939 | return QImage(); never executed: return QImage(); | 0 |
3940 | | - |
3941 | qreal factor = (qreal) h / height(); never executed (the execution status of this line is deduced): qreal factor = (qreal) h / height(); | - |
3942 | QTransform wm = QTransform::fromScale(factor, factor); never executed (the execution status of this line is deduced): QTransform wm = QTransform::fromScale(factor, factor); | - |
3943 | return transformed(wm, mode); never executed: return transformed(wm, mode); | 0 |
3944 | } | - |
3945 | | - |
3946 | | - |
3947 | /*! | - |
3948 | \fn QMatrix QImage::trueMatrix(const QMatrix &matrix, int width, int height) | - |
3949 | | - |
3950 | Returns the actual matrix used for transforming an image with the | - |
3951 | given \a width, \a height and \a matrix. | - |
3952 | | - |
3953 | When transforming an image using the transformed() function, the | - |
3954 | transformation matrix is internally adjusted to compensate for | - |
3955 | unwanted translation, i.e. transformed() returns the smallest | - |
3956 | image containing all transformed points of the original image. | - |
3957 | This function returns the modified matrix, which maps points | - |
3958 | correctly from the original image into the new image. | - |
3959 | | - |
3960 | \sa transformed(), {QImage#Image Transformations}{Image | - |
3961 | Transformations} | - |
3962 | */ | - |
3963 | QMatrix QImage::trueMatrix(const QMatrix &matrix, int w, int h) | - |
3964 | { | - |
3965 | return trueMatrix(QTransform(matrix), w, h).toAffine(); never executed: return trueMatrix(QTransform(matrix), w, h).toAffine(); | 0 |
3966 | } | - |
3967 | | - |
3968 | /*! | - |
3969 | Returns a copy of the image that is transformed using the given | - |
3970 | transformation \a matrix and transformation \a mode. | - |
3971 | | - |
3972 | The transformation \a matrix is internally adjusted to compensate | - |
3973 | for unwanted translation; i.e. the image produced is the smallest | - |
3974 | image that contains all the transformed points of the original | - |
3975 | image. Use the trueMatrix() function to retrieve the actual matrix | - |
3976 | used for transforming an image. | - |
3977 | | - |
3978 | \sa trueMatrix(), {QImage#Image Transformations}{Image | - |
3979 | Transformations} | - |
3980 | */ | - |
3981 | QImage QImage::transformed(const QMatrix &matrix, Qt::TransformationMode mode) const | - |
3982 | { | - |
3983 | return transformed(QTransform(matrix), mode); executed: return transformed(QTransform(matrix), mode); Execution Count:320 | 320 |
3984 | } | - |
3985 | | - |
3986 | /*! | - |
3987 | Builds and returns a 1-bpp mask from the alpha buffer in this | - |
3988 | image. Returns a null image if the image's format is | - |
3989 | QImage::Format_RGB32. | - |
3990 | | - |
3991 | The \a flags argument is a bitwise-OR of the | - |
3992 | Qt::ImageConversionFlags, and controls the conversion | - |
3993 | process. Passing 0 for flags sets all the default options. | - |
3994 | | - |
3995 | The returned image has little-endian bit order (i.e. the image's | - |
3996 | format is QImage::Format_MonoLSB), which you can convert to | - |
3997 | big-endian (QImage::Format_Mono) using the convertToFormat() | - |
3998 | function. | - |
3999 | | - |
4000 | \sa createHeuristicMask(), {QImage#Image Transformations}{Image | - |
4001 | Transformations} | - |
4002 | */ | - |
4003 | QImage QImage::createAlphaMask(Qt::ImageConversionFlags flags) const | - |
4004 | { | - |
4005 | if (!d || d->format == QImage::Format_RGB32) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:260 |
partially evaluated: d->format == QImage::Format_RGB32 no Evaluation Count:0 | yes Evaluation Count:260 |
| 0-260 |
4006 | return QImage(); never executed: return QImage(); | 0 |
4007 | | - |
4008 | if (d->depth == 1) { evaluated: d->depth == 1 yes Evaluation Count:103 | yes Evaluation Count:157 |
| 103-157 |
4009 | // A monochrome pixmap, with alpha channels on those two colors. | - |
4010 | // Pretty unlikely, so use less efficient solution. | - |
4011 | return convertToFormat(Format_Indexed8, flags).createAlphaMask(flags); executed: return convertToFormat(Format_Indexed8, flags).createAlphaMask(flags); Execution Count:103 | 103 |
4012 | } | - |
4013 | | - |
4014 | QImage mask(d->width, d->height, Format_MonoLSB); executed (the execution status of this line is deduced): QImage mask(d->width, d->height, Format_MonoLSB); | - |
4015 | if (!mask.isNull()) partially evaluated: !mask.isNull() yes Evaluation Count:157 | no Evaluation Count:0 |
| 0-157 |
4016 | dither_to_Mono(mask.d, d, flags, true); executed: dither_to_Mono(mask.d, d, flags, true); Execution Count:157 | 157 |
4017 | return mask; executed: return mask; Execution Count:157 | 157 |
4018 | } | - |
4019 | | - |
4020 | #ifndef QT_NO_IMAGE_HEURISTIC_MASK | - |
4021 | /*! | - |
4022 | Creates and returns a 1-bpp heuristic mask for this image. | - |
4023 | | - |
4024 | The function works by selecting a color from one of the corners, | - |
4025 | then chipping away pixels of that color starting at all the edges. | - |
4026 | The four corners vote for which color is to be masked away. In | - |
4027 | case of a draw (this generally means that this function is not | - |
4028 | applicable to the image), the result is arbitrary. | - |
4029 | | - |
4030 | The returned image has little-endian bit order (i.e. the image's | - |
4031 | format is QImage::Format_MonoLSB), which you can convert to | - |
4032 | big-endian (QImage::Format_Mono) using the convertToFormat() | - |
4033 | function. | - |
4034 | | - |
4035 | If \a clipTight is true (the default) the mask is just large | - |
4036 | enough to cover the pixels; otherwise, the mask is larger than the | - |
4037 | data pixels. | - |
4038 | | - |
4039 | Note that this function disregards the alpha buffer. | - |
4040 | | - |
4041 | \sa createAlphaMask(), {QImage#Image Transformations}{Image | - |
4042 | Transformations} | - |
4043 | */ | - |
4044 | | - |
4045 | QImage QImage::createHeuristicMask(bool clipTight) const | - |
4046 | { | - |
4047 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
4048 | return QImage(); never executed: return QImage(); | 0 |
4049 | | - |
4050 | if (d->depth != 32) { evaluated: d->depth != 32 yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
4051 | QImage img32 = convertToFormat(Format_RGB32); executed (the execution status of this line is deduced): QImage img32 = convertToFormat(Format_RGB32); | - |
4052 | return img32.createHeuristicMask(clipTight); executed: return img32.createHeuristicMask(clipTight); Execution Count:1 | 1 |
4053 | } | - |
4054 | | - |
4055 | #define PIX(x,y) (*((QRgb*)scanLine(y)+x) & 0x00ffffff) | - |
4056 | | - |
4057 | int w = width(); executed (the execution status of this line is deduced): int w = width(); | - |
4058 | int h = height(); executed (the execution status of this line is deduced): int h = height(); | - |
4059 | QImage m(w, h, Format_MonoLSB); executed (the execution status of this line is deduced): QImage m(w, h, Format_MonoLSB); | - |
4060 | QIMAGE_SANITYCHECK_MEMORY(m); never executed: return QImage(); partially evaluated: (m).isNull() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
4061 | m.setColorCount(2); executed (the execution status of this line is deduced): m.setColorCount(2); | - |
4062 | m.setColor(0, QColor(Qt::color0).rgba()); executed (the execution status of this line is deduced): m.setColor(0, QColor(Qt::color0).rgba()); | - |
4063 | m.setColor(1, QColor(Qt::color1).rgba()); executed (the execution status of this line is deduced): m.setColor(1, QColor(Qt::color1).rgba()); | - |
4064 | m.fill(0xff); executed (the execution status of this line is deduced): m.fill(0xff); | - |
4065 | | - |
4066 | QRgb background = PIX(0,0); executed (the execution status of this line is deduced): QRgb background = (*((QRgb*)scanLine(0)+0) & 0x00ffffff); | - |
4067 | if (background != PIX(w-1,0) && partially evaluated: background != (*((QRgb*)scanLine(0)+w-1) & 0x00ffffff) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
4068 | background != PIX(0,h-1) && never evaluated: background != (*((QRgb*)scanLine(h-1)+0) & 0x00ffffff) | 0 |
4069 | background != PIX(w-1,h-1)) { never evaluated: background != (*((QRgb*)scanLine(h-1)+w-1) & 0x00ffffff) | 0 |
4070 | background = PIX(w-1,0); never executed (the execution status of this line is deduced): background = (*((QRgb*)scanLine(0)+w-1) & 0x00ffffff); | - |
4071 | if (background != PIX(w-1,h-1) && never evaluated: background != (*((QRgb*)scanLine(h-1)+w-1) & 0x00ffffff) | 0 |
4072 | background != PIX(0,h-1) && never evaluated: background != (*((QRgb*)scanLine(h-1)+0) & 0x00ffffff) | 0 |
4073 | PIX(0,h-1) == PIX(w-1,h-1)) { never evaluated: (*((QRgb*)scanLine(h-1)+0) & 0x00ffffff) == (*((QRgb*)scanLine(h-1)+w-1) & 0x00ffffff) | 0 |
4074 | background = PIX(w-1,h-1); never executed (the execution status of this line is deduced): background = (*((QRgb*)scanLine(h-1)+w-1) & 0x00ffffff); | - |
4075 | } | 0 |
4076 | } | 0 |
4077 | | - |
4078 | int x,y; executed (the execution status of this line is deduced): int x,y; | - |
4079 | bool done = false; executed (the execution status of this line is deduced): bool done = false; | - |
4080 | uchar *ypp, *ypc, *ypn; executed (the execution status of this line is deduced): uchar *ypp, *ypc, *ypn; | - |
4081 | while(!done) { evaluated: !done yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
4082 | done = true; executed (the execution status of this line is deduced): done = true; | - |
4083 | ypn = m.scanLine(0); executed (the execution status of this line is deduced): ypn = m.scanLine(0); | - |
4084 | ypc = 0; executed (the execution status of this line is deduced): ypc = 0; | - |
4085 | for (y = 0; y < h; y++) { evaluated: y < h yes Evaluation Count:8 | yes Evaluation Count:2 |
| 2-8 |
4086 | ypp = ypc; executed (the execution status of this line is deduced): ypp = ypc; | - |
4087 | ypc = ypn; executed (the execution status of this line is deduced): ypc = ypn; | - |
4088 | ypn = (y == h-1) ? 0 : m.scanLine(y+1); evaluated: (y == h-1) yes Evaluation Count:2 | yes Evaluation Count:6 |
| 2-6 |
4089 | QRgb *p = (QRgb *)scanLine(y); executed (the execution status of this line is deduced): QRgb *p = (QRgb *)scanLine(y); | - |
4090 | for (x = 0; x < w; x++) { evaluated: x < w yes Evaluation Count:32 | yes Evaluation Count:8 |
| 8-32 |
4091 | // slowness here - it's possible to do six of these tests | - |
4092 | // together in one go. oh well. | - |
4093 | if ((x == 0 || y == 0 || x == w-1 || y == h-1 || evaluated: x == 0 yes Evaluation Count:8 | yes Evaluation Count:24 |
evaluated: y == 0 yes Evaluation Count:6 | yes Evaluation Count:18 |
evaluated: x == w-1 yes Evaluation Count:6 | yes Evaluation Count:12 |
evaluated: y == h-1 yes Evaluation Count:4 | yes Evaluation Count:8 |
| 4-24 |
4094 | !(*(ypc + ((x-1) >> 3)) & (1 << ((x-1) & 7))) || evaluated: !(*(ypc + ((x-1) >> 3)) & (1 << ((x-1) & 7))) yes Evaluation Count:4 | yes Evaluation Count:4 |
| 4 |
4095 | !(*(ypc + ((x+1) >> 3)) & (1 << ((x+1) & 7))) || evaluated: !(*(ypc + ((x+1) >> 3)) & (1 << ((x+1) & 7))) yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
4096 | !(*(ypp + (x >> 3)) & (1 << (x & 7))) || evaluated: !(*(ypp + (x >> 3)) & (1 << (x & 7))) yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
4097 | !(*(ypn + (x >> 3)) & (1 << (x & 7)))) && partially evaluated: !(*(ypn + (x >> 3)) & (1 << (x & 7))) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
4098 | ( (*(ypc + (x >> 3)) & (1 << (x & 7)))) && evaluated: ( (*(ypc + (x >> 3)) & (1 << (x & 7)))) yes Evaluation Count:19 | yes Evaluation Count:12 |
| 12-19 |
4099 | ((*p & 0x00ffffff) == background)) { evaluated: ((*p & 0x00ffffff) == background) yes Evaluation Count:12 | yes Evaluation Count:7 |
| 7-12 |
4100 | done = false; executed (the execution status of this line is deduced): done = false; | - |
4101 | *(ypc + (x >> 3)) &= ~(1 << (x & 7)); executed (the execution status of this line is deduced): *(ypc + (x >> 3)) &= ~(1 << (x & 7)); | - |
4102 | } executed: } Execution Count:12 | 12 |
4103 | p++; executed (the execution status of this line is deduced): p++; | - |
4104 | } executed: } Execution Count:32 | 32 |
4105 | } executed: } Execution Count:8 | 8 |
4106 | } executed: } Execution Count:2 | 2 |
4107 | | - |
4108 | if (!clipTight) { partially evaluated: !clipTight no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
4109 | ypn = m.scanLine(0); never executed (the execution status of this line is deduced): ypn = m.scanLine(0); | - |
4110 | ypc = 0; never executed (the execution status of this line is deduced): ypc = 0; | - |
4111 | for (y = 0; y < h; y++) { | 0 |
4112 | ypp = ypc; never executed (the execution status of this line is deduced): ypp = ypc; | - |
4113 | ypc = ypn; never executed (the execution status of this line is deduced): ypc = ypn; | - |
4114 | ypn = (y == h-1) ? 0 : m.scanLine(y+1); never evaluated: (y == h-1) | 0 |
4115 | QRgb *p = (QRgb *)scanLine(y); never executed (the execution status of this line is deduced): QRgb *p = (QRgb *)scanLine(y); | - |
4116 | for (x = 0; x < w; x++) { | 0 |
4117 | if ((*p & 0x00ffffff) != background) { never evaluated: (*p & 0x00ffffff) != background | 0 |
4118 | if (x > 0) | 0 |
4119 | *(ypc + ((x-1) >> 3)) |= (1 << ((x-1) & 7)); never executed: *(ypc + ((x-1) >> 3)) |= (1 << ((x-1) & 7)); | 0 |
4120 | if (x < w-1) | 0 |
4121 | *(ypc + ((x+1) >> 3)) |= (1 << ((x+1) & 7)); never executed: *(ypc + ((x+1) >> 3)) |= (1 << ((x+1) & 7)); | 0 |
4122 | if (y > 0) | 0 |
4123 | *(ypp + (x >> 3)) |= (1 << (x & 7)); never executed: *(ypp + (x >> 3)) |= (1 << (x & 7)); | 0 |
4124 | if (y < h-1) | 0 |
4125 | *(ypn + (x >> 3)) |= (1 << (x & 7)); never executed: *(ypn + (x >> 3)) |= (1 << (x & 7)); | 0 |
4126 | } | 0 |
4127 | p++; never executed (the execution status of this line is deduced): p++; | - |
4128 | } | 0 |
4129 | } | 0 |
4130 | } | 0 |
4131 | | - |
4132 | #undef PIX | - |
4133 | | - |
4134 | return m; executed: return m; Execution Count:1 | 1 |
4135 | } | - |
4136 | #endif //QT_NO_IMAGE_HEURISTIC_MASK | - |
4137 | | - |
4138 | /*! | - |
4139 | Creates and returns a mask for this image based on the given \a | - |
4140 | color value. If the \a mode is MaskInColor (the default value), | - |
4141 | all pixels matching \a color will be opaque pixels in the mask. If | - |
4142 | \a mode is MaskOutColor, all pixels matching the given color will | - |
4143 | be transparent. | - |
4144 | | - |
4145 | \sa createAlphaMask(), createHeuristicMask() | - |
4146 | */ | - |
4147 | | - |
4148 | QImage QImage::createMaskFromColor(QRgb color, Qt::MaskMode mode) const | - |
4149 | { | - |
4150 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
4151 | return QImage(); never executed: return QImage(); | 0 |
4152 | QImage maskImage(size(), QImage::Format_MonoLSB); executed (the execution status of this line is deduced): QImage maskImage(size(), QImage::Format_MonoLSB); | - |
4153 | QIMAGE_SANITYCHECK_MEMORY(maskImage); never executed: return QImage(); partially evaluated: (maskImage).isNull() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
4154 | maskImage.fill(0); executed (the execution status of this line is deduced): maskImage.fill(0); | - |
4155 | uchar *s = maskImage.bits(); executed (the execution status of this line is deduced): uchar *s = maskImage.bits(); | - |
4156 | | - |
4157 | if (depth() == 32) { evaluated: depth() == 32 yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
4158 | for (int h = 0; h < d->height; h++) { evaluated: h < d->height yes Evaluation Count:106 | yes Evaluation Count:3 |
| 3-106 |
4159 | const uint *sl = (uint *) scanLine(h); executed (the execution status of this line is deduced): const uint *sl = (uint *) scanLine(h); | - |
4160 | for (int w = 0; w < d->width; w++) { evaluated: w < d->width yes Evaluation Count:10018 | yes Evaluation Count:106 |
| 106-10018 |
4161 | if (sl[w] == color) evaluated: sl[w] == color yes Evaluation Count:10002 | yes Evaluation Count:16 |
| 16-10002 |
4162 | *(s + (w >> 3)) |= (1 << (w & 7)); executed: *(s + (w >> 3)) |= (1 << (w & 7)); Execution Count:10002 | 10002 |
4163 | } executed: } Execution Count:10018 | 10018 |
4164 | s += maskImage.bytesPerLine(); executed (the execution status of this line is deduced): s += maskImage.bytesPerLine(); | - |
4165 | } executed: } Execution Count:106 | 106 |
4166 | } else { executed: } Execution Count:3 | 3 |
4167 | for (int h = 0; h < d->height; h++) { evaluated: h < d->height yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
4168 | for (int w = 0; w < d->width; w++) { evaluated: w < d->width yes Evaluation Count:9 | yes Evaluation Count:3 |
| 3-9 |
4169 | if ((uint) pixel(w, h) == color) evaluated: (uint) pixel(w, h) == color yes Evaluation Count:1 | yes Evaluation Count:8 |
| 1-8 |
4170 | *(s + (w >> 3)) |= (1 << (w & 7)); executed: *(s + (w >> 3)) |= (1 << (w & 7)); Execution Count:1 | 1 |
4171 | } executed: } Execution Count:9 | 9 |
4172 | s += maskImage.bytesPerLine(); executed (the execution status of this line is deduced): s += maskImage.bytesPerLine(); | - |
4173 | } executed: } Execution Count:3 | 3 |
4174 | } executed: } Execution Count:1 | 1 |
4175 | if (mode == Qt::MaskOutColor) evaluated: mode == Qt::MaskOutColor yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
4176 | maskImage.invertPixels(); executed: maskImage.invertPixels(); Execution Count:1 | 1 |
4177 | return maskImage; executed: return maskImage; Execution Count:4 | 4 |
4178 | } | - |
4179 | | - |
4180 | | - |
4181 | /* | - |
4182 | This code is contributed by Philipp Lang, | - |
4183 | GeneriCom Software Germany (www.generi.com) | - |
4184 | under the terms of the QPL, Version 1.0 | - |
4185 | */ | - |
4186 | | - |
4187 | /*! | - |
4188 | Returns a mirror of the image, mirrored in the horizontal and/or | - |
4189 | the vertical direction depending on whether \a horizontal and \a | - |
4190 | vertical are set to true or false. | - |
4191 | | - |
4192 | Note that the original image is not changed. | - |
4193 | | - |
4194 | \sa {QImage#Image Transformations}{Image Transformations} | - |
4195 | */ | - |
4196 | QImage QImage::mirrored(bool horizontal, bool vertical) const | - |
4197 | { | - |
4198 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:128 |
| 0-128 |
4199 | return QImage(); never executed: return QImage(); | 0 |
4200 | | - |
4201 | if ((d->width <= 1 && d->height <= 1) || (!horizontal && !vertical)) partially evaluated: d->width <= 1 no Evaluation Count:0 | yes Evaluation Count:128 |
never evaluated: d->height <= 1 partially evaluated: !horizontal no Evaluation Count:0 | yes Evaluation Count:128 |
never evaluated: !vertical | 0-128 |
4202 | return *this; never executed: return *this; | 0 |
4203 | | - |
4204 | int w = d->width; executed (the execution status of this line is deduced): int w = d->width; | - |
4205 | int h = d->height; executed (the execution status of this line is deduced): int h = d->height; | - |
4206 | // Create result image, copy colormap | - |
4207 | QImage result(d->width, d->height, d->format); executed (the execution status of this line is deduced): QImage result(d->width, d->height, d->format); | - |
4208 | QIMAGE_SANITYCHECK_MEMORY(result); never executed: return QImage(); partially evaluated: (result).isNull() no Evaluation Count:0 | yes Evaluation Count:128 |
| 0-128 |
4209 | | - |
4210 | // check if we ran out of of memory.. | - |
4211 | if (!result.d) partially evaluated: !result.d no Evaluation Count:0 | yes Evaluation Count:128 |
| 0-128 |
4212 | return QImage(); never executed: return QImage(); | 0 |
4213 | | - |
4214 | result.d->colortable = d->colortable; executed (the execution status of this line is deduced): result.d->colortable = d->colortable; | - |
4215 | result.d->has_alpha_clut = d->has_alpha_clut; executed (the execution status of this line is deduced): result.d->has_alpha_clut = d->has_alpha_clut; | - |
4216 | result.d->devicePixelRatio = d->devicePixelRatio; executed (the execution status of this line is deduced): result.d->devicePixelRatio = d->devicePixelRatio; | - |
4217 | | - |
4218 | if (depth() == 1) partially evaluated: depth() == 1 no Evaluation Count:0 | yes Evaluation Count:128 |
| 0-128 |
4219 | w = (w+7)/8; never executed: w = (w+7)/8; | 0 |
4220 | int dxi = horizontal ? -1 : 1; partially evaluated: horizontal yes Evaluation Count:128 | no Evaluation Count:0 |
| 0-128 |
4221 | int dxs = horizontal ? w-1 : 0; partially evaluated: horizontal yes Evaluation Count:128 | no Evaluation Count:0 |
| 0-128 |
4222 | int dyi = vertical ? -1 : 1; partially evaluated: vertical yes Evaluation Count:128 | no Evaluation Count:0 |
| 0-128 |
4223 | int dy = vertical ? h-1: 0; partially evaluated: vertical yes Evaluation Count:128 | no Evaluation Count:0 |
| 0-128 |
4224 | | - |
4225 | // 1 bit, 8 bit | - |
4226 | if (d->depth == 1 || d->depth == 8) { partially evaluated: d->depth == 1 no Evaluation Count:0 | yes Evaluation Count:128 |
evaluated: d->depth == 8 yes Evaluation Count:12 | yes Evaluation Count:116 |
| 0-128 |
4227 | for (int sy = 0; sy < h; sy++, dy += dyi) { evaluated: sy < h yes Evaluation Count:156 | yes Evaluation Count:12 |
| 12-156 |
4228 | quint8* ssl = (quint8*)(d->data + sy*d->bytes_per_line); executed (the execution status of this line is deduced): quint8* ssl = (quint8*)(d->data + sy*d->bytes_per_line); | - |
4229 | quint8* dsl = (quint8*)(result.d->data + dy*result.d->bytes_per_line); executed (the execution status of this line is deduced): quint8* dsl = (quint8*)(result.d->data + dy*result.d->bytes_per_line); | - |
4230 | int dx = dxs; executed (the execution status of this line is deduced): int dx = dxs; | - |
4231 | for (int sx = 0; sx < w; sx++, dx += dxi) evaluated: sx < w yes Evaluation Count:8424 | yes Evaluation Count:156 |
| 156-8424 |
4232 | dsl[dx] = ssl[sx]; executed: dsl[dx] = ssl[sx]; Execution Count:8424 | 8424 |
4233 | } executed: } Execution Count:156 | 156 |
4234 | } executed: } Execution Count:12 | 12 |
4235 | // 16 bit | - |
4236 | else if (d->depth == 16) { evaluated: d->depth == 16 yes Evaluation Count:24 | yes Evaluation Count:92 |
| 24-92 |
4237 | for (int sy = 0; sy < h; sy++, dy += dyi) { evaluated: sy < h yes Evaluation Count:312 | yes Evaluation Count:24 |
| 24-312 |
4238 | quint16* ssl = (quint16*)(d->data + sy*d->bytes_per_line); executed (the execution status of this line is deduced): quint16* ssl = (quint16*)(d->data + sy*d->bytes_per_line); | - |
4239 | quint16* dsl = (quint16*)(result.d->data + dy*result.d->bytes_per_line); executed (the execution status of this line is deduced): quint16* dsl = (quint16*)(result.d->data + dy*result.d->bytes_per_line); | - |
4240 | int dx = dxs; executed (the execution status of this line is deduced): int dx = dxs; | - |
4241 | for (int sx = 0; sx < w; sx++, dx += dxi) evaluated: sx < w yes Evaluation Count:16848 | yes Evaluation Count:312 |
| 312-16848 |
4242 | dsl[dx] = ssl[sx]; executed: dsl[dx] = ssl[sx]; Execution Count:16848 | 16848 |
4243 | } executed: } Execution Count:312 | 312 |
4244 | } executed: } Execution Count:24 | 24 |
4245 | // 24 bit | - |
4246 | else if (d->depth == 24) { evaluated: d->depth == 24 yes Evaluation Count:48 | yes Evaluation Count:44 |
| 44-48 |
4247 | for (int sy = 0; sy < h; sy++, dy += dyi) { evaluated: sy < h yes Evaluation Count:624 | yes Evaluation Count:48 |
| 48-624 |
4248 | quint24* ssl = (quint24*)(d->data + sy*d->bytes_per_line); executed (the execution status of this line is deduced): quint24* ssl = (quint24*)(d->data + sy*d->bytes_per_line); | - |
4249 | quint24* dsl = (quint24*)(result.d->data + dy*result.d->bytes_per_line); executed (the execution status of this line is deduced): quint24* dsl = (quint24*)(result.d->data + dy*result.d->bytes_per_line); | - |
4250 | int dx = dxs; executed (the execution status of this line is deduced): int dx = dxs; | - |
4251 | for (int sx = 0; sx < w; sx++, dx += dxi) evaluated: sx < w yes Evaluation Count:33696 | yes Evaluation Count:624 |
| 624-33696 |
4252 | dsl[dx] = ssl[sx]; executed: dsl[dx] = ssl[sx]; Execution Count:33696 | 33696 |
4253 | } executed: } Execution Count:624 | 624 |
4254 | } executed: } Execution Count:48 | 48 |
4255 | // 32 bit | - |
4256 | else if (d->depth == 32) { partially evaluated: d->depth == 32 yes Evaluation Count:44 | no Evaluation Count:0 |
| 0-44 |
4257 | for (int sy = 0; sy < h; sy++, dy += dyi) { evaluated: sy < h yes Evaluation Count:657 | yes Evaluation Count:44 |
| 44-657 |
4258 | quint32* ssl = (quint32*)(d->data + sy*d->bytes_per_line); executed (the execution status of this line is deduced): quint32* ssl = (quint32*)(d->data + sy*d->bytes_per_line); | - |
4259 | quint32* dsl = (quint32*)(result.d->data + dy*result.d->bytes_per_line); executed (the execution status of this line is deduced): quint32* dsl = (quint32*)(result.d->data + dy*result.d->bytes_per_line); | - |
4260 | int dx = dxs; executed (the execution status of this line is deduced): int dx = dxs; | - |
4261 | for (int sx = 0; sx < w; sx++, dx += dxi) evaluated: sx < w yes Evaluation Count:43797 | yes Evaluation Count:657 |
| 657-43797 |
4262 | dsl[dx] = ssl[sx]; executed: dsl[dx] = ssl[sx]; Execution Count:43797 | 43797 |
4263 | } executed: } Execution Count:657 | 657 |
4264 | } executed: } Execution Count:44 | 44 |
4265 | | - |
4266 | // special handling of 1 bit images for horizontal mirroring | - |
4267 | if (horizontal && d->depth == 1) { partially evaluated: horizontal yes Evaluation Count:128 | no Evaluation Count:0 |
partially evaluated: d->depth == 1 no Evaluation Count:0 | yes Evaluation Count:128 |
| 0-128 |
4268 | int shift = width() % 8; never executed (the execution status of this line is deduced): int shift = width() % 8; | - |
4269 | for (int y = h-1; y >= 0; y--) { | 0 |
4270 | quint8* a0 = (quint8*)(result.d->data + y*d->bytes_per_line); never executed (the execution status of this line is deduced): quint8* a0 = (quint8*)(result.d->data + y*d->bytes_per_line); | - |
4271 | // Swap bytes | - |
4272 | quint8* a = a0+dxs; never executed (the execution status of this line is deduced): quint8* a = a0+dxs; | - |
4273 | while (a >= a0) { | 0 |
4274 | *a = bitflip[*a]; never executed (the execution status of this line is deduced): *a = bitflip[*a]; | - |
4275 | a--; never executed (the execution status of this line is deduced): a--; | - |
4276 | } | 0 |
4277 | // Shift bits if unaligned | - |
4278 | if (shift != 0) { never evaluated: shift != 0 | 0 |
4279 | a = a0+dxs; never executed (the execution status of this line is deduced): a = a0+dxs; | - |
4280 | quint8 c = 0; never executed (the execution status of this line is deduced): quint8 c = 0; | - |
4281 | if (format() == Format_MonoLSB) { never evaluated: format() == Format_MonoLSB | 0 |
4282 | while (a >= a0) { | 0 |
4283 | quint8 nc = *a << shift; never executed (the execution status of this line is deduced): quint8 nc = *a << shift; | - |
4284 | *a = (*a >> (8-shift)) | c; never executed (the execution status of this line is deduced): *a = (*a >> (8-shift)) | c; | - |
4285 | --a; never executed (the execution status of this line is deduced): --a; | - |
4286 | c = nc; never executed (the execution status of this line is deduced): c = nc; | - |
4287 | } | 0 |
4288 | } else { | 0 |
4289 | while (a >= a0) { | 0 |
4290 | quint8 nc = *a >> shift; never executed (the execution status of this line is deduced): quint8 nc = *a >> shift; | - |
4291 | *a = (*a << (8-shift)) | c; never executed (the execution status of this line is deduced): *a = (*a << (8-shift)) | c; | - |
4292 | --a; never executed (the execution status of this line is deduced): --a; | - |
4293 | c = nc; never executed (the execution status of this line is deduced): c = nc; | - |
4294 | } | 0 |
4295 | } | 0 |
4296 | } | - |
4297 | } | 0 |
4298 | } | 0 |
4299 | | - |
4300 | return result; executed: return result; Execution Count:128 | 128 |
4301 | } | - |
4302 | | - |
4303 | /*! | - |
4304 | Returns a QImage in which the values of the red and blue | - |
4305 | components of all pixels have been swapped, effectively converting | - |
4306 | an RGB image to an BGR image. | - |
4307 | | - |
4308 | The original QImage is not changed. | - |
4309 | | - |
4310 | \sa {QImage#Image Transformations}{Image Transformations} | - |
4311 | */ | - |
4312 | QImage QImage::rgbSwapped() const | - |
4313 | { | - |
4314 | if (isNull()) partially evaluated: isNull() no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
4315 | return *this; never executed: return *this; | 0 |
4316 | QImage res; executed (the execution status of this line is deduced): QImage res; | - |
4317 | switch (d->format) { | - |
4318 | case Format_Invalid: | - |
4319 | case NImageFormats: | - |
4320 | Q_ASSERT(false); never executed (the execution status of this line is deduced): qt_noop(); | - |
4321 | return res; never executed: return res; | 0 |
4322 | case Format_Mono: | - |
4323 | case Format_MonoLSB: | - |
4324 | case Format_Indexed8: | - |
4325 | res = copy(); executed (the execution status of this line is deduced): res = copy(); | - |
4326 | for (int i = 0; i < res.d->colortable.size(); i++) { evaluated: i < res.d->colortable.size() yes Evaluation Count:200 | yes Evaluation Count:2 |
| 2-200 |
4327 | QRgb c = res.d->colortable.at(i); executed (the execution status of this line is deduced): QRgb c = res.d->colortable.at(i); | - |
4328 | res.d->colortable[i] = QRgb(((c << 16) & 0xff0000) | ((c >> 16) & 0xff) | (c & 0xff00ff00)); executed (the execution status of this line is deduced): res.d->colortable[i] = QRgb(((c << 16) & 0xff0000) | ((c >> 16) & 0xff) | (c & 0xff00ff00)); | - |
4329 | } executed: } Execution Count:200 | 200 |
4330 | return res; executed: return res; Execution Count:2 | 2 |
4331 | case Format_RGB32: | - |
4332 | case Format_ARGB32: | - |
4333 | case Format_ARGB32_Premultiplied: | - |
4334 | res = QImage(d->width, d->height, d->format); executed (the execution status of this line is deduced): res = QImage(d->width, d->height, d->format); | - |
4335 | QIMAGE_SANITYCHECK_MEMORY(res); never executed: return QImage(); partially evaluated: (res).isNull() no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
4336 | for (int i = 0; i < d->height; i++) { evaluated: i < d->height yes Evaluation Count:6 | yes Evaluation Count:6 |
| 6 |
4337 | uint *q = (uint*)res.scanLine(i); executed (the execution status of this line is deduced): uint *q = (uint*)res.scanLine(i); | - |
4338 | uint *p = (uint*)constScanLine(i); executed (the execution status of this line is deduced): uint *p = (uint*)constScanLine(i); | - |
4339 | uint *end = p + d->width; executed (the execution status of this line is deduced): uint *end = p + d->width; | - |
4340 | while (p < end) { evaluated: p < end yes Evaluation Count:600 | yes Evaluation Count:6 |
| 6-600 |
4341 | *q = ((*p << 16) & 0xff0000) | ((*p >> 16) & 0xff) | (*p & 0xff00ff00); executed (the execution status of this line is deduced): *q = ((*p << 16) & 0xff0000) | ((*p >> 16) & 0xff) | (*p & 0xff00ff00); | - |
4342 | p++; executed (the execution status of this line is deduced): p++; | - |
4343 | q++; executed (the execution status of this line is deduced): q++; | - |
4344 | } executed: } Execution Count:600 | 600 |
4345 | } executed: } Execution Count:6 | 6 |
4346 | return res; executed: return res; Execution Count:6 | 6 |
4347 | case Format_RGB16: | - |
4348 | res = QImage(d->width, d->height, d->format); executed (the execution status of this line is deduced): res = QImage(d->width, d->height, d->format); | - |
4349 | QIMAGE_SANITYCHECK_MEMORY(res); never executed: return QImage(); partially evaluated: (res).isNull() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
4350 | for (int i = 0; i < d->height; i++) { evaluated: i < d->height yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
4351 | ushort *q = (ushort*)res.scanLine(i); executed (the execution status of this line is deduced): ushort *q = (ushort*)res.scanLine(i); | - |
4352 | const ushort *p = (const ushort*)constScanLine(i); executed (the execution status of this line is deduced): const ushort *p = (const ushort*)constScanLine(i); | - |
4353 | const ushort *end = p + d->width; executed (the execution status of this line is deduced): const ushort *end = p + d->width; | - |
4354 | while (p < end) { evaluated: p < end yes Evaluation Count:200 | yes Evaluation Count:2 |
| 2-200 |
4355 | *q = ((*p << 11) & 0xf800) | ((*p >> 11) & 0x1f) | (*p & 0x07e0); executed (the execution status of this line is deduced): *q = ((*p << 11) & 0xf800) | ((*p >> 11) & 0x1f) | (*p & 0x07e0); | - |
4356 | p++; executed (the execution status of this line is deduced): p++; | - |
4357 | q++; executed (the execution status of this line is deduced): q++; | - |
4358 | } executed: } Execution Count:200 | 200 |
4359 | } executed: } Execution Count:2 | 2 |
4360 | return res; executed: return res; Execution Count:2 | 2 |
4361 | default: | - |
4362 | break; executed: break; Execution Count:16 | 16 |
4363 | } | - |
4364 | | - |
4365 | res = QImage(d->width, d->height, d->format); executed (the execution status of this line is deduced): res = QImage(d->width, d->height, d->format); | - |
4366 | QIMAGE_SANITYCHECK_MEMORY(res); never executed: return QImage(); partially evaluated: (res).isNull() no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
4367 | const QPixelLayout *layout = &qPixelLayouts[d->format]; executed (the execution status of this line is deduced): const QPixelLayout *layout = &qPixelLayouts[d->format]; | - |
4368 | Q_ASSERT(layout->redWidth == layout->blueWidth); executed (the execution status of this line is deduced): qt_noop(); | - |
4369 | FetchPixelsFunc fetch = qFetchPixels[layout->bpp]; executed (the execution status of this line is deduced): FetchPixelsFunc fetch = qFetchPixels[layout->bpp]; | - |
4370 | StorePixelsFunc store = qStorePixels[layout->bpp]; executed (the execution status of this line is deduced): StorePixelsFunc store = qStorePixels[layout->bpp]; | - |
4371 | | - |
4372 | const uint redBlueMask = (1 << layout->redWidth) - 1; executed (the execution status of this line is deduced): const uint redBlueMask = (1 << layout->redWidth) - 1; | - |
4373 | const uint alphaGreenMask = (((1 << layout->alphaWidth) - 1) << layout->alphaShift) executed (the execution status of this line is deduced): const uint alphaGreenMask = (((1 << layout->alphaWidth) - 1) << layout->alphaShift) | - |
4374 | | (((1 << layout->greenWidth) - 1) << layout->greenShift); executed (the execution status of this line is deduced): | (((1 << layout->greenWidth) - 1) << layout->greenShift); | - |
4375 | | - |
4376 | const int buffer_size = 2048; executed (the execution status of this line is deduced): const int buffer_size = 2048; | - |
4377 | uint buffer[buffer_size]; executed (the execution status of this line is deduced): uint buffer[buffer_size]; | - |
4378 | for (int i = 0; i < d->height; ++i) { evaluated: i < d->height yes Evaluation Count:16 | yes Evaluation Count:16 |
| 16 |
4379 | uchar *q = res.scanLine(i); executed (the execution status of this line is deduced): uchar *q = res.scanLine(i); | - |
4380 | const uchar *p = constScanLine(i); executed (the execution status of this line is deduced): const uchar *p = constScanLine(i); | - |
4381 | int x = 0; executed (the execution status of this line is deduced): int x = 0; | - |
4382 | while (x < d->width) { evaluated: x < d->width yes Evaluation Count:16 | yes Evaluation Count:16 |
| 16 |
4383 | int l = qMin(d->width - x, buffer_size); executed (the execution status of this line is deduced): int l = qMin(d->width - x, buffer_size); | - |
4384 | const uint *ptr = fetch(buffer, p, x, l); executed (the execution status of this line is deduced): const uint *ptr = fetch(buffer, p, x, l); | - |
4385 | for (int j = 0; j < l; ++j) { evaluated: j < l yes Evaluation Count:1600 | yes Evaluation Count:16 |
| 16-1600 |
4386 | uint red = (ptr[j] >> layout->redShift) & redBlueMask; executed (the execution status of this line is deduced): uint red = (ptr[j] >> layout->redShift) & redBlueMask; | - |
4387 | uint blue = (ptr[j] >> layout->blueShift) & redBlueMask; executed (the execution status of this line is deduced): uint blue = (ptr[j] >> layout->blueShift) & redBlueMask; | - |
4388 | buffer[j] = (ptr[j] & alphaGreenMask) executed (the execution status of this line is deduced): buffer[j] = (ptr[j] & alphaGreenMask) | - |
4389 | | (red << layout->blueShift) executed (the execution status of this line is deduced): | (red << layout->blueShift) | - |
4390 | | (blue << layout->redShift); executed (the execution status of this line is deduced): | (blue << layout->redShift); | - |
4391 | } executed: } Execution Count:1600 | 1600 |
4392 | store(q, buffer, x, l); executed (the execution status of this line is deduced): store(q, buffer, x, l); | - |
4393 | x += l; executed (the execution status of this line is deduced): x += l; | - |
4394 | } executed: } Execution Count:16 | 16 |
4395 | } executed: } Execution Count:16 | 16 |
4396 | return res; executed: return res; Execution Count:16 | 16 |
4397 | } | - |
4398 | | - |
4399 | /*! | - |
4400 | Loads an image from the file with the given \a fileName. Returns true if | - |
4401 | the image was successfully loaded; otherwise invalidates the image | - |
4402 | and returns false. | - |
4403 | | - |
4404 | The loader attempts to read the image using the specified \a format, e.g., | - |
4405 | PNG or JPG. If \a format is not specified (which is the default), the | - |
4406 | loader probes the file for a header to guess the file format. | - |
4407 | | - |
4408 | The file name can either refer to an actual file on disk or to one | - |
4409 | of the application's embedded resources. See the | - |
4410 | \l{resources.html}{Resource System} overview for details on how to | - |
4411 | embed images and other resource files in the application's | - |
4412 | executable. | - |
4413 | | - |
4414 | \sa {QImage#Reading and Writing Image Files}{Reading and Writing Image Files} | - |
4415 | */ | - |
4416 | | - |
4417 | bool QImage::load(const QString &fileName, const char* format) | - |
4418 | { | - |
4419 | QImage image = QImageReader(fileName, format).read(); executed (the execution status of this line is deduced): QImage image = QImageReader(fileName, format).read(); | - |
4420 | operator=(image); executed (the execution status of this line is deduced): operator=(image); | - |
4421 | return !isNull(); executed: return !isNull(); Execution Count:180 | 180 |
4422 | } | - |
4423 | | - |
4424 | /*! | - |
4425 | \overload | - |
4426 | | - |
4427 | This function reads a QImage from the given \a device. This can, | - |
4428 | for example, be used to load an image directly into a QByteArray. | - |
4429 | */ | - |
4430 | | - |
4431 | bool QImage::load(QIODevice* device, const char* format) | - |
4432 | { | - |
4433 | QImage image = QImageReader(device, format).read(); executed (the execution status of this line is deduced): QImage image = QImageReader(device, format).read(); | - |
4434 | operator=(image); executed (the execution status of this line is deduced): operator=(image); | - |
4435 | return !isNull(); executed: return !isNull(); Execution Count:2 | 2 |
4436 | } | - |
4437 | | - |
4438 | /*! | - |
4439 | \fn bool QImage::loadFromData(const uchar *data, int len, const char *format) | - |
4440 | | - |
4441 | Loads an image from the first \a len bytes of the given binary \a | - |
4442 | data. Returns true if the image was successfully loaded; otherwise | - |
4443 | invalidates the image and returns false. | - |
4444 | | - |
4445 | The loader attempts to read the image using the specified \a format, e.g., | - |
4446 | PNG or JPG. If \a format is not specified (which is the default), the | - |
4447 | loader probes the file for a header to guess the file format. | - |
4448 | | - |
4449 | \sa {QImage#Reading and Writing Image Files}{Reading and Writing Image Files} | - |
4450 | */ | - |
4451 | | - |
4452 | bool QImage::loadFromData(const uchar *data, int len, const char *format) | - |
4453 | { | - |
4454 | QImage image = fromData(data, len, format); executed (the execution status of this line is deduced): QImage image = fromData(data, len, format); | - |
4455 | operator=(image); executed (the execution status of this line is deduced): operator=(image); | - |
4456 | return !isNull(); executed: return !isNull(); Execution Count:40 | 40 |
4457 | } | - |
4458 | | - |
4459 | /*! | - |
4460 | \fn bool QImage::loadFromData(const QByteArray &data, const char *format) | - |
4461 | | - |
4462 | \overload | - |
4463 | | - |
4464 | Loads an image from the given QByteArray \a data. | - |
4465 | */ | - |
4466 | | - |
4467 | /*! | - |
4468 | \fn QImage QImage::fromData(const uchar *data, int size, const char *format) | - |
4469 | | - |
4470 | Constructs a QImage from the first \a size bytes of the given | - |
4471 | binary \a data. The loader attempts to read the image using the | - |
4472 | specified \a format. If \a format is not specified (which is the default), | - |
4473 | the loader probes the file for a header to guess the file format. | - |
4474 | binary \a data. The loader attempts to read the image, either using the | - |
4475 | optional image \a format specified or by determining the image format from | - |
4476 | the data. | - |
4477 | | - |
4478 | If \a format is not specified (which is the default), the loader probes the | - |
4479 | file for a header to determine the file format. If \a format is specified, | - |
4480 | it must be one of the values returned by QImageReader::supportedImageFormats(). | - |
4481 | | - |
4482 | If the loading of the image fails, the image returned will be a null image. | - |
4483 | | - |
4484 | \sa load(), save(), {QImage#Reading and Writing Image Files}{Reading and Writing Image Files} | - |
4485 | */ | - |
4486 | | - |
4487 | QImage QImage::fromData(const uchar *data, int size, const char *format) | - |
4488 | { | - |
4489 | QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(data), size); executed (the execution status of this line is deduced): QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(data), size); | - |
4490 | QBuffer b; executed (the execution status of this line is deduced): QBuffer b; | - |
4491 | b.setData(a); executed (the execution status of this line is deduced): b.setData(a); | - |
4492 | b.open(QIODevice::ReadOnly); executed (the execution status of this line is deduced): b.open(QIODevice::ReadOnly); | - |
4493 | return QImageReader(&b, format).read(); executed: return QImageReader(&b, format).read(); Execution Count:68 | 68 |
4494 | } | - |
4495 | | - |
4496 | /*! | - |
4497 | \fn QImage QImage::fromData(const QByteArray &data, const char *format) | - |
4498 | | - |
4499 | \overload | - |
4500 | | - |
4501 | Loads an image from the given QByteArray \a data. | - |
4502 | */ | - |
4503 | | - |
4504 | /*! | - |
4505 | Saves the image to the file with the given \a fileName, using the | - |
4506 | given image file \a format and \a quality factor. If \a format is | - |
4507 | 0, QImage will attempt to guess the format by looking at \a fileName's | - |
4508 | suffix. | - |
4509 | | - |
4510 | The \a quality factor must be in the range 0 to 100 or -1. Specify | - |
4511 | 0 to obtain small compressed files, 100 for large uncompressed | - |
4512 | files, and -1 (the default) to use the default settings. | - |
4513 | | - |
4514 | Returns true if the image was successfully saved; otherwise | - |
4515 | returns false. | - |
4516 | | - |
4517 | \sa {QImage#Reading and Writing Image Files}{Reading and Writing | - |
4518 | Image Files} | - |
4519 | */ | - |
4520 | bool QImage::save(const QString &fileName, const char *format, int quality) const | - |
4521 | { | - |
4522 | if (isNull()) partially evaluated: isNull() no Evaluation Count:0 | yes Evaluation Count:278 |
| 0-278 |
4523 | return false; never executed: return false; | 0 |
4524 | QImageWriter writer(fileName, format); executed (the execution status of this line is deduced): QImageWriter writer(fileName, format); | - |
4525 | return d->doImageIO(this, &writer, quality); executed: return d->doImageIO(this, &writer, quality); Execution Count:278 | 278 |
4526 | } | - |
4527 | | - |
4528 | /*! | - |
4529 | \overload | - |
4530 | | - |
4531 | This function writes a QImage to the given \a device. | - |
4532 | | - |
4533 | This can, for example, be used to save an image directly into a | - |
4534 | QByteArray: | - |
4535 | | - |
4536 | \snippet image/image.cpp 0 | - |
4537 | */ | - |
4538 | | - |
4539 | bool QImage::save(QIODevice* device, const char* format, int quality) const | - |
4540 | { | - |
4541 | if (isNull()) partially evaluated: isNull() no Evaluation Count:0 | yes Evaluation Count:30 |
| 0-30 |
4542 | return false; // nothing to save never executed: return false; | 0 |
4543 | QImageWriter writer(device, format); executed (the execution status of this line is deduced): QImageWriter writer(device, format); | - |
4544 | return d->doImageIO(this, &writer, quality); executed: return d->doImageIO(this, &writer, quality); Execution Count:30 | 30 |
4545 | } | - |
4546 | | - |
4547 | /* \internal | - |
4548 | */ | - |
4549 | | - |
4550 | bool QImageData::doImageIO(const QImage *image, QImageWriter *writer, int quality) const | - |
4551 | { | - |
4552 | if (quality > 100 || quality < -1) partially evaluated: quality > 100 no Evaluation Count:0 | yes Evaluation Count:308 |
partially evaluated: quality < -1 no Evaluation Count:0 | yes Evaluation Count:308 |
| 0-308 |
4553 | qWarning("QPixmap::save: Quality out of range [-1, 100]"); never executed: QMessageLogger("image/qimage.cpp", 4553, __PRETTY_FUNCTION__).warning("QPixmap::save: Quality out of range [-1, 100]"); | 0 |
4554 | if (quality >= 0) partially evaluated: quality >= 0 no Evaluation Count:0 | yes Evaluation Count:308 |
| 0-308 |
4555 | writer->setQuality(qMin(quality,100)); never executed: writer->setQuality(qMin(quality,100)); | 0 |
4556 | return writer->write(*image); executed: return writer->write(*image); Execution Count:308 | 308 |
4557 | } | - |
4558 | | - |
4559 | /***************************************************************************** | - |
4560 | QImage stream functions | - |
4561 | *****************************************************************************/ | - |
4562 | #if !defined(QT_NO_DATASTREAM) | - |
4563 | /*! | - |
4564 | \fn QDataStream &operator<<(QDataStream &stream, const QImage &image) | - |
4565 | \relates QImage | - |
4566 | | - |
4567 | Writes the given \a image to the given \a stream as a PNG image, | - |
4568 | or as a BMP image if the stream's version is 1. Note that writing | - |
4569 | the stream to a file will not produce a valid image file. | - |
4570 | | - |
4571 | \sa QImage::save(), {Serializing Qt Data Types} | - |
4572 | */ | - |
4573 | | - |
4574 | QDataStream &operator<<(QDataStream &s, const QImage &image) | - |
4575 | { | - |
4576 | if (s.version() >= 5) { partially evaluated: s.version() >= 5 yes Evaluation Count:67 | no Evaluation Count:0 |
| 0-67 |
4577 | if (image.isNull()) { evaluated: image.isNull() yes Evaluation Count:3 | yes Evaluation Count:64 |
| 3-64 |
4578 | s << (qint32) 0; // null image marker executed (the execution status of this line is deduced): s << (qint32) 0; | - |
4579 | return s; executed: return s; Execution Count:3 | 3 |
4580 | } else { | - |
4581 | s << (qint32) 1; executed (the execution status of this line is deduced): s << (qint32) 1; | - |
4582 | // continue ... | - |
4583 | } executed: } Execution Count:64 | 64 |
4584 | } | - |
4585 | QImageWriter writer(s.device(), s.version() == 1 ? "bmp" : "png"); executed (the execution status of this line is deduced): QImageWriter writer(s.device(), s.version() == 1 ? "bmp" : "png"); | - |
4586 | writer.write(image); executed (the execution status of this line is deduced): writer.write(image); | - |
4587 | return s; executed: return s; Execution Count:64 | 64 |
4588 | } | - |
4589 | | - |
4590 | /*! | - |
4591 | \fn QDataStream &operator>>(QDataStream &stream, QImage &image) | - |
4592 | \relates QImage | - |
4593 | | - |
4594 | Reads an image from the given \a stream and stores it in the given | - |
4595 | \a image. | - |
4596 | | - |
4597 | \sa QImage::load(), {Serializing Qt Data Types} | - |
4598 | */ | - |
4599 | | - |
4600 | QDataStream &operator>>(QDataStream &s, QImage &image) | - |
4601 | { | - |
4602 | if (s.version() >= 5) { partially evaluated: s.version() >= 5 yes Evaluation Count:67 | no Evaluation Count:0 |
| 0-67 |
4603 | qint32 nullMarker; executed (the execution status of this line is deduced): qint32 nullMarker; | - |
4604 | s >> nullMarker; executed (the execution status of this line is deduced): s >> nullMarker; | - |
4605 | if (!nullMarker) { evaluated: !nullMarker yes Evaluation Count:5 | yes Evaluation Count:62 |
| 5-62 |
4606 | image = QImage(); // null image executed (the execution status of this line is deduced): image = QImage(); | - |
4607 | return s; executed: return s; Execution Count:5 | 5 |
4608 | } | - |
4609 | } executed: } Execution Count:62 | 62 |
4610 | image = QImageReader(s.device(), 0).read(); executed (the execution status of this line is deduced): image = QImageReader(s.device(), 0).read(); | - |
4611 | return s; executed: return s; Execution Count:62 | 62 |
4612 | } | - |
4613 | #endif // QT_NO_DATASTREAM | - |
4614 | | - |
4615 | | - |
4616 | | - |
4617 | /*! | - |
4618 | \fn bool QImage::operator==(const QImage & image) const | - |
4619 | | - |
4620 | Returns true if this image and the given \a image have the same | - |
4621 | contents; otherwise returns false. | - |
4622 | | - |
4623 | The comparison can be slow, unless there is some obvious | - |
4624 | difference (e.g. different size or format), in which case the | - |
4625 | function will return quickly. | - |
4626 | | - |
4627 | \sa operator=() | - |
4628 | */ | - |
4629 | | - |
4630 | bool QImage::operator==(const QImage & i) const | - |
4631 | { | - |
4632 | // same object, or shared? | - |
4633 | if (i.d == d) evaluated: i.d == d yes Evaluation Count:103 | yes Evaluation Count:1484 |
| 103-1484 |
4634 | return true; executed: return true; Execution Count:103 | 103 |
4635 | if (!i.d || !d) partially evaluated: !i.d no Evaluation Count:0 | yes Evaluation Count:1484 |
partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:1484 |
| 0-1484 |
4636 | return false; never executed: return false; | 0 |
4637 | | - |
4638 | // obviously different stuff? | - |
4639 | if (i.d->height != d->height || i.d->width != d->width || i.d->format != d->format) evaluated: i.d->height != d->height yes Evaluation Count:1 | yes Evaluation Count:1483 |
partially evaluated: i.d->width != d->width no Evaluation Count:0 | yes Evaluation Count:1483 |
partially evaluated: i.d->format != d->format no Evaluation Count:0 | yes Evaluation Count:1483 |
| 0-1483 |
4640 | return false; executed: return false; Execution Count:1 | 1 |
4641 | | - |
4642 | if (d->format != Format_RGB32) { evaluated: d->format != Format_RGB32 yes Evaluation Count:1148 | yes Evaluation Count:335 |
| 335-1148 |
4643 | if (d->format >= Format_ARGB32) { // all bits defined evaluated: d->format >= Format_ARGB32 yes Evaluation Count:992 | yes Evaluation Count:156 |
| 156-992 |
4644 | const int n = d->width * d->depth / 8; executed (the execution status of this line is deduced): const int n = d->width * d->depth / 8; | - |
4645 | if (n == d->bytes_per_line && n == i.d->bytes_per_line) { evaluated: n == d->bytes_per_line yes Evaluation Count:647 | yes Evaluation Count:345 |
evaluated: n == i.d->bytes_per_line yes Evaluation Count:582 | yes Evaluation Count:65 |
| 65-647 |
4646 | if (memcmp(bits(), i.bits(), d->nbytes)) evaluated: memcmp(bits(), i.bits(), d->nbytes) yes Evaluation Count:2 | yes Evaluation Count:580 |
| 2-580 |
4647 | return false; executed: return false; Execution Count:2 | 2 |
4648 | } else { executed: } Execution Count:580 | 580 |
4649 | for (int y = 0; y < d->height; ++y) { evaluated: y < d->height yes Evaluation Count:33491 | yes Evaluation Count:410 |
| 410-33491 |
4650 | if (memcmp(scanLine(y), i.scanLine(y), n)) partially evaluated: memcmp(scanLine(y), i.scanLine(y), n) no Evaluation Count:0 | yes Evaluation Count:33491 |
| 0-33491 |
4651 | return false; never executed: return false; | 0 |
4652 | } executed: } Execution Count:33491 | 33491 |
4653 | } executed: } Execution Count:410 | 410 |
4654 | } else { | - |
4655 | const int w = width(); executed (the execution status of this line is deduced): const int w = width(); | - |
4656 | const int h = height(); executed (the execution status of this line is deduced): const int h = height(); | - |
4657 | const QVector<QRgb> &colortable = d->colortable; executed (the execution status of this line is deduced): const QVector<QRgb> &colortable = d->colortable; | - |
4658 | const QVector<QRgb> &icolortable = i.d->colortable; executed (the execution status of this line is deduced): const QVector<QRgb> &icolortable = i.d->colortable; | - |
4659 | for (int y=0; y<h; ++y) { evaluated: y<h yes Evaluation Count:13772 | yes Evaluation Count:156 |
| 156-13772 |
4660 | for (int x=0; x<w; ++x) { evaluated: x<w yes Evaluation Count:4142555 | yes Evaluation Count:13772 |
| 13772-4142555 |
4661 | if (colortable[pixelIndex(x, y)] != icolortable[i.pixelIndex(x, y)]) partially evaluated: colortable[pixelIndex(x, y)] != icolortable[i.pixelIndex(x, y)] no Evaluation Count:0 | yes Evaluation Count:4142555 |
| 0-4142555 |
4662 | return false; never executed: return false; | 0 |
4663 | } executed: } Execution Count:4142555 | 4142555 |
4664 | } executed: } Execution Count:13772 | 13772 |
4665 | } executed: } Execution Count:156 | 156 |
4666 | } else { | - |
4667 | //alpha channel undefined, so we must mask it out | - |
4668 | for(int l = 0; l < d->height; l++) { evaluated: l < d->height yes Evaluation Count:57448 | yes Evaluation Count:325 |
| 325-57448 |
4669 | int w = d->width; executed (the execution status of this line is deduced): int w = d->width; | - |
4670 | const uint *p1 = reinterpret_cast<const uint*>(scanLine(l)); executed (the execution status of this line is deduced): const uint *p1 = reinterpret_cast<const uint*>(scanLine(l)); | - |
4671 | const uint *p2 = reinterpret_cast<const uint*>(i.scanLine(l)); executed (the execution status of this line is deduced): const uint *p2 = reinterpret_cast<const uint*>(i.scanLine(l)); | - |
4672 | while (w--) { evaluated: w-- yes Evaluation Count:22131310 | yes Evaluation Count:57438 |
| 57438-22131310 |
4673 | if ((*p1++ & 0x00ffffff) != (*p2++ & 0x00ffffff)) evaluated: (*p1++ & 0x00ffffff) != (*p2++ & 0x00ffffff) yes Evaluation Count:10 | yes Evaluation Count:22131300 |
| 10-22131300 |
4674 | return false; executed: return false; Execution Count:10 | 10 |
4675 | } executed: } Execution Count:22131300 | 22131300 |
4676 | } executed: } Execution Count:57438 | 57438 |
4677 | } executed: } Execution Count:325 | 325 |
4678 | return true; executed: return true; Execution Count:1471 | 1471 |
4679 | } | - |
4680 | | - |
4681 | | - |
4682 | /*! | - |
4683 | \fn bool QImage::operator!=(const QImage & image) const | - |
4684 | | - |
4685 | Returns true if this image and the given \a image have different | - |
4686 | contents; otherwise returns false. | - |
4687 | | - |
4688 | The comparison can be slow, unless there is some obvious | - |
4689 | difference, such as different widths, in which case the function | - |
4690 | will return quickly. | - |
4691 | | - |
4692 | \sa operator=() | - |
4693 | */ | - |
4694 | | - |
4695 | bool QImage::operator!=(const QImage & i) const | - |
4696 | { | - |
4697 | return !(*this == i); executed: return !(*this == i); Execution Count:17 | 17 |
4698 | } | - |
4699 | | - |
4700 | | - |
4701 | | - |
4702 | | - |
4703 | /*! | - |
4704 | Returns the number of pixels that fit horizontally in a physical | - |
4705 | meter. Together with dotsPerMeterY(), this number defines the | - |
4706 | intended scale and aspect ratio of the image. | - |
4707 | | - |
4708 | \sa setDotsPerMeterX(), {QImage#Image Information}{Image | - |
4709 | Information} | - |
4710 | */ | - |
4711 | int QImage::dotsPerMeterX() const | - |
4712 | { | - |
4713 | return d ? qRound(d->dpmx) : 0; executed: return d ? qRound(d->dpmx) : 0; Execution Count:13686 | 13686 |
4714 | } | - |
4715 | | - |
4716 | /*! | - |
4717 | Returns the number of pixels that fit vertically in a physical | - |
4718 | meter. Together with dotsPerMeterX(), this number defines the | - |
4719 | intended scale and aspect ratio of the image. | - |
4720 | | - |
4721 | \sa setDotsPerMeterY(), {QImage#Image Information}{Image | - |
4722 | Information} | - |
4723 | */ | - |
4724 | int QImage::dotsPerMeterY() const | - |
4725 | { | - |
4726 | return d ? qRound(d->dpmy) : 0; executed: return d ? qRound(d->dpmy) : 0; Execution Count:13563 | 13563 |
4727 | } | - |
4728 | | - |
4729 | /*! | - |
4730 | Sets the number of pixels that fit horizontally in a physical | - |
4731 | meter, to \a x. | - |
4732 | | - |
4733 | Together with dotsPerMeterY(), this number defines the intended | - |
4734 | scale and aspect ratio of the image, and determines the scale | - |
4735 | at which QPainter will draw graphics on the image. It does not | - |
4736 | change the scale or aspect ratio of the image when it is rendered | - |
4737 | on other paint devices. | - |
4738 | | - |
4739 | \sa dotsPerMeterX(), {QImage#Image Information}{Image Information} | - |
4740 | */ | - |
4741 | void QImage::setDotsPerMeterX(int x) | - |
4742 | { | - |
4743 | if (!d || !x) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:10045 |
evaluated: !x yes Evaluation Count:203 | yes Evaluation Count:9842 |
| 0-10045 |
4744 | return; executed: return; Execution Count:203 | 203 |
4745 | detach(); executed (the execution status of this line is deduced): detach(); | - |
4746 | | - |
4747 | if (d) partially evaluated: d yes Evaluation Count:9842 | no Evaluation Count:0 |
| 0-9842 |
4748 | d->dpmx = x; executed: d->dpmx = x; Execution Count:9842 | 9842 |
4749 | } executed: } Execution Count:9842 | 9842 |
4750 | | - |
4751 | /*! | - |
4752 | Sets the number of pixels that fit vertically in a physical meter, | - |
4753 | to \a y. | - |
4754 | | - |
4755 | Together with dotsPerMeterX(), this number defines the intended | - |
4756 | scale and aspect ratio of the image, and determines the scale | - |
4757 | at which QPainter will draw graphics on the image. It does not | - |
4758 | change the scale or aspect ratio of the image when it is rendered | - |
4759 | on other paint devices. | - |
4760 | | - |
4761 | \sa dotsPerMeterY(), {QImage#Image Information}{Image Information} | - |
4762 | */ | - |
4763 | void QImage::setDotsPerMeterY(int y) | - |
4764 | { | - |
4765 | if (!d || !y) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:10045 |
evaluated: !y yes Evaluation Count:203 | yes Evaluation Count:9842 |
| 0-10045 |
4766 | return; executed: return; Execution Count:203 | 203 |
4767 | detach(); executed (the execution status of this line is deduced): detach(); | - |
4768 | | - |
4769 | if (d) partially evaluated: d yes Evaluation Count:9842 | no Evaluation Count:0 |
| 0-9842 |
4770 | d->dpmy = y; executed: d->dpmy = y; Execution Count:9842 | 9842 |
4771 | } executed: } Execution Count:9842 | 9842 |
4772 | | - |
4773 | /*! | - |
4774 | \fn QPoint QImage::offset() const | - |
4775 | | - |
4776 | Returns the number of pixels by which the image is intended to be | - |
4777 | offset by when positioning relative to other images. | - |
4778 | | - |
4779 | \sa setOffset(), {QImage#Image Information}{Image Information} | - |
4780 | */ | - |
4781 | QPoint QImage::offset() const | - |
4782 | { | - |
4783 | return d ? d->offset : QPoint(); executed: return d ? d->offset : QPoint(); Execution Count:4111 | 4111 |
4784 | } | - |
4785 | | - |
4786 | | - |
4787 | /*! | - |
4788 | \fn void QImage::setOffset(const QPoint& offset) | - |
4789 | | - |
4790 | Sets the number of pixels by which the image is intended to be | - |
4791 | offset by when positioning relative to other images, to \a offset. | - |
4792 | | - |
4793 | \sa offset(), {QImage#Image Information}{Image Information} | - |
4794 | */ | - |
4795 | void QImage::setOffset(const QPoint& p) | - |
4796 | { | - |
4797 | if (!d) | 0 |
4798 | return; | 0 |
4799 | detach(); never executed (the execution status of this line is deduced): detach(); | - |
4800 | | - |
4801 | if (d) | 0 |
4802 | d->offset = p; never executed: d->offset = p; | 0 |
4803 | } | 0 |
4804 | | - |
4805 | /*! | - |
4806 | Returns the text keys for this image. | - |
4807 | | - |
4808 | You can use these keys with text() to list the image text for a | - |
4809 | certain key. | - |
4810 | | - |
4811 | \sa text() | - |
4812 | */ | - |
4813 | QStringList QImage::textKeys() const | - |
4814 | { | - |
4815 | return d ? QStringList(d->text.keys()) : QStringList(); executed: return d ? QStringList(d->text.keys()) : QStringList(); Execution Count:155 | 155 |
4816 | } | - |
4817 | | - |
4818 | /*! | - |
4819 | Returns the image text associated with the given \a key. If the | - |
4820 | specified \a key is an empty string, the whole image text is | - |
4821 | returned, with each key-text pair separated by a newline. | - |
4822 | | - |
4823 | \sa setText(), textKeys() | - |
4824 | */ | - |
4825 | QString QImage::text(const QString &key) const | - |
4826 | { | - |
4827 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:145 |
| 0-145 |
4828 | return QString(); never executed: return QString(); | 0 |
4829 | | - |
4830 | if (!key.isEmpty()) evaluated: !key.isEmpty() yes Evaluation Count:142 | yes Evaluation Count:3 |
| 3-142 |
4831 | return d->text.value(key); executed: return d->text.value(key); Execution Count:142 | 142 |
4832 | | - |
4833 | QString tmp; executed (the execution status of this line is deduced): QString tmp; | - |
4834 | foreach (const QString &key, d->text.keys()) { executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d->text.keys())> _container_(d->text.keys()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QString &key = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
4835 | if (!tmp.isEmpty()) evaluated: !tmp.isEmpty() yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3 |
4836 | tmp += QLatin1String("\n\n"); executed: tmp += QLatin1String("\n\n"); Execution Count:3 | 3 |
4837 | tmp += key + QLatin1String(": ") + d->text.value(key).simplified(); executed (the execution status of this line is deduced): tmp += key + QLatin1String(": ") + d->text.value(key).simplified(); | - |
4838 | } executed: } Execution Count:6 | 6 |
4839 | return tmp; executed: return tmp; Execution Count:3 | 3 |
4840 | } | - |
4841 | | - |
4842 | /*! | - |
4843 | \fn void QImage::setText(const QString &key, const QString &text) | - |
4844 | | - |
4845 | Sets the image text to the given \a text and associate it with the | - |
4846 | given \a key. | - |
4847 | | - |
4848 | If you just want to store a single text block (i.e., a "comment" | - |
4849 | or just a description), you can either pass an empty key, or use a | - |
4850 | generic key like "Description". | - |
4851 | | - |
4852 | The image text is embedded into the image data when you | - |
4853 | call save() or QImageWriter::write(). | - |
4854 | | - |
4855 | Not all image formats support embedded text. You can find out | - |
4856 | if a specific image or format supports embedding text | - |
4857 | by using QImageWriter::supportsOption(). We give an example: | - |
4858 | | - |
4859 | \snippet image/supportedformat.cpp 0 | - |
4860 | | - |
4861 | You can use QImageWriter::supportedImageFormats() to find out | - |
4862 | which image formats are available to you. | - |
4863 | | - |
4864 | \sa text(), textKeys() | - |
4865 | */ | - |
4866 | void QImage::setText(const QString &key, const QString &value) | - |
4867 | { | - |
4868 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:305 |
| 0-305 |
4869 | return; | 0 |
4870 | detach(); executed (the execution status of this line is deduced): detach(); | - |
4871 | | - |
4872 | if (d) partially evaluated: d yes Evaluation Count:305 | no Evaluation Count:0 |
| 0-305 |
4873 | d->text.insert(key, value); executed: d->text.insert(key, value); Execution Count:305 | 305 |
4874 | } executed: } Execution Count:305 | 305 |
4875 | | - |
4876 | /*! | - |
4877 | \fn QString QImage::text(const char* key, const char* language) const | - |
4878 | \obsolete | - |
4879 | | - |
4880 | Returns the text recorded for the given \a key in the given \a | - |
4881 | language, or in a default language if \a language is 0. | - |
4882 | | - |
4883 | Use text() instead. | - |
4884 | | - |
4885 | The language the text is recorded in is no longer relevant since | - |
4886 | the text is always set using QString and UTF-8 representation. | - |
4887 | */ | - |
4888 | | - |
4889 | /*! | - |
4890 | \fn QString QImage::text(const QImageTextKeyLang& keywordAndLanguage) const | - |
4891 | \overload | - |
4892 | \obsolete | - |
4893 | | - |
4894 | Returns the text recorded for the given \a keywordAndLanguage. | - |
4895 | | - |
4896 | Use text() instead. | - |
4897 | | - |
4898 | The language the text is recorded in is no longer relevant since | - |
4899 | the text is always set using QString and UTF-8 representation. | - |
4900 | */ | - |
4901 | | - |
4902 | /*! | - |
4903 | \fn void QImage::setText(const char* key, const char* language, const QString& text) | - |
4904 | \obsolete | - |
4905 | | - |
4906 | Sets the image text to the given \a text and associate it with the | - |
4907 | given \a key. The text is recorded in the specified \a language, | - |
4908 | or in a default language if \a language is 0. | - |
4909 | | - |
4910 | Use setText() instead. | - |
4911 | | - |
4912 | The language the text is recorded in is no longer relevant since | - |
4913 | the text is always set using QString and UTF-8 representation. | - |
4914 | | - |
4915 | \omit | - |
4916 | Records string \a for the keyword \a key. The \a key should be | - |
4917 | a portable keyword recognizable by other software - some suggested | - |
4918 | values can be found in | - |
4919 | \l{http://www.libpng.org/pub/png/spec/1.2/png-1.2-pdg.html#C.Anc-text} | - |
4920 | {the PNG specification}. \a s can be any text. \a lang should | - |
4921 | specify the language code (see | - |
4922 | \l{http://www.rfc-editor.org/rfc/rfc1766.txt}{RFC 1766}) or 0. | - |
4923 | \endomit | - |
4924 | */ | - |
4925 | | - |
4926 | /* | - |
4927 | Sets the image bits to the \a pixmap contents and returns a | - |
4928 | reference to the image. | - |
4929 | | - |
4930 | If the image shares data with other images, it will first | - |
4931 | dereference the shared data. | - |
4932 | | - |
4933 | Makes a call to QPixmap::convertToImage(). | - |
4934 | */ | - |
4935 | | - |
4936 | /*! | - |
4937 | \internal | - |
4938 | | - |
4939 | Used by QPainter to retrieve a paint engine for the image. | - |
4940 | */ | - |
4941 | | - |
4942 | QPaintEngine *QImage::paintEngine() const | - |
4943 | { | - |
4944 | if (!d) evaluated: !d yes Evaluation Count:1 | yes Evaluation Count:43168 |
| 1-43168 |
4945 | return 0; executed: return 0; Execution Count:1 | 1 |
4946 | | - |
4947 | if (!d->paintEngine) { evaluated: !d->paintEngine yes Evaluation Count:4685 | yes Evaluation Count:38483 |
| 4685-38483 |
4948 | QPaintDevice *paintDevice = const_cast<QImage *>(this); executed (the execution status of this line is deduced): QPaintDevice *paintDevice = const_cast<QImage *>(this); | - |
4949 | QPaintEngine *paintEngine = QGuiApplicationPrivate::platformIntegration()->createImagePaintEngine(paintDevice); executed (the execution status of this line is deduced): QPaintEngine *paintEngine = QGuiApplicationPrivate::platformIntegration()->createImagePaintEngine(paintDevice); | - |
4950 | d->paintEngine = paintEngine ? paintEngine : new QRasterPaintEngine(paintDevice); partially evaluated: paintEngine no Evaluation Count:0 | yes Evaluation Count:4685 |
| 0-4685 |
4951 | } executed: } Execution Count:4685 | 4685 |
4952 | | - |
4953 | return d->paintEngine; executed: return d->paintEngine; Execution Count:43168 | 43168 |
4954 | } | - |
4955 | | - |
4956 | | - |
4957 | /*! | - |
4958 | \internal | - |
4959 | | - |
4960 | Returns the size for the specified \a metric on the device. | - |
4961 | */ | - |
4962 | int QImage::metric(PaintDeviceMetric metric) const | - |
4963 | { | - |
4964 | if (!d) evaluated: !d yes Evaluation Count:2 | yes Evaluation Count:67046 |
| 2-67046 |
4965 | return 0; executed: return 0; Execution Count:2 | 2 |
4966 | | - |
4967 | switch (metric) { | - |
4968 | case PdmWidth: | - |
4969 | return d->width; executed: return d->width; Execution Count:26430 | 26430 |
4970 | | - |
4971 | case PdmHeight: | - |
4972 | return d->height; executed: return d->height; Execution Count:31115 | 31115 |
4973 | | - |
4974 | case PdmWidthMM: | - |
4975 | return qRound(d->width * 1000 / d->dpmx); never executed: return qRound(d->width * 1000 / d->dpmx); | 0 |
4976 | | - |
4977 | case PdmHeightMM: | - |
4978 | return qRound(d->height * 1000 / d->dpmy); never executed: return qRound(d->height * 1000 / d->dpmy); | 0 |
4979 | | - |
4980 | case PdmNumColors: | - |
4981 | return d->colortable.size(); never executed: return d->colortable.size(); | 0 |
4982 | | - |
4983 | case PdmDepth: | - |
4984 | return d->depth; executed: return d->depth; Execution Count:4685 | 4685 |
4985 | | - |
4986 | case PdmDpiX: | - |
4987 | return qRound(d->ldpmx * 0.0254); never executed: return qRound(d->ldpmx * 0.0254); | 0 |
4988 | break; | - |
4989 | | - |
4990 | case PdmDpiY: | - |
4991 | return qRound(d->ldpmy * 0.0254); executed: return qRound(d->ldpmy * 0.0254); Execution Count:4816 | 4816 |
4992 | break; | - |
4993 | | - |
4994 | case PdmPhysicalDpiX: | - |
4995 | return qRound(d->dpmx * 0.0254 * d->devicePixelRatio); never executed: return qRound(d->dpmx * 0.0254 * d->devicePixelRatio); | 0 |
4996 | break; | - |
4997 | | - |
4998 | case PdmPhysicalDpiY: | - |
4999 | return qRound(d->dpmy * 0.0254 * d->devicePixelRatio); never executed: return qRound(d->dpmy * 0.0254 * d->devicePixelRatio); | 0 |
5000 | break; | - |
5001 | default: | - |
5002 | qWarning("QImage::metric(): Unhandled metric type %d", metric); never executed (the execution status of this line is deduced): QMessageLogger("image/qimage.cpp", 5002, __PRETTY_FUNCTION__).warning("QImage::metric(): Unhandled metric type %d", metric); | - |
5003 | break; | 0 |
5004 | } | - |
5005 | return 0; never executed: return 0; | 0 |
5006 | } | - |
5007 | | - |
5008 | | - |
5009 | | - |
5010 | /***************************************************************************** | - |
5011 | QPixmap (and QImage) helper functions | - |
5012 | *****************************************************************************/ | - |
5013 | /* | - |
5014 | This internal function contains the common (i.e. platform independent) code | - |
5015 | to do a transformation of pixel data. It is used by QPixmap::transform() and by | - |
5016 | QImage::transform(). | - |
5017 | | - |
5018 | \a trueMat is the true transformation matrix (see QPixmap::trueMatrix()) and | - |
5019 | \a xoffset is an offset to the matrix. | - |
5020 | | - |
5021 | \a msbfirst specifies for 1bpp images, if the MSB or LSB comes first and \a | - |
5022 | depth specifies the colordepth of the data. | - |
5023 | | - |
5024 | \a dptr is a pointer to the destination data, \a dbpl specifies the bits per | - |
5025 | line for the destination data, \a p_inc is the offset that we advance for | - |
5026 | every scanline and \a dHeight is the height of the destination image. | - |
5027 | | - |
5028 | \a sprt is the pointer to the source data, \a sbpl specifies the bits per | - |
5029 | line of the source data, \a sWidth and \a sHeight are the width and height of | - |
5030 | the source data. | - |
5031 | */ | - |
5032 | | - |
5033 | #undef IWX_MSB | - |
5034 | #define IWX_MSB(b) if (trigx < maxws && trigy < maxhs) { \ | - |
5035 | if (*(sptr+sbpl*(trigy>>12)+(trigx>>15)) & \ | - |
5036 | (1 << (7-((trigx>>12)&7)))) \ | - |
5037 | *dptr |= b; \ | - |
5038 | } \ | - |
5039 | trigx += m11; \ | - |
5040 | trigy += m12; | - |
5041 | // END OF MACRO | - |
5042 | #undef IWX_LSB | - |
5043 | #define IWX_LSB(b) if (trigx < maxws && trigy < maxhs) { \ | - |
5044 | if (*(sptr+sbpl*(trigy>>12)+(trigx>>15)) & \ | - |
5045 | (1 << ((trigx>>12)&7))) \ | - |
5046 | *dptr |= b; \ | - |
5047 | } \ | - |
5048 | trigx += m11; \ | - |
5049 | trigy += m12; | - |
5050 | // END OF MACRO | - |
5051 | #undef IWX_PIX | - |
5052 | #define IWX_PIX(b) if (trigx < maxws && trigy < maxhs) { \ | - |
5053 | if ((*(sptr+sbpl*(trigy>>12)+(trigx>>15)) & \ | - |
5054 | (1 << (7-((trigx>>12)&7)))) == 0) \ | - |
5055 | *dptr &= ~b; \ | - |
5056 | } \ | - |
5057 | trigx += m11; \ | - |
5058 | trigy += m12; | - |
5059 | // END OF MACRO | - |
5060 | bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth, | - |
5061 | uchar *dptr, int dbpl, int p_inc, int dHeight, | - |
5062 | const uchar *sptr, int sbpl, int sWidth, int sHeight) | - |
5063 | { | - |
5064 | int m11 = int(trueMat.m11()*4096.0); executed (the execution status of this line is deduced): int m11 = int(trueMat.m11()*4096.0); | - |
5065 | int m12 = int(trueMat.m12()*4096.0); executed (the execution status of this line is deduced): int m12 = int(trueMat.m12()*4096.0); | - |
5066 | int m21 = int(trueMat.m21()*4096.0); executed (the execution status of this line is deduced): int m21 = int(trueMat.m21()*4096.0); | - |
5067 | int m22 = int(trueMat.m22()*4096.0); executed (the execution status of this line is deduced): int m22 = int(trueMat.m22()*4096.0); | - |
5068 | int dx = qRound(trueMat.dx()*4096.0); executed (the execution status of this line is deduced): int dx = qRound(trueMat.dx()*4096.0); | - |
5069 | int dy = qRound(trueMat.dy()*4096.0); executed (the execution status of this line is deduced): int dy = qRound(trueMat.dy()*4096.0); | - |
5070 | | - |
5071 | int m21ydx = dx + (xoffset<<16) + (m11 + m21) / 2; executed (the execution status of this line is deduced): int m21ydx = dx + (xoffset<<16) + (m11 + m21) / 2; | - |
5072 | int m22ydy = dy + (m12 + m22) / 2; executed (the execution status of this line is deduced): int m22ydy = dy + (m12 + m22) / 2; | - |
5073 | uint trigx; executed (the execution status of this line is deduced): uint trigx; | - |
5074 | uint trigy; executed (the execution status of this line is deduced): uint trigy; | - |
5075 | uint maxws = sWidth<<12; executed (the execution status of this line is deduced): uint maxws = sWidth<<12; | - |
5076 | uint maxhs = sHeight<<12; executed (the execution status of this line is deduced): uint maxhs = sHeight<<12; | - |
5077 | | - |
5078 | for (int y=0; y<dHeight; y++) { // for each target scanline evaluated: y<dHeight yes Evaluation Count:19 | yes Evaluation Count:2 |
| 2-19 |
5079 | trigx = m21ydx; executed (the execution status of this line is deduced): trigx = m21ydx; | - |
5080 | trigy = m22ydy; executed (the execution status of this line is deduced): trigy = m22ydy; | - |
5081 | uchar *maxp = dptr + dbpl; executed (the execution status of this line is deduced): uchar *maxp = dptr + dbpl; | - |
5082 | if (depth != 1) { partially evaluated: depth != 1 no Evaluation Count:0 | yes Evaluation Count:19 |
| 0-19 |
5083 | switch (depth) { | - |
5084 | case 8: // 8 bpp transform | - |
5085 | while (dptr < maxp) { never evaluated: dptr < maxp | 0 |
5086 | if (trigx < maxws && trigy < maxhs) never evaluated: trigx < maxws never evaluated: trigy < maxhs | 0 |
5087 | *dptr = *(sptr+sbpl*(trigy>>12)+(trigx>>12)); never executed: *dptr = *(sptr+sbpl*(trigy>>12)+(trigx>>12)); | 0 |
5088 | trigx += m11; never executed (the execution status of this line is deduced): trigx += m11; | - |
5089 | trigy += m12; never executed (the execution status of this line is deduced): trigy += m12; | - |
5090 | dptr++; never executed (the execution status of this line is deduced): dptr++; | - |
5091 | } | 0 |
5092 | break; | 0 |
5093 | | - |
5094 | case 16: // 16 bpp transform | - |
5095 | while (dptr < maxp) { never evaluated: dptr < maxp | 0 |
5096 | if (trigx < maxws && trigy < maxhs) never evaluated: trigx < maxws never evaluated: trigy < maxhs | 0 |
5097 | *((ushort*)dptr) = *((ushort *)(sptr+sbpl*(trigy>>12) + never executed: *((ushort*)dptr) = *((ushort *)(sptr+sbpl*(trigy>>12) + ((trigx>>12)<<1))); | 0 |
5098 | ((trigx>>12)<<1))); never executed: *((ushort*)dptr) = *((ushort *)(sptr+sbpl*(trigy>>12) + ((trigx>>12)<<1))); | 0 |
5099 | trigx += m11; never executed (the execution status of this line is deduced): trigx += m11; | - |
5100 | trigy += m12; never executed (the execution status of this line is deduced): trigy += m12; | - |
5101 | dptr++; never executed (the execution status of this line is deduced): dptr++; | - |
5102 | dptr++; never executed (the execution status of this line is deduced): dptr++; | - |
5103 | } | 0 |
5104 | break; | 0 |
5105 | | - |
5106 | case 24: // 24 bpp transform | - |
5107 | while (dptr < maxp) { never evaluated: dptr < maxp | 0 |
5108 | if (trigx < maxws && trigy < maxhs) { never evaluated: trigx < maxws never evaluated: trigy < maxhs | 0 |
5109 | const uchar *p2 = sptr+sbpl*(trigy>>12) + ((trigx>>12)*3); never executed (the execution status of this line is deduced): const uchar *p2 = sptr+sbpl*(trigy>>12) + ((trigx>>12)*3); | - |
5110 | dptr[0] = p2[0]; never executed (the execution status of this line is deduced): dptr[0] = p2[0]; | - |
5111 | dptr[1] = p2[1]; never executed (the execution status of this line is deduced): dptr[1] = p2[1]; | - |
5112 | dptr[2] = p2[2]; never executed (the execution status of this line is deduced): dptr[2] = p2[2]; | - |
5113 | } | 0 |
5114 | trigx += m11; never executed (the execution status of this line is deduced): trigx += m11; | - |
5115 | trigy += m12; never executed (the execution status of this line is deduced): trigy += m12; | - |
5116 | dptr += 3; never executed (the execution status of this line is deduced): dptr += 3; | - |
5117 | } | 0 |
5118 | break; | 0 |
5119 | | - |
5120 | case 32: // 32 bpp transform | - |
5121 | while (dptr < maxp) { never evaluated: dptr < maxp | 0 |
5122 | if (trigx < maxws && trigy < maxhs) never evaluated: trigx < maxws never evaluated: trigy < maxhs | 0 |
5123 | *((uint*)dptr) = *((uint *)(sptr+sbpl*(trigy>>12) + never executed: *((uint*)dptr) = *((uint *)(sptr+sbpl*(trigy>>12) + ((trigx>>12)<<2))); | 0 |
5124 | ((trigx>>12)<<2))); never executed: *((uint*)dptr) = *((uint *)(sptr+sbpl*(trigy>>12) + ((trigx>>12)<<2))); | 0 |
5125 | trigx += m11; never executed (the execution status of this line is deduced): trigx += m11; | - |
5126 | trigy += m12; never executed (the execution status of this line is deduced): trigy += m12; | - |
5127 | dptr += 4; never executed (the execution status of this line is deduced): dptr += 4; | - |
5128 | } | 0 |
5129 | break; | 0 |
5130 | | - |
5131 | default: { | - |
5132 | return false; never executed: return false; | 0 |
5133 | } | - |
5134 | } | - |
5135 | } else { | 0 |
5136 | switch (type) { | - |
5137 | case QT_XFORM_TYPE_MSBFIRST: | - |
5138 | while (dptr < maxp) { evaluated: dptr < maxp yes Evaluation Count:2556 | yes Evaluation Count:19 |
| 19-2556 |
5139 | IWX_MSB(128); executed: *dptr |= 128; Execution Count:2512 executed: } Execution Count:2518 evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << (7-((trigx>>12)&7))) yes Evaluation Count:2512 | yes Evaluation Count:6 |
evaluated: trigx < maxws yes Evaluation Count:2518 | yes Evaluation Count:38 |
partially evaluated: trigy < maxhs yes Evaluation Count:2518 | no Evaluation Count:0 |
| 0-2518 |
5140 | IWX_MSB(64); executed: *dptr |= 64; Execution Count:2506 executed: } Execution Count:2509 evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << (7-((trigx>>12)&7))) yes Evaluation Count:2506 | yes Evaluation Count:3 |
evaluated: trigx < maxws yes Evaluation Count:2509 | yes Evaluation Count:47 |
partially evaluated: trigy < maxhs yes Evaluation Count:2509 | no Evaluation Count:0 |
| 0-2509 |
5141 | IWX_MSB(32); executed: *dptr |= 32; Execution Count:2506 executed: } Execution Count:2509 evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << (7-((trigx>>12)&7))) yes Evaluation Count:2506 | yes Evaluation Count:3 |
evaluated: trigx < maxws yes Evaluation Count:2509 | yes Evaluation Count:47 |
partially evaluated: trigy < maxhs yes Evaluation Count:2509 | no Evaluation Count:0 |
| 0-2509 |
5142 | IWX_MSB(16); executed: *dptr |= 16; Execution Count:2503 executed: } Execution Count:2509 evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << (7-((trigx>>12)&7))) yes Evaluation Count:2503 | yes Evaluation Count:6 |
evaluated: trigx < maxws yes Evaluation Count:2509 | yes Evaluation Count:47 |
partially evaluated: trigy < maxhs yes Evaluation Count:2509 | no Evaluation Count:0 |
| 0-2509 |
5143 | IWX_MSB(8); executed: *dptr |= 8; Execution Count:2503 executed: } Execution Count:2509 evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << (7-((trigx>>12)&7))) yes Evaluation Count:2503 | yes Evaluation Count:6 |
evaluated: trigx < maxws yes Evaluation Count:2509 | yes Evaluation Count:47 |
partially evaluated: trigy < maxhs yes Evaluation Count:2509 | no Evaluation Count:0 |
| 0-2509 |
5144 | IWX_MSB(4); executed: *dptr |= 4; Execution Count:2503 executed: } Execution Count:2509 evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << (7-((trigx>>12)&7))) yes Evaluation Count:2503 | yes Evaluation Count:6 |
evaluated: trigx < maxws yes Evaluation Count:2509 | yes Evaluation Count:47 |
partially evaluated: trigy < maxhs yes Evaluation Count:2509 | no Evaluation Count:0 |
| 0-2509 |
5145 | IWX_MSB(2); executed: *dptr |= 2; Execution Count:2506 executed: } Execution Count:2509 evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << (7-((trigx>>12)&7))) yes Evaluation Count:2506 | yes Evaluation Count:3 |
evaluated: trigx < maxws yes Evaluation Count:2509 | yes Evaluation Count:47 |
partially evaluated: trigy < maxhs yes Evaluation Count:2509 | no Evaluation Count:0 |
| 0-2509 |
5146 | IWX_MSB(1); executed: *dptr |= 1; Execution Count:2496 executed: } Execution Count:2499 evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << (7-((trigx>>12)&7))) yes Evaluation Count:2496 | yes Evaluation Count:3 |
evaluated: trigx < maxws yes Evaluation Count:2499 | yes Evaluation Count:57 |
partially evaluated: trigy < maxhs yes Evaluation Count:2499 | no Evaluation Count:0 |
| 0-2499 |
5147 | dptr++; executed (the execution status of this line is deduced): dptr++; | - |
5148 | } executed: } Execution Count:2556 | 2556 |
5149 | break; executed: break; Execution Count:19 | 19 |
5150 | case QT_XFORM_TYPE_LSBFIRST: | - |
5151 | while (dptr < maxp) { never evaluated: dptr < maxp | 0 |
5152 | IWX_LSB(1); never executed: *dptr |= 1; never executed: } never evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << ((trigx>>12)&7)) never evaluated: trigx < maxws never evaluated: trigy < maxhs | 0 |
5153 | IWX_LSB(2); never executed: *dptr |= 2; never executed: } never evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << ((trigx>>12)&7)) never evaluated: trigx < maxws never evaluated: trigy < maxhs | 0 |
5154 | IWX_LSB(4); never executed: *dptr |= 4; never executed: } never evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << ((trigx>>12)&7)) never evaluated: trigx < maxws never evaluated: trigy < maxhs | 0 |
5155 | IWX_LSB(8); never executed: *dptr |= 8; never executed: } never evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << ((trigx>>12)&7)) never evaluated: trigx < maxws never evaluated: trigy < maxhs | 0 |
5156 | IWX_LSB(16); never executed: *dptr |= 16; never executed: } never evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << ((trigx>>12)&7)) never evaluated: trigx < maxws never evaluated: trigy < maxhs | 0 |
5157 | IWX_LSB(32); never executed: *dptr |= 32; never executed: } never evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << ((trigx>>12)&7)) never evaluated: trigx < maxws never evaluated: trigy < maxhs | 0 |
5158 | IWX_LSB(64); never executed: *dptr |= 64; never executed: } never evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << ((trigx>>12)&7)) never evaluated: trigx < maxws never evaluated: trigy < maxhs | 0 |
5159 | IWX_LSB(128); never executed: *dptr |= 128; never executed: } never evaluated: *(sptr+sbpl*(trigy>>12)+(trigx>>15)) & (1 << ((trigx>>12)&7)) never evaluated: trigx < maxws never evaluated: trigy < maxhs | 0 |
5160 | dptr++; never executed (the execution status of this line is deduced): dptr++; | - |
5161 | } | 0 |
5162 | break; | 0 |
5163 | } | - |
5164 | } executed: } Execution Count:19 | 19 |
5165 | m21ydx += m21; executed (the execution status of this line is deduced): m21ydx += m21; | - |
5166 | m22ydy += m22; executed (the execution status of this line is deduced): m22ydy += m22; | - |
5167 | dptr += p_inc; executed (the execution status of this line is deduced): dptr += p_inc; | - |
5168 | } executed: } Execution Count:19 | 19 |
5169 | return true; executed: return true; Execution Count:2 | 2 |
5170 | } | - |
5171 | #undef IWX_MSB | - |
5172 | #undef IWX_LSB | - |
5173 | #undef IWX_PIX | - |
5174 | | - |
5175 | /*! \fn int QImage::serialNumber() const | - |
5176 | \obsolete | - |
5177 | Returns a number that identifies the contents of this | - |
5178 | QImage object. Distinct QImage objects can only have the same | - |
5179 | serial number if they refer to the same contents (but they don't | - |
5180 | have to). | - |
5181 | | - |
5182 | Use cacheKey() instead. | - |
5183 | | - |
5184 | \warning The serial number doesn't necessarily change when the | - |
5185 | image is altered. This means that it may be dangerous to use | - |
5186 | it as a cache key. | - |
5187 | | - |
5188 | \sa operator==() | - |
5189 | */ | - |
5190 | | - |
5191 | /*! | - |
5192 | Returns a number that identifies the contents of this QImage | - |
5193 | object. Distinct QImage objects can only have the same key if they | - |
5194 | refer to the same contents. | - |
5195 | | - |
5196 | The key will change when the image is altered. | - |
5197 | */ | - |
5198 | qint64 QImage::cacheKey() const | - |
5199 | { | - |
5200 | if (!d) evaluated: !d yes Evaluation Count:237 | yes Evaluation Count:4892 |
| 237-4892 |
5201 | return 0; executed: return 0; Execution Count:237 | 237 |
5202 | else | - |
5203 | return (((qint64) d->ser_no) << 32) | ((qint64) d->detach_no); executed: return (((qint64) d->ser_no) << 32) | ((qint64) d->detach_no); Execution Count:4892 | 4892 |
5204 | } | - |
5205 | | - |
5206 | /*! | - |
5207 | \internal | - |
5208 | | - |
5209 | Returns true if the image is detached; otherwise returns false. | - |
5210 | | - |
5211 | \sa detach(), {Implicit Data Sharing} | - |
5212 | */ | - |
5213 | | - |
5214 | bool QImage::isDetached() const | - |
5215 | { | - |
5216 | return d && d->ref.load() == 1; never executed: return d && d->ref.load() == 1; | 0 |
5217 | } | - |
5218 | | - |
5219 | | - |
5220 | /*! | - |
5221 | \obsolete | - |
5222 | Sets the alpha channel of this image to the given \a alphaChannel. | - |
5223 | | - |
5224 | If \a alphaChannel is an 8 bit grayscale image, the intensity values are | - |
5225 | written into this buffer directly. Otherwise, \a alphaChannel is converted | - |
5226 | to 32 bit and the intensity of the RGB pixel values is used. | - |
5227 | | - |
5228 | Note that the image will be converted to the Format_ARGB32_Premultiplied | - |
5229 | format if the function succeeds. | - |
5230 | | - |
5231 | Use one of the composition modes in QPainter::CompositionMode instead. | - |
5232 | | - |
5233 | \warning This function is expensive. | - |
5234 | | - |
5235 | \sa alphaChannel(), {QImage#Image Transformations}{Image | - |
5236 | Transformations}, {QImage#Image Formats}{Image Formats} | - |
5237 | */ | - |
5238 | | - |
5239 | void QImage::setAlphaChannel(const QImage &alphaChannel) | - |
5240 | { | - |
5241 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:128 |
| 0-128 |
5242 | return; | 0 |
5243 | | - |
5244 | int w = d->width; executed (the execution status of this line is deduced): int w = d->width; | - |
5245 | int h = d->height; executed (the execution status of this line is deduced): int h = d->height; | - |
5246 | | - |
5247 | if (w != alphaChannel.d->width || h != alphaChannel.d->height) { partially evaluated: w != alphaChannel.d->width no Evaluation Count:0 | yes Evaluation Count:128 |
partially evaluated: h != alphaChannel.d->height no Evaluation Count:0 | yes Evaluation Count:128 |
| 0-128 |
5248 | qWarning("QImage::setAlphaChannel: " never executed (the execution status of this line is deduced): QMessageLogger("image/qimage.cpp", 5248, __PRETTY_FUNCTION__).warning("QImage::setAlphaChannel: " | - |
5249 | "Alpha channel must have same dimensions as the target image"); never executed (the execution status of this line is deduced): "Alpha channel must have same dimensions as the target image"); | - |
5250 | return; | 0 |
5251 | } | - |
5252 | | - |
5253 | if (d->paintEngine && d->paintEngine->isActive()) { evaluated: d->paintEngine yes Evaluation Count:1 | yes Evaluation Count:127 |
partially evaluated: d->paintEngine->isActive() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-127 |
5254 | qWarning("QImage::setAlphaChannel: " executed (the execution status of this line is deduced): QMessageLogger("image/qimage.cpp", 5254, __PRETTY_FUNCTION__).warning("QImage::setAlphaChannel: " | - |
5255 | "Unable to set alpha channel while image is being painted on"); executed (the execution status of this line is deduced): "Unable to set alpha channel while image is being painted on"); | - |
5256 | return; executed: return; Execution Count:1 | 1 |
5257 | } | - |
5258 | | - |
5259 | if (d->format == QImage::Format_ARGB32_Premultiplied) partially evaluated: d->format == QImage::Format_ARGB32_Premultiplied no Evaluation Count:0 | yes Evaluation Count:127 |
| 0-127 |
5260 | detach(); never executed: detach(); | 0 |
5261 | else | - |
5262 | *this = convertToFormat(QImage::Format_ARGB32_Premultiplied); executed: *this = convertToFormat(QImage::Format_ARGB32_Premultiplied); Execution Count:127 | 127 |
5263 | | - |
5264 | if (isNull()) partially evaluated: isNull() no Evaluation Count:0 | yes Evaluation Count:127 |
| 0-127 |
5265 | return; | 0 |
5266 | | - |
5267 | // Slight optimization since alphachannels are returned as 8-bit grays. | - |
5268 | if (alphaChannel.d->depth == 8 && alphaChannel.isGrayscale()) { evaluated: alphaChannel.d->depth == 8 yes Evaluation Count:12 | yes Evaluation Count:115 |
partially evaluated: alphaChannel.isGrayscale() yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-115 |
5269 | const uchar *src_data = alphaChannel.d->data; executed (the execution status of this line is deduced): const uchar *src_data = alphaChannel.d->data; | - |
5270 | const uchar *dest_data = d->data; executed (the execution status of this line is deduced): const uchar *dest_data = d->data; | - |
5271 | for (int y=0; y<h; ++y) { evaluated: y<h yes Evaluation Count:1200 | yes Evaluation Count:12 |
| 12-1200 |
5272 | const uchar *src = src_data; executed (the execution status of this line is deduced): const uchar *src = src_data; | - |
5273 | QRgb *dest = (QRgb *)dest_data; executed (the execution status of this line is deduced): QRgb *dest = (QRgb *)dest_data; | - |
5274 | for (int x=0; x<w; ++x) { evaluated: x<w yes Evaluation Count:120000 | yes Evaluation Count:1200 |
| 1200-120000 |
5275 | int alpha = *src; executed (the execution status of this line is deduced): int alpha = *src; | - |
5276 | int destAlpha = qt_div_255(alpha * qAlpha(*dest)); executed (the execution status of this line is deduced): int destAlpha = qt_div_255(alpha * qAlpha(*dest)); | - |
5277 | *dest = ((destAlpha << 24) executed (the execution status of this line is deduced): *dest = ((destAlpha << 24) | - |
5278 | | (qt_div_255(qRed(*dest) * alpha) << 16) executed (the execution status of this line is deduced): | (qt_div_255(qRed(*dest) * alpha) << 16) | - |
5279 | | (qt_div_255(qGreen(*dest) * alpha) << 8) executed (the execution status of this line is deduced): | (qt_div_255(qGreen(*dest) * alpha) << 8) | - |
5280 | | (qt_div_255(qBlue(*dest) * alpha))); executed (the execution status of this line is deduced): | (qt_div_255(qBlue(*dest) * alpha))); | - |
5281 | ++dest; executed (the execution status of this line is deduced): ++dest; | - |
5282 | ++src; executed (the execution status of this line is deduced): ++src; | - |
5283 | } executed: } Execution Count:120000 | 120000 |
5284 | src_data += alphaChannel.d->bytes_per_line; executed (the execution status of this line is deduced): src_data += alphaChannel.d->bytes_per_line; | - |
5285 | dest_data += d->bytes_per_line; executed (the execution status of this line is deduced): dest_data += d->bytes_per_line; | - |
5286 | } executed: } Execution Count:1200 | 1200 |
5287 | | - |
5288 | } else { executed: } Execution Count:12 | 12 |
5289 | const QImage sourceImage = alphaChannel.convertToFormat(QImage::Format_RGB32); executed (the execution status of this line is deduced): const QImage sourceImage = alphaChannel.convertToFormat(QImage::Format_RGB32); | - |
5290 | const uchar *src_data = sourceImage.d->data; executed (the execution status of this line is deduced): const uchar *src_data = sourceImage.d->data; | - |
5291 | const uchar *dest_data = d->data; executed (the execution status of this line is deduced): const uchar *dest_data = d->data; | - |
5292 | for (int y=0; y<h; ++y) { evaluated: y<h yes Evaluation Count:1303 | yes Evaluation Count:115 |
| 115-1303 |
5293 | const QRgb *src = (const QRgb *) src_data; executed (the execution status of this line is deduced): const QRgb *src = (const QRgb *) src_data; | - |
5294 | QRgb *dest = (QRgb *) dest_data; executed (the execution status of this line is deduced): QRgb *dest = (QRgb *) dest_data; | - |
5295 | for (int x=0; x<w; ++x) { evaluated: x<w yes Evaluation Count:121648 | yes Evaluation Count:1303 |
| 1303-121648 |
5296 | int alpha = qGray(*src); executed (the execution status of this line is deduced): int alpha = qGray(*src); | - |
5297 | int destAlpha = qt_div_255(alpha * qAlpha(*dest)); executed (the execution status of this line is deduced): int destAlpha = qt_div_255(alpha * qAlpha(*dest)); | - |
5298 | *dest = ((destAlpha << 24) executed (the execution status of this line is deduced): *dest = ((destAlpha << 24) | - |
5299 | | (qt_div_255(qRed(*dest) * alpha) << 16) executed (the execution status of this line is deduced): | (qt_div_255(qRed(*dest) * alpha) << 16) | - |
5300 | | (qt_div_255(qGreen(*dest) * alpha) << 8) executed (the execution status of this line is deduced): | (qt_div_255(qGreen(*dest) * alpha) << 8) | - |
5301 | | (qt_div_255(qBlue(*dest) * alpha))); executed (the execution status of this line is deduced): | (qt_div_255(qBlue(*dest) * alpha))); | - |
5302 | ++dest; executed (the execution status of this line is deduced): ++dest; | - |
5303 | ++src; executed (the execution status of this line is deduced): ++src; | - |
5304 | } executed: } Execution Count:121648 | 121648 |
5305 | src_data += sourceImage.d->bytes_per_line; executed (the execution status of this line is deduced): src_data += sourceImage.d->bytes_per_line; | - |
5306 | dest_data += d->bytes_per_line; executed (the execution status of this line is deduced): dest_data += d->bytes_per_line; | - |
5307 | } executed: } Execution Count:1303 | 1303 |
5308 | } executed: } Execution Count:115 | 115 |
5309 | } | - |
5310 | | - |
5311 | | - |
5312 | /*! | - |
5313 | \obsolete | - |
5314 | | - |
5315 | Returns the alpha channel of the image as a new grayscale QImage in which | - |
5316 | each pixel's red, green, and blue values are given the alpha value of the | - |
5317 | original image. The color depth of the returned image is 8-bit. | - |
5318 | | - |
5319 | You can see an example of use of this function in QPixmap's | - |
5320 | \l{QPixmap::}{alphaChannel()}, which works in the same way as | - |
5321 | this function on QPixmaps. | - |
5322 | | - |
5323 | Most usecases for this function can be replaced with QPainter and | - |
5324 | using composition modes. | - |
5325 | | - |
5326 | \warning This is an expensive function. | - |
5327 | | - |
5328 | \sa setAlphaChannel(), hasAlphaChannel(), | - |
5329 | {QPixmap#Pixmap Information}{Pixmap}, | - |
5330 | {QImage#Image Transformations}{Image Transformations} | - |
5331 | */ | - |
5332 | | - |
5333 | QImage QImage::alphaChannel() const | - |
5334 | { | - |
5335 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
5336 | return QImage(); never executed: return QImage(); | 0 |
5337 | | - |
5338 | int w = d->width; executed (the execution status of this line is deduced): int w = d->width; | - |
5339 | int h = d->height; executed (the execution status of this line is deduced): int h = d->height; | - |
5340 | | - |
5341 | QImage image(w, h, Format_Indexed8); executed (the execution status of this line is deduced): QImage image(w, h, Format_Indexed8); | - |
5342 | image.setColorCount(256); executed (the execution status of this line is deduced): image.setColorCount(256); | - |
5343 | | - |
5344 | // set up gray scale table. | - |
5345 | for (int i=0; i<256; ++i) evaluated: i<256 yes Evaluation Count:6656 | yes Evaluation Count:26 |
| 26-6656 |
5346 | image.setColor(i, qRgb(i, i, i)); executed: image.setColor(i, qRgb(i, i, i)); Execution Count:6656 | 6656 |
5347 | | - |
5348 | if (!hasAlphaChannel()) { partially evaluated: !hasAlphaChannel() no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
5349 | image.fill(255); never executed (the execution status of this line is deduced): image.fill(255); | - |
5350 | return image; never executed: return image; | 0 |
5351 | } | - |
5352 | | - |
5353 | if (d->format == Format_Indexed8) { partially evaluated: d->format == Format_Indexed8 no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
5354 | const uchar *src_data = d->data; never executed (the execution status of this line is deduced): const uchar *src_data = d->data; | - |
5355 | uchar *dest_data = image.d->data; never executed (the execution status of this line is deduced): uchar *dest_data = image.d->data; | - |
5356 | for (int y=0; y<h; ++y) { | 0 |
5357 | const uchar *src = src_data; never executed (the execution status of this line is deduced): const uchar *src = src_data; | - |
5358 | uchar *dest = dest_data; never executed (the execution status of this line is deduced): uchar *dest = dest_data; | - |
5359 | for (int x=0; x<w; ++x) { | 0 |
5360 | *dest = qAlpha(d->colortable.at(*src)); never executed (the execution status of this line is deduced): *dest = qAlpha(d->colortable.at(*src)); | - |
5361 | ++dest; never executed (the execution status of this line is deduced): ++dest; | - |
5362 | ++src; never executed (the execution status of this line is deduced): ++src; | - |
5363 | } | 0 |
5364 | src_data += d->bytes_per_line; never executed (the execution status of this line is deduced): src_data += d->bytes_per_line; | - |
5365 | dest_data += image.d->bytes_per_line; never executed (the execution status of this line is deduced): dest_data += image.d->bytes_per_line; | - |
5366 | } | 0 |
5367 | } else { | 0 |
5368 | QImage alpha32 = *this; executed (the execution status of this line is deduced): QImage alpha32 = *this; | - |
5369 | if (d->format != Format_ARGB32 && d->format != Format_ARGB32_Premultiplied) evaluated: d->format != Format_ARGB32 yes Evaluation Count:1 | yes Evaluation Count:25 |
partially evaluated: d->format != Format_ARGB32_Premultiplied yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-25 |
5370 | alpha32 = convertToFormat(Format_ARGB32); executed: alpha32 = convertToFormat(Format_ARGB32); Execution Count:1 | 1 |
5371 | | - |
5372 | const uchar *src_data = alpha32.d->data; executed (the execution status of this line is deduced): const uchar *src_data = alpha32.d->data; | - |
5373 | uchar *dest_data = image.d->data; executed (the execution status of this line is deduced): uchar *dest_data = image.d->data; | - |
5374 | for (int y=0; y<h; ++y) { evaluated: y<h yes Evaluation Count:2420 | yes Evaluation Count:26 |
| 26-2420 |
5375 | const QRgb *src = (const QRgb *) src_data; executed (the execution status of this line is deduced): const QRgb *src = (const QRgb *) src_data; | - |
5376 | uchar *dest = dest_data; executed (the execution status of this line is deduced): uchar *dest = dest_data; | - |
5377 | for (int x=0; x<w; ++x) { evaluated: x<w yes Evaluation Count:240200 | yes Evaluation Count:2420 |
| 2420-240200 |
5378 | *dest = qAlpha(*src); executed (the execution status of this line is deduced): *dest = qAlpha(*src); | - |
5379 | ++dest; executed (the execution status of this line is deduced): ++dest; | - |
5380 | ++src; executed (the execution status of this line is deduced): ++src; | - |
5381 | } executed: } Execution Count:240200 | 240200 |
5382 | src_data += alpha32.d->bytes_per_line; executed (the execution status of this line is deduced): src_data += alpha32.d->bytes_per_line; | - |
5383 | dest_data += image.d->bytes_per_line; executed (the execution status of this line is deduced): dest_data += image.d->bytes_per_line; | - |
5384 | } executed: } Execution Count:2420 | 2420 |
5385 | } executed: } Execution Count:26 | 26 |
5386 | | - |
5387 | return image; executed: return image; Execution Count:26 | 26 |
5388 | } | - |
5389 | | - |
5390 | /*! | - |
5391 | Returns true if the image has a format that respects the alpha | - |
5392 | channel, otherwise returns false. | - |
5393 | | - |
5394 | \sa {QImage#Image Information}{Image Information} | - |
5395 | */ | - |
5396 | bool QImage::hasAlphaChannel() const | - |
5397 | { | - |
5398 | return d && (d->format == Format_ARGB32_Premultiplied executed: return d && (d->format == Format_ARGB32_Premultiplied || d->format == Format_ARGB32 || d->format == Format_ARGB8565_Premultiplied || d->format == Format_ARGB8555_Premultiplied || d->format == Format_ARGB6666_Premultiplied || d->format == Format_ARGB4444_Premultiplied || (d->has_alpha_clut && (d->format == Format_Indexed8 || d->format == Format_Mono || d->format == Format_MonoLSB))); Execution Count:10413 | 10413 |
5399 | || d->format == Format_ARGB32 executed: return d && (d->format == Format_ARGB32_Premultiplied || d->format == Format_ARGB32 || d->format == Format_ARGB8565_Premultiplied || d->format == Format_ARGB8555_Premultiplied || d->format == Format_ARGB6666_Premultiplied || d->format == Format_ARGB4444_Premultiplied || (d->has_alpha_clut && (d->format == Format_Indexed8 || d->format == Format_Mono || d->format == Format_MonoLSB))); Execution Count:10413 | 10413 |
5400 | || d->format == Format_ARGB8565_Premultiplied executed: return d && (d->format == Format_ARGB32_Premultiplied || d->format == Format_ARGB32 || d->format == Format_ARGB8565_Premultiplied || d->format == Format_ARGB8555_Premultiplied || d->format == Format_ARGB6666_Premultiplied || d->format == Format_ARGB4444_Premultiplied || (d->has_alpha_clut && (d->format == Format_Indexed8 || d->format == Format_Mono || d->format == Format_MonoLSB))); Execution Count:10413 | 10413 |
5401 | || d->format == Format_ARGB8555_Premultiplied executed: return d && (d->format == Format_ARGB32_Premultiplied || d->format == Format_ARGB32 || d->format == Format_ARGB8565_Premultiplied || d->format == Format_ARGB8555_Premultiplied || d->format == Format_ARGB6666_Premultiplied || d->format == Format_ARGB4444_Premultiplied || (d->has_alpha_clut && (d->format == Format_Indexed8 || d->format == Format_Mono || d->format == Format_MonoLSB))); Execution Count:10413 | 10413 |
5402 | || d->format == Format_ARGB6666_Premultiplied executed: return d && (d->format == Format_ARGB32_Premultiplied || d->format == Format_ARGB32 || d->format == Format_ARGB8565_Premultiplied || d->format == Format_ARGB8555_Premultiplied || d->format == Format_ARGB6666_Premultiplied || d->format == Format_ARGB4444_Premultiplied || (d->has_alpha_clut && (d->format == Format_Indexed8 || d->format == Format_Mono || d->format == Format_MonoLSB))); Execution Count:10413 | 10413 |
5403 | || d->format == Format_ARGB4444_Premultiplied executed: return d && (d->format == Format_ARGB32_Premultiplied || d->format == Format_ARGB32 || d->format == Format_ARGB8565_Premultiplied || d->format == Format_ARGB8555_Premultiplied || d->format == Format_ARGB6666_Premultiplied || d->format == Format_ARGB4444_Premultiplied || (d->has_alpha_clut && (d->format == Format_Indexed8 || d->format == Format_Mono || d->format == Format_MonoLSB))); Execution Count:10413 | 10413 |
5404 | || (d->has_alpha_clut && (d->format == Format_Indexed8 executed: return d && (d->format == Format_ARGB32_Premultiplied || d->format == Format_ARGB32 || d->format == Format_ARGB8565_Premultiplied || d->format == Format_ARGB8555_Premultiplied || d->format == Format_ARGB6666_Premultiplied || d->format == Format_ARGB4444_Premultiplied || (d->has_alpha_clut && (d->format == Format_Indexed8 || d->format == Format_Mono || d->format == Format_MonoLSB))); Execution Count:10413 | 10413 |
5405 | || d->format == Format_Mono executed: return d && (d->format == Format_ARGB32_Premultiplied || d->format == Format_ARGB32 || d->format == Format_ARGB8565_Premultiplied || d->format == Format_ARGB8555_Premultiplied || d->format == Format_ARGB6666_Premultiplied || d->format == Format_ARGB4444_Premultiplied || (d->has_alpha_clut && (d->format == Format_Indexed8 || d->format == Format_Mono || d->format == Format_MonoLSB))); Execution Count:10413 | 10413 |
5406 | || d->format == Format_MonoLSB))); executed: return d && (d->format == Format_ARGB32_Premultiplied || d->format == Format_ARGB32 || d->format == Format_ARGB8565_Premultiplied || d->format == Format_ARGB8555_Premultiplied || d->format == Format_ARGB6666_Premultiplied || d->format == Format_ARGB4444_Premultiplied || (d->has_alpha_clut && (d->format == Format_Indexed8 || d->format == Format_Mono || d->format == Format_MonoLSB))); Execution Count:10413 | 10413 |
5407 | } | - |
5408 | | - |
5409 | | - |
5410 | /*! | - |
5411 | \since 4.7 | - |
5412 | Returns the number of bit planes in the image. | - |
5413 | | - |
5414 | The number of bit planes is the number of bits of color and | - |
5415 | transparency information for each pixel. This is different from | - |
5416 | (i.e. smaller than) the depth when the image format contains | - |
5417 | unused bits. | - |
5418 | | - |
5419 | \sa depth(), format(), {QImage#Image Formats}{Image Formats} | - |
5420 | */ | - |
5421 | int QImage::bitPlaneCount() const | - |
5422 | { | - |
5423 | if (!d) | 0 |
5424 | return 0; never executed: return 0; | 0 |
5425 | int bpc = 0; never executed (the execution status of this line is deduced): int bpc = 0; | - |
5426 | switch (d->format) { | - |
5427 | case QImage::Format_Invalid: | - |
5428 | break; | 0 |
5429 | case QImage::Format_RGB32: | - |
5430 | bpc = 24; never executed (the execution status of this line is deduced): bpc = 24; | - |
5431 | break; | 0 |
5432 | case QImage::Format_RGB666: | - |
5433 | bpc = 18; never executed (the execution status of this line is deduced): bpc = 18; | - |
5434 | break; | 0 |
5435 | case QImage::Format_RGB555: | - |
5436 | bpc = 15; never executed (the execution status of this line is deduced): bpc = 15; | - |
5437 | break; | 0 |
5438 | case QImage::Format_ARGB8555_Premultiplied: | - |
5439 | bpc = 23; never executed (the execution status of this line is deduced): bpc = 23; | - |
5440 | break; | 0 |
5441 | case QImage::Format_RGB444: | - |
5442 | bpc = 12; never executed (the execution status of this line is deduced): bpc = 12; | - |
5443 | break; | 0 |
5444 | default: | - |
5445 | bpc = qt_depthForFormat(d->format); never executed (the execution status of this line is deduced): bpc = qt_depthForFormat(d->format); | - |
5446 | break; | 0 |
5447 | } | - |
5448 | return bpc; never executed: return bpc; | 0 |
5449 | } | - |
5450 | | - |
5451 | static QImage smoothScaled(const QImage &source, int w, int h) { | - |
5452 | QImage src = source; executed (the execution status of this line is deduced): QImage src = source; | - |
5453 | if (src.format() == QImage::Format_ARGB32) evaluated: src.format() == QImage::Format_ARGB32 yes Evaluation Count:56 | yes Evaluation Count:190 |
| 56-190 |
5454 | src = src.convertToFormat(QImage::Format_ARGB32_Premultiplied); executed: src = src.convertToFormat(QImage::Format_ARGB32_Premultiplied); Execution Count:56 | 56 |
5455 | else if (src.depth() < 32) { evaluated: src.depth() < 32 yes Evaluation Count:22 | yes Evaluation Count:168 |
| 22-168 |
5456 | if (src.hasAlphaChannel()) partially evaluated: src.hasAlphaChannel() no Evaluation Count:0 | yes Evaluation Count:22 |
| 0-22 |
5457 | src = src.convertToFormat(QImage::Format_ARGB32_Premultiplied); never executed: src = src.convertToFormat(QImage::Format_ARGB32_Premultiplied); | 0 |
5458 | else | - |
5459 | src = src.convertToFormat(QImage::Format_RGB32); executed: src = src.convertToFormat(QImage::Format_RGB32); Execution Count:22 | 22 |
5460 | } | - |
5461 | | - |
5462 | return qSmoothScaleImage(src, w, h); executed: return qSmoothScaleImage(src, w, h); Execution Count:246 | 246 |
5463 | } | - |
5464 | | - |
5465 | | - |
5466 | static QImage rotated90(const QImage &image) { | - |
5467 | QImage out(image.height(), image.width(), image.format()); executed (the execution status of this line is deduced): QImage out(image.height(), image.width(), image.format()); | - |
5468 | if (image.colorCount() > 0) evaluated: image.colorCount() > 0 yes Evaluation Count:4 | yes Evaluation Count:38 |
| 4-38 |
5469 | out.setColorTable(image.colorTable()); executed: out.setColorTable(image.colorTable()); Execution Count:4 | 4 |
5470 | int w = image.width(); executed (the execution status of this line is deduced): int w = image.width(); | - |
5471 | int h = image.height(); executed (the execution status of this line is deduced): int h = image.height(); | - |
5472 | switch (image.format()) { | - |
5473 | case QImage::Format_RGB32: | - |
5474 | case QImage::Format_ARGB32: | - |
5475 | case QImage::Format_ARGB32_Premultiplied: | - |
5476 | qt_memrotate270(reinterpret_cast<const quint32*>(image.bits()), executed (the execution status of this line is deduced): qt_memrotate270(reinterpret_cast<const quint32*>(image.bits()), | - |
5477 | w, h, image.bytesPerLine(), executed (the execution status of this line is deduced): w, h, image.bytesPerLine(), | - |
5478 | reinterpret_cast<quint32*>(out.bits()), executed (the execution status of this line is deduced): reinterpret_cast<quint32*>(out.bits()), | - |
5479 | out.bytesPerLine()); executed (the execution status of this line is deduced): out.bytesPerLine()); | - |
5480 | break; executed: break; Execution Count:14 | 14 |
5481 | case QImage::Format_RGB666: | - |
5482 | case QImage::Format_ARGB6666_Premultiplied: | - |
5483 | case QImage::Format_ARGB8565_Premultiplied: | - |
5484 | case QImage::Format_ARGB8555_Premultiplied: | - |
5485 | case QImage::Format_RGB888: | - |
5486 | qt_memrotate270(reinterpret_cast<const quint24*>(image.bits()), executed (the execution status of this line is deduced): qt_memrotate270(reinterpret_cast<const quint24*>(image.bits()), | - |
5487 | w, h, image.bytesPerLine(), executed (the execution status of this line is deduced): w, h, image.bytesPerLine(), | - |
5488 | reinterpret_cast<quint24*>(out.bits()), executed (the execution status of this line is deduced): reinterpret_cast<quint24*>(out.bits()), | - |
5489 | out.bytesPerLine()); executed (the execution status of this line is deduced): out.bytesPerLine()); | - |
5490 | break; executed: break; Execution Count:16 | 16 |
5491 | case QImage::Format_RGB555: | - |
5492 | case QImage::Format_RGB16: | - |
5493 | case QImage::Format_ARGB4444_Premultiplied: | - |
5494 | qt_memrotate270(reinterpret_cast<const quint16*>(image.bits()), executed (the execution status of this line is deduced): qt_memrotate270(reinterpret_cast<const quint16*>(image.bits()), | - |
5495 | w, h, image.bytesPerLine(), executed (the execution status of this line is deduced): w, h, image.bytesPerLine(), | - |
5496 | reinterpret_cast<quint16*>(out.bits()), executed (the execution status of this line is deduced): reinterpret_cast<quint16*>(out.bits()), | - |
5497 | out.bytesPerLine()); executed (the execution status of this line is deduced): out.bytesPerLine()); | - |
5498 | break; executed: break; Execution Count:8 | 8 |
5499 | case QImage::Format_Indexed8: | - |
5500 | qt_memrotate270(reinterpret_cast<const quint8*>(image.bits()), executed (the execution status of this line is deduced): qt_memrotate270(reinterpret_cast<const quint8*>(image.bits()), | - |
5501 | w, h, image.bytesPerLine(), executed (the execution status of this line is deduced): w, h, image.bytesPerLine(), | - |
5502 | reinterpret_cast<quint8*>(out.bits()), executed (the execution status of this line is deduced): reinterpret_cast<quint8*>(out.bits()), | - |
5503 | out.bytesPerLine()); executed (the execution status of this line is deduced): out.bytesPerLine()); | - |
5504 | break; executed: break; Execution Count:4 | 4 |
5505 | default: | - |
5506 | for (int y=0; y<h; ++y) { | 0 |
5507 | if (image.colorCount()) never evaluated: image.colorCount() | 0 |
5508 | for (int x=0; x<w; ++x) | 0 |
5509 | out.setPixel(h-y-1, x, image.pixelIndex(x, y)); never executed: out.setPixel(h-y-1, x, image.pixelIndex(x, y)); | 0 |
5510 | else | - |
5511 | for (int x=0; x<w; ++x) | 0 |
5512 | out.setPixel(h-y-1, x, image.pixel(x, y)); never executed: out.setPixel(h-y-1, x, image.pixel(x, y)); | 0 |
5513 | } | - |
5514 | break; | 0 |
5515 | } | - |
5516 | return out; executed: return out; Execution Count:42 | 42 |
5517 | } | - |
5518 | | - |
5519 | | - |
5520 | static QImage rotated180(const QImage &image) { | - |
5521 | return image.mirrored(true, true); executed: return image.mirrored(true, true); Execution Count:125 | 125 |
5522 | } | - |
5523 | | - |
5524 | | - |
5525 | static QImage rotated270(const QImage &image) { | - |
5526 | QImage out(image.height(), image.width(), image.format()); executed (the execution status of this line is deduced): QImage out(image.height(), image.width(), image.format()); | - |
5527 | if (image.colorCount() > 0) evaluated: image.colorCount() > 0 yes Evaluation Count:4 | yes Evaluation Count:38 |
| 4-38 |
5528 | out.setColorTable(image.colorTable()); executed: out.setColorTable(image.colorTable()); Execution Count:4 | 4 |
5529 | int w = image.width(); executed (the execution status of this line is deduced): int w = image.width(); | - |
5530 | int h = image.height(); executed (the execution status of this line is deduced): int h = image.height(); | - |
5531 | switch (image.format()) { | - |
5532 | case QImage::Format_RGB32: | - |
5533 | case QImage::Format_ARGB32: | - |
5534 | case QImage::Format_ARGB32_Premultiplied: | - |
5535 | qt_memrotate90(reinterpret_cast<const quint32*>(image.bits()), executed (the execution status of this line is deduced): qt_memrotate90(reinterpret_cast<const quint32*>(image.bits()), | - |
5536 | w, h, image.bytesPerLine(), executed (the execution status of this line is deduced): w, h, image.bytesPerLine(), | - |
5537 | reinterpret_cast<quint32*>(out.bits()), executed (the execution status of this line is deduced): reinterpret_cast<quint32*>(out.bits()), | - |
5538 | out.bytesPerLine()); executed (the execution status of this line is deduced): out.bytesPerLine()); | - |
5539 | break; executed: break; Execution Count:14 | 14 |
5540 | case QImage::Format_RGB666: | - |
5541 | case QImage::Format_ARGB6666_Premultiplied: | - |
5542 | case QImage::Format_ARGB8565_Premultiplied: | - |
5543 | case QImage::Format_ARGB8555_Premultiplied: | - |
5544 | case QImage::Format_RGB888: | - |
5545 | qt_memrotate90(reinterpret_cast<const quint24*>(image.bits()), executed (the execution status of this line is deduced): qt_memrotate90(reinterpret_cast<const quint24*>(image.bits()), | - |
5546 | w, h, image.bytesPerLine(), executed (the execution status of this line is deduced): w, h, image.bytesPerLine(), | - |
5547 | reinterpret_cast<quint24*>(out.bits()), executed (the execution status of this line is deduced): reinterpret_cast<quint24*>(out.bits()), | - |
5548 | out.bytesPerLine()); executed (the execution status of this line is deduced): out.bytesPerLine()); | - |
5549 | break; executed: break; Execution Count:16 | 16 |
5550 | case QImage::Format_RGB555: | - |
5551 | case QImage::Format_RGB16: | - |
5552 | case QImage::Format_ARGB4444_Premultiplied: | - |
5553 | qt_memrotate90(reinterpret_cast<const quint16*>(image.bits()), executed (the execution status of this line is deduced): qt_memrotate90(reinterpret_cast<const quint16*>(image.bits()), | - |
5554 | w, h, image.bytesPerLine(), executed (the execution status of this line is deduced): w, h, image.bytesPerLine(), | - |
5555 | reinterpret_cast<quint16*>(out.bits()), executed (the execution status of this line is deduced): reinterpret_cast<quint16*>(out.bits()), | - |
5556 | out.bytesPerLine()); executed (the execution status of this line is deduced): out.bytesPerLine()); | - |
5557 | break; executed: break; Execution Count:8 | 8 |
5558 | case QImage::Format_Indexed8: | - |
5559 | qt_memrotate90(reinterpret_cast<const quint8*>(image.bits()), executed (the execution status of this line is deduced): qt_memrotate90(reinterpret_cast<const quint8*>(image.bits()), | - |
5560 | w, h, image.bytesPerLine(), executed (the execution status of this line is deduced): w, h, image.bytesPerLine(), | - |
5561 | reinterpret_cast<quint8*>(out.bits()), executed (the execution status of this line is deduced): reinterpret_cast<quint8*>(out.bits()), | - |
5562 | out.bytesPerLine()); executed (the execution status of this line is deduced): out.bytesPerLine()); | - |
5563 | break; executed: break; Execution Count:4 | 4 |
5564 | default: | - |
5565 | for (int y=0; y<h; ++y) { | 0 |
5566 | if (image.colorCount()) never evaluated: image.colorCount() | 0 |
5567 | for (int x=0; x<w; ++x) | 0 |
5568 | out.setPixel(y, w-x-1, image.pixelIndex(x, y)); never executed: out.setPixel(y, w-x-1, image.pixelIndex(x, y)); | 0 |
5569 | else | - |
5570 | for (int x=0; x<w; ++x) | 0 |
5571 | out.setPixel(y, w-x-1, image.pixel(x, y)); never executed: out.setPixel(y, w-x-1, image.pixel(x, y)); | 0 |
5572 | } | - |
5573 | break; | 0 |
5574 | } | - |
5575 | return out; executed: return out; Execution Count:42 | 42 |
5576 | } | - |
5577 | | - |
5578 | /*! | - |
5579 | Returns a copy of the image that is transformed using the given | - |
5580 | transformation \a matrix and transformation \a mode. | - |
5581 | | - |
5582 | The transformation \a matrix is internally adjusted to compensate | - |
5583 | for unwanted translation; i.e. the image produced is the smallest | - |
5584 | image that contains all the transformed points of the original | - |
5585 | image. Use the trueMatrix() function to retrieve the actual matrix | - |
5586 | used for transforming an image. | - |
5587 | | - |
5588 | Unlike the other overload, this function can be used to perform perspective | - |
5589 | transformations on images. | - |
5590 | | - |
5591 | \sa trueMatrix(), {QImage#Image Transformations}{Image | - |
5592 | Transformations} | - |
5593 | */ | - |
5594 | | - |
5595 | QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode ) const | - |
5596 | { | - |
5597 | if (!d) partially evaluated: !d no Evaluation Count:0 | yes Evaluation Count:594 |
| 0-594 |
5598 | return QImage(); never executed: return QImage(); | 0 |
5599 | | - |
5600 | // source image data | - |
5601 | int ws = width(); executed (the execution status of this line is deduced): int ws = width(); | - |
5602 | int hs = height(); executed (the execution status of this line is deduced): int hs = height(); | - |
5603 | | - |
5604 | // target image data | - |
5605 | int wd; executed (the execution status of this line is deduced): int wd; | - |
5606 | int hd; executed (the execution status of this line is deduced): int hd; | - |
5607 | | - |
5608 | // compute size of target image | - |
5609 | QTransform mat = trueMatrix(matrix, ws, hs); executed (the execution status of this line is deduced): QTransform mat = trueMatrix(matrix, ws, hs); | - |
5610 | bool complex_xform = false; executed (the execution status of this line is deduced): bool complex_xform = false; | - |
5611 | bool scale_xform = false; executed (the execution status of this line is deduced): bool scale_xform = false; | - |
5612 | if (mat.type() <= QTransform::TxScale) { evaluated: mat.type() <= QTransform::TxScale yes Evaluation Count:505 | yes Evaluation Count:89 |
| 89-505 |
5613 | if (mat.type() == QTransform::TxNone) // identity matrix evaluated: mat.type() == QTransform::TxNone yes Evaluation Count:120 | yes Evaluation Count:385 |
| 120-385 |
5614 | return *this; executed: return *this; Execution Count:120 | 120 |
5615 | else if (mat.m11() == -1. && mat.m22() == -1.) evaluated: mat.m11() == -1. yes Evaluation Count:125 | yes Evaluation Count:260 |
partially evaluated: mat.m22() == -1. yes Evaluation Count:125 | no Evaluation Count:0 |
| 0-260 |
5616 | return rotated180(*this); executed: return rotated180(*this); Execution Count:125 | 125 |
5617 | | - |
5618 | if (mode == Qt::FastTransformation) { evaluated: mode == Qt::FastTransformation yes Evaluation Count:14 | yes Evaluation Count:246 |
| 14-246 |
5619 | hd = qRound(qAbs(mat.m22()) * hs); executed (the execution status of this line is deduced): hd = qRound(qAbs(mat.m22()) * hs); | - |
5620 | wd = qRound(qAbs(mat.m11()) * ws); executed (the execution status of this line is deduced): wd = qRound(qAbs(mat.m11()) * ws); | - |
5621 | } else { executed: } Execution Count:14 | 14 |
5622 | hd = int(qAbs(mat.m22()) * hs + 0.9999); executed (the execution status of this line is deduced): hd = int(qAbs(mat.m22()) * hs + 0.9999); | - |
5623 | wd = int(qAbs(mat.m11()) * ws + 0.9999); executed (the execution status of this line is deduced): wd = int(qAbs(mat.m11()) * ws + 0.9999); | - |
5624 | } executed: } Execution Count:246 | 246 |
5625 | scale_xform = true; executed (the execution status of this line is deduced): scale_xform = true; | - |
5626 | } else { executed: } Execution Count:260 | 260 |
5627 | if (mat.type() <= QTransform::TxRotate && mat.m11() == 0 && mat.m22() == 0) { evaluated: mat.type() <= QTransform::TxRotate yes Evaluation Count:87 | yes Evaluation Count:2 |
evaluated: mat.m11() == 0 yes Evaluation Count:86 | yes Evaluation Count:1 |
partially evaluated: mat.m22() == 0 yes Evaluation Count:86 | no Evaluation Count:0 |
| 0-87 |
5628 | if (mat.m12() == 1. && mat.m21() == -1.) evaluated: mat.m12() == 1. yes Evaluation Count:42 | yes Evaluation Count:44 |
partially evaluated: mat.m21() == -1. yes Evaluation Count:42 | no Evaluation Count:0 |
| 0-44 |
5629 | return rotated90(*this); executed: return rotated90(*this); Execution Count:42 | 42 |
5630 | else if (mat.m12() == -1. && mat.m21() == 1.) evaluated: mat.m12() == -1. yes Evaluation Count:42 | yes Evaluation Count:2 |
partially evaluated: mat.m21() == 1. yes Evaluation Count:42 | no Evaluation Count:0 |
| 0-42 |
5631 | return rotated270(*this); executed: return rotated270(*this); Execution Count:42 | 42 |
5632 | } | - |
5633 | | - |
5634 | QPolygonF a(QRectF(0, 0, ws, hs)); executed (the execution status of this line is deduced): QPolygonF a(QRectF(0, 0, ws, hs)); | - |
5635 | a = mat.map(a); executed (the execution status of this line is deduced): a = mat.map(a); | - |
5636 | QRect r = a.boundingRect().toAlignedRect(); executed (the execution status of this line is deduced): QRect r = a.boundingRect().toAlignedRect(); | - |
5637 | wd = r.width(); executed (the execution status of this line is deduced): wd = r.width(); | - |
5638 | hd = r.height(); executed (the execution status of this line is deduced): hd = r.height(); | - |
5639 | complex_xform = true; executed (the execution status of this line is deduced): complex_xform = true; | - |
5640 | } executed: } Execution Count:5 | 5 |
5641 | | - |
5642 | if (wd == 0 || hd == 0) partially evaluated: wd == 0 no Evaluation Count:0 | yes Evaluation Count:265 |
partially evaluated: hd == 0 no Evaluation Count:0 | yes Evaluation Count:265 |
| 0-265 |
5643 | return QImage(); never executed: return QImage(); | 0 |
5644 | | - |
5645 | // Make use of the optimized algorithm when we're scaling | - |
5646 | if (scale_xform && mode == Qt::SmoothTransformation) { evaluated: scale_xform yes Evaluation Count:260 | yes Evaluation Count:5 |
evaluated: mode == Qt::SmoothTransformation yes Evaluation Count:246 | yes Evaluation Count:14 |
| 5-260 |
5647 | if (mat.m11() < 0.0F && mat.m22() < 0.0F) { // horizontal/vertical flip partially evaluated: mat.m11() < 0.0F no Evaluation Count:0 | yes Evaluation Count:246 |
never evaluated: mat.m22() < 0.0F | 0-246 |
5648 | return smoothScaled(mirrored(true, true), wd, hd); never executed: return smoothScaled(mirrored(true, true), wd, hd); | 0 |
5649 | } else if (mat.m11() < 0.0F) { // horizontal flip partially evaluated: mat.m11() < 0.0F no Evaluation Count:0 | yes Evaluation Count:246 |
| 0-246 |
5650 | return smoothScaled(mirrored(true, false), wd, hd); never executed: return smoothScaled(mirrored(true, false), wd, hd); | 0 |
5651 | } else if (mat.m22() < 0.0F) { // vertical flip partially evaluated: mat.m22() < 0.0F no Evaluation Count:0 | yes Evaluation Count:246 |
| 0-246 |
5652 | return smoothScaled(mirrored(false, true), wd, hd); never executed: return smoothScaled(mirrored(false, true), wd, hd); | 0 |
5653 | } else { // no flipping | - |
5654 | return smoothScaled(*this, wd, hd); executed: return smoothScaled(*this, wd, hd); Execution Count:246 | 246 |
5655 | } | - |
5656 | } | - |
5657 | | - |
5658 | int bpp = depth(); executed (the execution status of this line is deduced): int bpp = depth(); | - |
5659 | | - |
5660 | int sbpl = bytesPerLine(); executed (the execution status of this line is deduced): int sbpl = bytesPerLine(); | - |
5661 | const uchar *sptr = bits(); executed (the execution status of this line is deduced): const uchar *sptr = bits(); | - |
5662 | | - |
5663 | QImage::Format target_format = d->format; executed (the execution status of this line is deduced): QImage::Format target_format = d->format; | - |
5664 | | - |
5665 | if (complex_xform || mode == Qt::SmoothTransformation) { evaluated: complex_xform yes Evaluation Count:5 | yes Evaluation Count:14 |
partially evaluated: mode == Qt::SmoothTransformation no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
5666 | if (d->format < QImage::Format_RGB32 || !hasAlphaChannel()) { evaluated: d->format < QImage::Format_RGB32 yes Evaluation Count:1 | yes Evaluation Count:4 |
evaluated: !hasAlphaChannel() yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-4 |
5667 | switch(d->format) { | - |
5668 | case QImage::Format_RGB16: | - |
5669 | target_format = Format_ARGB8565_Premultiplied; never executed (the execution status of this line is deduced): target_format = Format_ARGB8565_Premultiplied; | - |
5670 | break; | 0 |
5671 | case QImage::Format_RGB555: | - |
5672 | target_format = Format_ARGB8555_Premultiplied; never executed (the execution status of this line is deduced): target_format = Format_ARGB8555_Premultiplied; | - |
5673 | break; | 0 |
5674 | case QImage::Format_RGB666: | - |
5675 | target_format = Format_ARGB6666_Premultiplied; never executed (the execution status of this line is deduced): target_format = Format_ARGB6666_Premultiplied; | - |
5676 | break; | 0 |
5677 | case QImage::Format_RGB444: | - |
5678 | target_format = Format_ARGB4444_Premultiplied; never executed (the execution status of this line is deduced): target_format = Format_ARGB4444_Premultiplied; | - |
5679 | break; | 0 |
5680 | default: | - |
5681 | target_format = Format_ARGB32_Premultiplied; executed (the execution status of this line is deduced): target_format = Format_ARGB32_Premultiplied; | - |
5682 | break; executed: break; Execution Count:2 | 2 |
5683 | } | - |
5684 | } executed: } Execution Count:2 | 2 |
5685 | } executed: } Execution Count:5 | 5 |
5686 | | - |
5687 | QImage dImage(wd, hd, target_format); executed (the execution status of this line is deduced): QImage dImage(wd, hd, target_format); | - |
5688 | QIMAGE_SANITYCHECK_MEMORY(dImage); never executed: return QImage(); partially evaluated: (dImage).isNull() no Evaluation Count:0 | yes Evaluation Count:19 |
| 0-19 |
5689 | | - |
5690 | if (target_format == QImage::Format_MonoLSB partially evaluated: target_format == QImage::Format_MonoLSB no Evaluation Count:0 | yes Evaluation Count:19 |
| 0-19 |
5691 | || target_format == QImage::Format_Mono evaluated: target_format == QImage::Format_Mono yes Evaluation Count:2 | yes Evaluation Count:17 |
| 2-17 |
5692 | || target_format == QImage::Format_Indexed8) { partially evaluated: target_format == QImage::Format_Indexed8 no Evaluation Count:0 | yes Evaluation Count:17 |
| 0-17 |
5693 | dImage.d->colortable = d->colortable; executed (the execution status of this line is deduced): dImage.d->colortable = d->colortable; | - |
5694 | dImage.d->has_alpha_clut = d->has_alpha_clut | complex_xform; executed (the execution status of this line is deduced): dImage.d->has_alpha_clut = d->has_alpha_clut | complex_xform; | - |
5695 | } executed: } Execution Count:2 | 2 |
5696 | | - |
5697 | dImage.d->dpmx = dotsPerMeterX(); executed (the execution status of this line is deduced): dImage.d->dpmx = dotsPerMeterX(); | - |
5698 | dImage.d->dpmy = dotsPerMeterY(); executed (the execution status of this line is deduced): dImage.d->dpmy = dotsPerMeterY(); | - |
5699 | dImage.d->devicePixelRatio = devicePixelRatio(); executed (the execution status of this line is deduced): dImage.d->devicePixelRatio = devicePixelRatio(); | - |
5700 | | - |
5701 | switch (bpp) { | - |
5702 | // initizialize the data | - |
5703 | case 8: | - |
5704 | if (dImage.d->colortable.size() < 256) { never evaluated: dImage.d->colortable.size() < 256 | 0 |
5705 | // colors are left in the color table, so pick that one as transparent | - |
5706 | dImage.d->colortable.append(0x0); never executed (the execution status of this line is deduced): dImage.d->colortable.append(0x0); | - |
5707 | memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage.byteCount()); never executed (the execution status of this line is deduced): memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage.byteCount()); | - |
5708 | } else { | 0 |
5709 | memset(dImage.bits(), 0, dImage.byteCount()); never executed (the execution status of this line is deduced): memset(dImage.bits(), 0, dImage.byteCount()); | - |
5710 | } | 0 |
5711 | break; | 0 |
5712 | case 1: | - |
5713 | case 16: | - |
5714 | case 24: | - |
5715 | case 32: | - |
5716 | memset(dImage.bits(), 0x00, dImage.byteCount()); executed (the execution status of this line is deduced): memset(dImage.bits(), 0x00, dImage.byteCount()); | - |
5717 | break; executed: break; Execution Count:19 | 19 |
5718 | } | - |
5719 | | - |
5720 | if (target_format >= QImage::Format_RGB32) { evaluated: target_format >= QImage::Format_RGB32 yes Evaluation Count:17 | yes Evaluation Count:2 |
| 2-17 |
5721 | QPainter p(&dImage); executed (the execution status of this line is deduced): QPainter p(&dImage); | - |
5722 | if (mode == Qt::SmoothTransformation) { evaluated: mode == Qt::SmoothTransformation yes Evaluation Count:3 | yes Evaluation Count:14 |
| 3-14 |
5723 | p.setRenderHint(QPainter::Antialiasing); executed (the execution status of this line is deduced): p.setRenderHint(QPainter::Antialiasing); | - |
5724 | p.setRenderHint(QPainter::SmoothPixmapTransform); executed (the execution status of this line is deduced): p.setRenderHint(QPainter::SmoothPixmapTransform); | - |
5725 | } executed: } Execution Count:3 | 3 |
5726 | p.setTransform(mat); executed (the execution status of this line is deduced): p.setTransform(mat); | - |
5727 | p.drawImage(QPoint(0, 0), *this); executed (the execution status of this line is deduced): p.drawImage(QPoint(0, 0), *this); | - |
5728 | } else { executed: } Execution Count:17 | 17 |
5729 | bool invertible; executed (the execution status of this line is deduced): bool invertible; | - |
5730 | mat = mat.inverted(&invertible); // invert matrix executed (the execution status of this line is deduced): mat = mat.inverted(&invertible); | - |
5731 | if (!invertible) // error, return null image partially evaluated: !invertible no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
5732 | return QImage(); never executed: return QImage(); | 0 |
5733 | | - |
5734 | // create target image (some of the code is from QImage::copy()) | - |
5735 | int type = format() == Format_Mono ? QT_XFORM_TYPE_MSBFIRST : QT_XFORM_TYPE_LSBFIRST; partially evaluated: format() == Format_Mono yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
5736 | int dbpl = dImage.bytesPerLine(); executed (the execution status of this line is deduced): int dbpl = dImage.bytesPerLine(); | - |
5737 | qt_xForm_helper(mat, 0, type, bpp, dImage.bits(), dbpl, 0, hd, sptr, sbpl, ws, hs); executed (the execution status of this line is deduced): qt_xForm_helper(mat, 0, type, bpp, dImage.bits(), dbpl, 0, hd, sptr, sbpl, ws, hs); | - |
5738 | } executed: } Execution Count:2 | 2 |
5739 | return dImage; executed: return dImage; Execution Count:19 | 19 |
5740 | } | - |
5741 | | - |
5742 | /*! | - |
5743 | \fn QTransform QImage::trueMatrix(const QTransform &matrix, int width, int height) | - |
5744 | | - |
5745 | Returns the actual matrix used for transforming an image with the | - |
5746 | given \a width, \a height and \a matrix. | - |
5747 | | - |
5748 | When transforming an image using the transformed() function, the | - |
5749 | transformation matrix is internally adjusted to compensate for | - |
5750 | unwanted translation, i.e. transformed() returns the smallest | - |
5751 | image containing all transformed points of the original image. | - |
5752 | This function returns the modified matrix, which maps points | - |
5753 | correctly from the original image into the new image. | - |
5754 | | - |
5755 | Unlike the other overload, this function creates transformation | - |
5756 | matrices that can be used to perform perspective | - |
5757 | transformations on images. | - |
5758 | | - |
5759 | \sa transformed(), {QImage#Image Transformations}{Image | - |
5760 | Transformations} | - |
5761 | */ | - |
5762 | | - |
5763 | QTransform QImage::trueMatrix(const QTransform &matrix, int w, int h) | - |
5764 | { | - |
5765 | const QRectF rect(0, 0, w, h); executed (the execution status of this line is deduced): const QRectF rect(0, 0, w, h); | - |
5766 | const QRect mapped = matrix.mapRect(rect).toAlignedRect(); executed (the execution status of this line is deduced): const QRect mapped = matrix.mapRect(rect).toAlignedRect(); | - |
5767 | const QPoint delta = mapped.topLeft(); executed (the execution status of this line is deduced): const QPoint delta = mapped.topLeft(); | - |
5768 | return matrix * QTransform().translate(-delta.x(), -delta.y()); executed: return matrix * QTransform().translate(-delta.x(), -delta.y()); Execution Count:602 | 602 |
5769 | } | - |
5770 | | - |
5771 | bool QImageData::convertInPlace(QImage::Format newFormat, Qt::ImageConversionFlags flags) | - |
5772 | { | - |
5773 | if (format == newFormat) evaluated: format == newFormat yes Evaluation Count:10 | yes Evaluation Count:20 |
| 10-20 |
5774 | return true; executed: return true; Execution Count:10 | 10 |
5775 | | - |
5776 | // No in-place conversion if we have to detach | - |
5777 | if (ref.load() > 1) evaluated: ref.load() > 1 yes Evaluation Count:3 | yes Evaluation Count:17 |
| 3-17 |
5778 | return false; executed: return false; Execution Count:3 | 3 |
5779 | | - |
5780 | const InPlace_Image_Converter *const converterPtr = &inplace_converter_map[format][newFormat]; executed (the execution status of this line is deduced): const InPlace_Image_Converter *const converterPtr = &inplace_converter_map[format][newFormat]; | - |
5781 | InPlace_Image_Converter converter = *converterPtr; executed (the execution status of this line is deduced): InPlace_Image_Converter converter = *converterPtr; | - |
5782 | if (converter) evaluated: converter yes Evaluation Count:15 | yes Evaluation Count:2 |
| 2-15 |
5783 | return converter(this, flags); executed: return converter(this, flags); Execution Count:15 | 15 |
5784 | else | - |
5785 | return false; executed: return false; Execution Count:2 | 2 |
5786 | } | - |
5787 | | - |
5788 | /*! | - |
5789 | \typedef QImage::DataPtr | - |
5790 | \internal | - |
5791 | */ | - |
5792 | | - |
5793 | /*! | - |
5794 | \fn DataPtr & QImage::data_ptr() | - |
5795 | \internal | - |
5796 | */ | - |
5797 | | - |
5798 | #ifndef QT_NO_DEBUG_STREAM | - |
5799 | QDebug operator<<(QDebug dbg, const QImage &i) | - |
5800 | { | - |
5801 | dbg.nospace() << "QImage(" << i.size() << ')'; executed (the execution status of this line is deduced): dbg.nospace() << "QImage(" << i.size() << ')'; | - |
5802 | return dbg.space(); executed: return dbg.space(); Execution Count:1 | 1 |
5803 | } | - |
5804 | #endif | - |
5805 | | - |
5806 | /*! | - |
5807 | \fn void QImage::setNumColors(int n) | - |
5808 | \obsolete | - |
5809 | | - |
5810 | Resizes the color table to contain \a n entries. | - |
5811 | | - |
5812 | \sa setColorCount() | - |
5813 | */ | - |
5814 | | - |
5815 | /*! | - |
5816 | \fn int QImage::numBytes() const | - |
5817 | \obsolete | - |
5818 | | - |
5819 | Returns the number of bytes occupied by the image data. | - |
5820 | | - |
5821 | \sa byteCount() | - |
5822 | */ | - |
5823 | | - |
5824 | /*! | - |
5825 | \fn QStringList QImage::textLanguages() const | - |
5826 | \obsolete | - |
5827 | | - |
5828 | Returns the language identifiers for which some texts are recorded. | - |
5829 | Note that if you want to iterate over the list, you should iterate over a copy. | - |
5830 | | - |
5831 | The language the text is recorded in is no longer relevant since the text is | - |
5832 | always set using QString and UTF-8 representation. | - |
5833 | | - |
5834 | \sa textKeys() | - |
5835 | */ | - |
5836 | | - |
5837 | /*! | - |
5838 | \fn QList<QImageTextKeyLang> QImage::textList() const | - |
5839 | \obsolete | - |
5840 | | - |
5841 | Returns a list of QImageTextKeyLang objects that enumerate all the texts | - |
5842 | key/language pairs set for this image. | - |
5843 | | - |
5844 | The language the text is recorded in is no longer relevant since the text | - |
5845 | is always set using QString and UTF-8 representation. | - |
5846 | | - |
5847 | \sa textKeys() | - |
5848 | */ | - |
5849 | | - |
5850 | QT_END_NAMESPACE | - |
5851 | | - |
| | |