qimage.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/image/qimage.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qimage.h"-
35#include "qdatastream.h"-
36#include "qbuffer.h"-
37#include "qmap.h"-
38#include "qmatrix.h"-
39#include "qtransform.h"-
40#include "qimagereader.h"-
41#include "qimagewriter.h"-
42#include "qstringlist.h"-
43#include "qvariant.h"-
44#include "qimagepixmapcleanuphooks_p.h"-
45#include <qpa/qplatformintegration.h>-
46#include <private/qguiapplication_p.h>-
47#include <ctype.h>-
48#include <stdlib.h>-
49#include <limits.h>-
50#include <qpa/qplatformpixmap.h>-
51#include <private/qdrawhelper_p.h>-
52#include <private/qmemrotate_p.h>-
53#include <private/qimagescale_p.h>-
54#include <private/qsimd_p.h>-
55-
56#include <qhash.h>-
57-
58#include <private/qpaintengine_raster_p.h>-
59-
60#include <private/qimage_p.h>-
61#include <private/qfont_p.h>-
62-
63QT_BEGIN_NAMESPACE-
64-
65static inline bool isLocked(QImageData *data)-
66{-
67 return data != 0 && data->is_locked;
never executed: return data != 0 && data->is_locked;
data != 0Description
TRUEnever evaluated
FALSEnever evaluated
data->is_lockedDescription
TRUEnever evaluated
FALSEnever evaluated
0
68}-
69-
70#if defined(Q_CC_DEC) && defined(__alpha) && (__DECCXX_VER-0 >= 50190001)-
71#pragma message disable narrowptr-
72#endif-
73-
74-
75#define QIMAGE_SANITYCHECK_MEMORY(image) \-
76 if ((image).isNull()) { \-
77 qWarning("QImage: out of memory, returning null image"); \-
78 return QImage(); \-
79 }-
80-
81-
82static QImage rotated90(const QImage &src);-
83static QImage rotated180(const QImage &src);-
84static QImage rotated270(const QImage &src);-
85-
86QBasicAtomicInt qimage_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1);-
87-
88QImageData::QImageData()-
89 : ref(0), width(0), height(0), depth(0), nbytes(0), devicePixelRatio(1.0), data(0),-
90 format(QImage::Format_ARGB32), bytes_per_line(0),-
91 ser_no(qimage_serial_number.fetchAndAddRelaxed(1)),-
92 detach_no(0),-
93 dpmx(qt_defaultDpiX() * 100 / qreal(2.54)),-
94 dpmy(qt_defaultDpiY() * 100 / qreal(2.54)),-
95 offset(0, 0), own_data(true), ro_data(false), has_alpha_clut(false),-
96 is_cached(false), is_locked(false), cleanupFunction(0), cleanupInfo(0),-
97 paintEngine(0)-
98{-
99}
never executed: end of block
0
100-
101/*! \fn QImageData * QImageData::create(const QSize &size, QImage::Format format)-
102-
103 \internal-
104-
105 Creates a new image data.-
106 Returns 0 if invalid parameters are give or anything else failed.-
107*/-
108QImageData * QImageData::create(const QSize &size, QImage::Format format)-
109{-
110 if (!size.isValid() || format == QImage::Format_Invalid)
!size.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
format == QIma...Format_InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
0
111 return 0; // invalid parameter(s)
never executed: return 0;
0
112-
113 uint width = size.width();-
114 uint height = size.height();-
115 uint depth = qt_depthForFormat(format);-
116-
117 const int bytes_per_line = ((width * depth + 31) >> 5) << 2; // bytes per scanline (must be multiple of 4)-
118-
119 // sanity check for potential overflows-
120 if (INT_MAX/depth < width
2147483647/depth < widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
121 || bytes_per_line <= 0
bytes_per_line <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
122 || height <= 0
height <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
123 || INT_MAX/uint(bytes_per_line) < height
2147483647/uin...line) < heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
124 || INT_MAX/sizeof(uchar *) < uint(height))
2147483647/siz...< uint(height)Description
TRUEnever evaluated
FALSEnever evaluated
0
125 return 0;
never executed: return 0;
0
126-
127 QScopedPointer<QImageData> d(new QImageData);-
128-
129 switch (format) {-
130 case QImage::Format_Mono:
never executed: case QImage::Format_Mono:
0
131 case QImage::Format_MonoLSB:
never executed: case QImage::Format_MonoLSB:
0
132 d->colortable.resize(2);-
133 d->colortable[0] = QColor(Qt::black).rgba();-
134 d->colortable[1] = QColor(Qt::white).rgba();-
135 break;
never executed: break;
0
136 default:
never executed: default:
0
137 break;
never executed: break;
0
138 }-
139-
140 d->width = width;-
141 d->height = height;-
142 d->depth = depth;-
143 d->format = format;-
144 d->has_alpha_clut = false;-
145 d->is_cached = false;-
146-
147 d->bytes_per_line = bytes_per_line;-
148-
149 d->nbytes = d->bytes_per_line*height;-
150 d->data = (uchar *)malloc(d->nbytes);-
151-
152 if (!d->data) {
!d->dataDescription
TRUEnever evaluated
FALSEnever evaluated
0
153 return 0;
never executed: return 0;
0
154 }-
155-
156 d->ref.ref();-
157 return d.take();
never executed: return d.take();
0
158-
159}-
160-
161QImageData::~QImageData()-
162{-
163 if (cleanupFunction)
cleanupFunctionDescription
TRUEnever evaluated
FALSEnever evaluated
0
164 cleanupFunction(cleanupInfo);
never executed: cleanupFunction(cleanupInfo);
0
165 if (is_cached)
is_cachedDescription
TRUEnever evaluated
FALSEnever evaluated
0
166 QImagePixmapCleanupHooks::executeImageHooks((((qint64) ser_no) << 32) | ((qint64) detach_no));
never executed: QImagePixmapCleanupHooks::executeImageHooks((((qint64) ser_no) << 32) | ((qint64) detach_no));
0
167 delete paintEngine;-
168 if (data && own_data)
dataDescription
TRUEnever evaluated
FALSEnever evaluated
own_dataDescription
TRUEnever evaluated
FALSEnever evaluated
0
169 free(data);
never executed: free(data);
0
170 data = 0;-
171}
never executed: end of block
0
172-
173#if defined(_M_ARM)-
174#pragma optimize("", off)-
175#endif-
176-
177bool QImageData::checkForAlphaPixels() const-
178{-
179 bool has_alpha_pixels = false;-
180-
181 switch (format) {-
182-
183 case QImage::Format_Mono:
never executed: case QImage::Format_Mono:
0
184 case QImage::Format_MonoLSB:
never executed: case QImage::Format_MonoLSB:
0
185 case QImage::Format_Indexed8:
never executed: case QImage::Format_Indexed8:
0
186 has_alpha_pixels = has_alpha_clut;-
187 break;
never executed: break;
0
188 case QImage::Format_Alpha8:
never executed: case QImage::Format_Alpha8:
0
189 has_alpha_pixels = true;-
190 break;
never executed: break;
0
191 case QImage::Format_ARGB32:
never executed: case QImage::Format_ARGB32:
0
192 case QImage::Format_ARGB32_Premultiplied: {
never executed: case QImage::Format_ARGB32_Premultiplied:
0
193 uchar *bits = data;-
194 for (int y=0; y<height && !has_alpha_pixels; ++y) {
y<heightDescription
TRUEnever evaluated
FALSEnever evaluated
!has_alpha_pixelsDescription
TRUEnever evaluated
FALSEnever evaluated
0
195 for (int x=0; x<width; ++x)
x<widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
196 has_alpha_pixels |= (((uint *)bits)[x] & 0xff000000) != 0xff000000;
never executed: has_alpha_pixels |= (((uint *)bits)[x] & 0xff000000) != 0xff000000;
0
197 bits += bytes_per_line;-
198 }
never executed: end of block
0
199 } break;
never executed: break;
0
200-
201 case QImage::Format_RGBA8888:
never executed: case QImage::Format_RGBA8888:
0
202 case QImage::Format_RGBA8888_Premultiplied: {
never executed: case QImage::Format_RGBA8888_Premultiplied:
0
203 uchar *bits = data;-
204 for (int y=0; y<height && !has_alpha_pixels; ++y) {
y<heightDescription
TRUEnever evaluated
FALSEnever evaluated
!has_alpha_pixelsDescription
TRUEnever evaluated
FALSEnever evaluated
0
205 for (int x=0; x<width; ++x)
x<widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
206 has_alpha_pixels |= bits[x*4+3] != 0xff;
never executed: has_alpha_pixels |= bits[x*4+3] != 0xff;
0
207 bits += bytes_per_line;-
208 }
never executed: end of block
0
209 } break;
never executed: break;
0
210-
211 case QImage::Format_A2BGR30_Premultiplied:
never executed: case QImage::Format_A2BGR30_Premultiplied:
0
212 case QImage::Format_A2RGB30_Premultiplied: {
never executed: case QImage::Format_A2RGB30_Premultiplied:
0
213 uchar *bits = data;-
214 for (int y=0; y<height && !has_alpha_pixels; ++y) {
y<heightDescription
TRUEnever evaluated
FALSEnever evaluated
!has_alpha_pixelsDescription
TRUEnever evaluated
FALSEnever evaluated
0
215 for (int x=0; x<width; ++x)
x<widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
216 has_alpha_pixels |= (((uint *)bits)[x] & 0xc0000000) != 0xc0000000;
never executed: has_alpha_pixels |= (((uint *)bits)[x] & 0xc0000000) != 0xc0000000;
0
217 bits += bytes_per_line;-
218 }
never executed: end of block
0
219 } break;
never executed: break;
0
220-
221 case QImage::Format_ARGB8555_Premultiplied:
never executed: case QImage::Format_ARGB8555_Premultiplied:
0
222 case QImage::Format_ARGB8565_Premultiplied: {
never executed: case QImage::Format_ARGB8565_Premultiplied:
0
223 uchar *bits = data;-
224 uchar *end_bits = data + bytes_per_line;-
225-
226 for (int y=0; y<height && !has_alpha_pixels; ++y) {
y<heightDescription
TRUEnever evaluated
FALSEnever evaluated
!has_alpha_pixelsDescription
TRUEnever evaluated
FALSEnever evaluated
0
227 while (bits < end_bits) {
bits < end_bitsDescription
TRUEnever evaluated
FALSEnever evaluated
0
228 has_alpha_pixels |= bits[0] != 0;-
229 bits += 3;-
230 }
never executed: end of block
0
231 bits = end_bits;-
232 end_bits += bytes_per_line;-
233 }
never executed: end of block
0
234 } break;
never executed: break;
0
235-
236 case QImage::Format_ARGB6666_Premultiplied: {
never executed: case QImage::Format_ARGB6666_Premultiplied:
0
237 uchar *bits = data;-
238 uchar *end_bits = data + bytes_per_line;-
239-
240 for (int y=0; y<height && !has_alpha_pixels; ++y) {
y<heightDescription
TRUEnever evaluated
FALSEnever evaluated
!has_alpha_pixelsDescription
TRUEnever evaluated
FALSEnever evaluated
0
241 while (bits < end_bits) {
bits < end_bitsDescription
TRUEnever evaluated
FALSEnever evaluated
0
242 has_alpha_pixels |= (bits[0] & 0xfc) != 0;-
243 bits += 3;-
244 }
never executed: end of block
0
245 bits = end_bits;-
246 end_bits += bytes_per_line;-
247 }
never executed: end of block
0
248 } break;
never executed: break;
0
249-
250 case QImage::Format_ARGB4444_Premultiplied: {
never executed: case QImage::Format_ARGB4444_Premultiplied:
0
251 uchar *bits = data;-
252 uchar *end_bits = data + bytes_per_line;-
253-
254 for (int y=0; y<height && !has_alpha_pixels; ++y) {
y<heightDescription
TRUEnever evaluated
FALSEnever evaluated
!has_alpha_pixelsDescription
TRUEnever evaluated
FALSEnever evaluated
0
255 while (bits < end_bits) {
bits < end_bitsDescription
TRUEnever evaluated
FALSEnever evaluated
0
256 has_alpha_pixels |= (bits[0] & 0xf0) != 0;-
257 bits += 2;-
258 }
never executed: end of block
0
259 bits = end_bits;-
260 end_bits += bytes_per_line;-
261 }
never executed: end of block
0
262 } break;
never executed: break;
0
263-
264 case QImage::Format_RGB32:
never executed: case QImage::Format_RGB32:
0
265 case QImage::Format_RGB16:
never executed: case QImage::Format_RGB16:
0
266 case QImage::Format_RGB444:
never executed: case QImage::Format_RGB444:
0
267 case QImage::Format_RGB555:
never executed: case QImage::Format_RGB555:
0
268 case QImage::Format_RGB666:
never executed: case QImage::Format_RGB666:
0
269 case QImage::Format_RGB888:
never executed: case QImage::Format_RGB888:
0
270 case QImage::Format_RGBX8888:
never executed: case QImage::Format_RGBX8888:
0
271 case QImage::Format_BGR30:
never executed: case QImage::Format_BGR30:
0
272 case QImage::Format_RGB30:
never executed: case QImage::Format_RGB30:
0
273 case QImage::Format_Grayscale8:
never executed: case QImage::Format_Grayscale8:
0
274 break;
never executed: break;
0
275 case QImage::Format_Invalid:
never executed: case QImage::Format_Invalid:
0
276 case QImage::NImageFormats:
never executed: case QImage::NImageFormats:
0
277 Q_UNREACHABLE();-
278 break;
never executed: break;
0
279 }-
280-
281 return has_alpha_pixels;
never executed: return has_alpha_pixels;
0
282}-
283#if defined(_M_ARM)-
284#pragma optimize("", on)-
285#endif-
286-
287/*!-
288 \class QImage-
289-
290 \inmodule QtGui-
291 \ingroup painting-
292 \ingroup shared-
293-
294 \reentrant-
295-
296 \brief The QImage class provides a hardware-independent image-
297 representation that allows direct access to the pixel data, and-
298 can be used as a paint device.-
299-
300 Qt provides four classes for handling image data: QImage, QPixmap,-
301 QBitmap and QPicture. QImage is designed and optimized for I/O,-
302 and for direct pixel access and manipulation, while QPixmap is-
303 designed and optimized for showing images on screen. QBitmap is-
304 only a convenience class that inherits QPixmap, ensuring a-
305 depth of 1. Finally, the QPicture class is a paint device that-
306 records and replays QPainter commands.-
307-
308 Because QImage is a QPaintDevice subclass, QPainter can be used to-
309 draw directly onto images. When using QPainter on a QImage, the-
310 painting can be performed in another thread than the current GUI-
311 thread.-
312-
313 The QImage class supports several image formats described by the-
314 \l Format enum. These include monochrome, 8-bit, 32-bit and-
315 alpha-blended images which are available in all versions of Qt-
316 4.x.-
317-
318 QImage provides a collection of functions that can be used to-
319 obtain a variety of information about the image. There are also-
320 several functions that enables transformation of the image.-
321-
322 QImage objects can be passed around by value since the QImage-
323 class uses \l{Implicit Data Sharing}{implicit data-
324 sharing}. QImage objects can also be streamed and compared.-
325-
326 \note If you would like to load QImage objects in a static build of Qt,-
327 refer to the \l{How to Create Qt Plugins}{Plugin HowTo}.-
328-
329 \warning Painting on a QImage with the format-
330 QImage::Format_Indexed8 is not supported.-
331-
332 \tableofcontents-
333-
334 \section1 Reading and Writing Image Files-
335-
336 QImage provides several ways of loading an image file: The file-
337 can be loaded when constructing the QImage object, or by using the-
338 load() or loadFromData() functions later on. QImage also provides-
339 the static fromData() function, constructing a QImage from the-
340 given data. When loading an image, the file name can either refer-
341 to an actual file on disk or to one of the application's embedded-
342 resources. See \l{The Qt Resource System} overview for details-
343 on how to embed images and other resource files in the-
344 application's executable.-
345-
346 Simply call the save() function to save a QImage object.-
347-
348 The complete list of supported file formats are available through-
349 the QImageReader::supportedImageFormats() and-
350 QImageWriter::supportedImageFormats() functions. New file formats-
351 can be added as plugins. By default, Qt supports the following-
352 formats:-
353-
354 \table-
355 \header \li Format \li Description \li Qt's support-
356 \row \li BMP \li Windows Bitmap \li Read/write-
357 \row \li GIF \li Graphic Interchange Format (optional) \li Read-
358 \row \li JPG \li Joint Photographic Experts Group \li Read/write-
359 \row \li JPEG \li Joint Photographic Experts Group \li Read/write-
360 \row \li PNG \li Portable Network Graphics \li Read/write-
361 \row \li PBM \li Portable Bitmap \li Read-
362 \row \li PGM \li Portable Graymap \li Read-
363 \row \li PPM \li Portable Pixmap \li Read/write-
364 \row \li XBM \li X11 Bitmap \li Read/write-
365 \row \li XPM \li X11 Pixmap \li Read/write-
366 \endtable-
367-
368 \section1 Image Information-
369-
370 QImage provides a collection of functions that can be used to-
371 obtain a variety of information about the image:-
372-
373 \table-
374 \header-
375 \li \li Available Functions-
376-
377 \row-
378 \li Geometry-
379 \li-
380-
381 The size(), width(), height(), dotsPerMeterX(), and-
382 dotsPerMeterY() functions provide information about the image size-
383 and aspect ratio.-
384-
385 The rect() function returns the image's enclosing rectangle. The-
386 valid() function tells if a given pair of coordinates is within-
387 this rectangle. The offset() function returns the number of pixels-
388 by which the image is intended to be offset by when positioned-
389 relative to other images, which also can be manipulated using the-
390 setOffset() function.-
391-
392 \row-
393 \li Colors-
394 \li-
395-
396 The color of a pixel can be retrieved by passing its coordinates-
397 to the pixel() function. The pixel() function returns the color-
398 as a QRgb value indepedent of the image's format.-
399-
400 In case of monochrome and 8-bit images, the colorCount() and-
401 colorTable() functions provide information about the color-
402 components used to store the image data: The colorTable() function-
403 returns the image's entire color table. To obtain a single entry,-
404 use the pixelIndex() function to retrieve the pixel index for a-
405 given pair of coordinates, then use the color() function to-
406 retrieve the color. Note that if you create an 8-bit image-
407 manually, you have to set a valid color table on the image as-
408 well.-
409-
410 The hasAlphaChannel() function tells if the image's format-
411 respects the alpha channel, or not. The allGray() and-
412 isGrayscale() functions tell whether an image's colors are all-
413 shades of gray.-
414-
415 See also the \l {QImage#Pixel Manipulation}{Pixel Manipulation}-
416 and \l {QImage#Image Transformations}{Image Transformations}-
417 sections.-
418-
419 \row-
420 \li Text-
421 \li-
422-
423 The text() function returns the image text associated with the-
424 given text key. An image's text keys can be retrieved using the-
425 textKeys() function. Use the setText() function to alter an-
426 image's text.-
427-
428 \row-
429 \li Low-level information-
430 \li-
431-
432 The depth() function returns the depth of the image. The supported-
433 depths are 1 (monochrome), 8, 16, 24 and 32 bits. The-
434 bitPlaneCount() function tells how many of those bits that are-
435 used. For more information see the-
436 \l {QImage#Image Formats}{Image Formats} section.-
437-
438 The format(), bytesPerLine(), and byteCount() functions provide-
439 low-level information about the data stored in the image.-
440-
441 The cacheKey() function returns a number that uniquely-
442 identifies the contents of this QImage object.-
443 \endtable-
444-
445 \section1 Pixel Manipulation-
446-
447 The functions used to manipulate an image's pixels depend on the-
448 image format. The reason is that monochrome and 8-bit images are-
449 index-based and use a color lookup table, while 32-bit images-
450 store ARGB values directly. For more information on image formats,-
451 see the \l {Image Formats} section.-
452-
453 In case of a 32-bit image, the setPixel() function can be used to-
454 alter the color of the pixel at the given coordinates to any other-
455 color specified as an ARGB quadruplet. To make a suitable QRgb-
456 value, use the qRgb() (adding a default alpha component to the-
457 given RGB values, i.e. creating an opaque color) or qRgba()-
458 function. For example:-
459-
460 \table-
461 \header-
462 \li {2,1}32-bit-
463 \row-
464 \li \inlineimage qimage-32bit_scaled.png-
465 \li-
466 \snippet code/src_gui_image_qimage.cpp 0-
467 \endtable-
468-
469 In case of a 8-bit and monchrome images, the pixel value is only-
470 an index from the image's color table. So the setPixel() function-
471 can only be used to alter the color of the pixel at the given-
472 coordinates to a predefined color from the image's color table,-
473 i.e. it can only change the pixel's index value. To alter or add a-
474 color to an image's color table, use the setColor() function.-
475-
476 An entry in the color table is an ARGB quadruplet encoded as an-
477 QRgb value. Use the qRgb() and qRgba() functions to make a-
478 suitable QRgb value for use with the setColor() function. For-
479 example:-
480-
481 \table-
482 \header-
483 \li {2,1} 8-bit-
484 \row-
485 \li \inlineimage qimage-8bit_scaled.png-
486 \li-
487 \snippet code/src_gui_image_qimage.cpp 1-
488 \endtable-
489-
490 For images with more than 8-bit per color-channel. The methods-
491 setPixelColor() and pixelColor() can be used to set and get-
492 with QColor values.-
493-
494 QImage also provide the scanLine() function which returns a-
495 pointer to the pixel data at the scanline with the given index,-
496 and the bits() function which returns a pointer to the first pixel-
497 data (this is equivalent to \c scanLine(0)).-
498-
499 \section1 Image Formats-
500-
501 Each pixel stored in a QImage is represented by an integer. The-
502 size of the integer varies depending on the format. QImage-
503 supports several image formats described by the \l Format-
504 enum.-
505-
506 Monochrome images are stored using 1-bit indexes into a color table-
507 with at most two colors. There are two different types of-
508 monochrome images: big endian (MSB first) or little endian (LSB-
509 first) bit order.-
510-
511 8-bit images are stored using 8-bit indexes into a color table,-
512 i.e. they have a single byte per pixel. The color table is a-
513 QVector<QRgb>, and the QRgb typedef is equivalent to an unsigned-
514 int containing an ARGB quadruplet on the format 0xAARRGGBB.-
515-
516 32-bit images have no color table; instead, each pixel contains an-
517 QRgb value. There are three different types of 32-bit images-
518 storing RGB (i.e. 0xffRRGGBB), ARGB and premultiplied ARGB-
519 values respectively. In the premultiplied format the red, green,-
520 and blue channels are multiplied by the alpha component divided by-
521 255.-
522-
523 An image's format can be retrieved using the format()-
524 function. Use the convertToFormat() functions to convert an image-
525 into another format. The allGray() and isGrayscale() functions-
526 tell whether a color image can safely be converted to a grayscale-
527 image.-
528-
529 \section1 Image Transformations-
530-
531 QImage supports a number of functions for creating a new image-
532 that is a transformed version of the original: The-
533 createAlphaMask() function builds and returns a 1-bpp mask from-
534 the alpha buffer in this image, and the createHeuristicMask()-
535 function creates and returns a 1-bpp heuristic mask for this-
536 image. The latter function works by selecting a color from one of-
537 the corners, then chipping away pixels of that color starting at-
538 all the edges.-
539-
540 The mirrored() function returns a mirror of the image in the-
541 desired direction, the scaled() returns a copy of the image scaled-
542 to a rectangle of the desired measures, and the rgbSwapped() function-
543 constructs a BGR image from a RGB image.-
544-
545 The scaledToWidth() and scaledToHeight() functions return scaled-
546 copies of the image.-
547-
548 The transformed() function returns a copy of the image that is-
549 transformed with the given transformation matrix and-
550 transformation mode: Internally, the transformation matrix is-
551 adjusted to compensate for unwanted translation,-
552 i.e. transformed() returns the smallest image containing all-
553 transformed points of the original image. The static trueMatrix()-
554 function returns the actual matrix used for transforming the-
555 image.-
556-
557 There are also functions for changing attributes of an image-
558 in-place:-
559-
560 \table-
561 \header \li Function \li Description-
562 \row-
563 \li setDotsPerMeterX()-
564 \li Defines the aspect ratio by setting the number of pixels that fit-
565 horizontally in a physical meter.-
566 \row-
567 \li setDotsPerMeterY()-
568 \li Defines the aspect ratio by setting the number of pixels that fit-
569 vertically in a physical meter.-
570 \row-
571 \li fill()-
572 \li Fills the entire image with the given pixel value.-
573 \row-
574 \li invertPixels()-
575 \li Inverts all pixel values in the image using the given InvertMode value.-
576 \row-
577 \li setColorTable()-
578 \li Sets the color table used to translate color indexes. Only-
579 monochrome and 8-bit formats.-
580 \row-
581 \li setColorCount()-
582 \li Resizes the color table. Only monochrome and 8-bit formats.-
583-
584 \endtable-
585-
586 \target qimage-legalese-
587 \section1 Legal Information-
588-
589 For smooth scaling, the transformed() functions use code based on-
590 smooth scaling algorithm by Daniel M. Duley.-
591-
592 \badcode-
593 Copyright (C) 2004, 2005 Daniel M. Duley-
594-
595 Redistribution and use in source and binary forms, with or without-
596 modification, are permitted provided that the following conditions-
597 are met:-
598-
599 1. Redistributions of source code must retain the above copyright-
600 notice, this list of conditions and the following disclaimer.-
601 2. Redistributions in binary form must reproduce the above copyright-
602 notice, this list of conditions and the following disclaimer in the-
603 documentation and/or other materials provided with the distribution.-
604-
605 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR-
606 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES-
607 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.-
608 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,-
609 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT-
610 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,-
611 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY-
612 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-
613 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF-
614 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.-
615 \endcode-
616-
617 \sa QImageReader, QImageWriter, QPixmap, QSvgRenderer, {Image Composition Example},-
618 {Image Viewer Example}, {Scribble Example}, {Pixelator Example}-
619*/-
620-
621/*!-
622 \fn QImage::QImage(QImage &&other)-
623-
624 Move-constructs a QImage instance, making it point at the same-
625 object that \a other was pointing to.-
626-
627 \since 5.2-
628*/-
629-
630/*!-
631 \fn QImage &QImage::operator=(QImage &&other)-
632-
633 Move-assigns \a other to this QImage instance.-
634-
635 \since 5.2-
636*/-
637-
638/*!-
639 \typedef QImageCleanupFunction-
640 \relates QImage-
641 \since 5.0-
642-
643 A function with the following signature that can be used to-
644 implement basic image memory management:-
645-
646 \code-
647 void myImageCleanupHandler(void *info);-
648 \endcode-
649*/-
650-
651/*!-
652 \enum QImage::InvertMode-
653-
654 This enum type is used to describe how pixel values should be-
655 inverted in the invertPixels() function.-
656-
657 \value InvertRgb Invert only the RGB values and leave the alpha-
658 channel unchanged.-
659-
660 \value InvertRgba Invert all channels, including the alpha channel.-
661-
662 \sa invertPixels()-
663*/-
664-
665/*!-
666 \enum QImage::Format-
667-
668 The following image formats are available in Qt. Values from Format_ARGB8565_Premultiplied-
669 to Format_ARGB4444_Premultiplied were added in Qt 4.4. Values Format_RGBX8888, Format_RGBA8888-
670 and Format_RGBA8888_Premultiplied were added in Qt 5.2. Values Format_BGR30, Format_A2BGR30_Premultiplied,-
671 Format_RGB30, Format_A2RGB30_Premultiplied were added in Qt 5.4. Format_Alpha8 and Format_Grayscale8-
672 were added in Qt 5.5.-
673 See the notes after the table.-
674-
675 \value Format_Invalid The image is invalid.-
676 \value Format_Mono The image is stored using 1-bit per pixel. Bytes are-
677 packed with the most significant bit (MSB) first.-
678 \value Format_MonoLSB The image is stored using 1-bit per pixel. Bytes are-
679 packed with the less significant bit (LSB) first.-
680-
681 \value Format_Indexed8 The image is stored using 8-bit indexes-
682 into a colormap.-
683-
684 \value Format_RGB32 The image is stored using a 32-bit RGB format (0xffRRGGBB).-
685-
686 \value Format_ARGB32 The image is stored using a 32-bit ARGB-
687 format (0xAARRGGBB).-
688-
689 \value Format_ARGB32_Premultiplied The image is stored using a premultiplied 32-bit-
690 ARGB format (0xAARRGGBB), i.e. the red,-
691 green, and blue channels are multiplied-
692 by the alpha component divided by 255. (If RR, GG, or BB-
693 has a higher value than the alpha channel, the results are-
694 undefined.) Certain operations (such as image composition-
695 using alpha blending) are faster using premultiplied ARGB32-
696 than with plain ARGB32.-
697-
698 \value Format_RGB16 The image is stored using a 16-bit RGB format (5-6-5).-
699-
700 \value Format_ARGB8565_Premultiplied The image is stored using a-
701 premultiplied 24-bit ARGB format (8-5-6-5).-
702 \value Format_RGB666 The image is stored using a 24-bit RGB format (6-6-6).-
703 The unused most significant bits is always zero.-
704 \value Format_ARGB6666_Premultiplied The image is stored using a-
705 premultiplied 24-bit ARGB format (6-6-6-6).-
706 \value Format_RGB555 The image is stored using a 16-bit RGB format (5-5-5).-
707 The unused most significant bit is always zero.-
708 \value Format_ARGB8555_Premultiplied The image is stored using a-
709 premultiplied 24-bit ARGB format (8-5-5-5).-
710 \value Format_RGB888 The image is stored using a 24-bit RGB format (8-8-8).-
711 \value Format_RGB444 The image is stored using a 16-bit RGB format (4-4-4).-
712 The unused bits are always zero.-
713 \value Format_ARGB4444_Premultiplied The image is stored using a-
714 premultiplied 16-bit ARGB format (4-4-4-4).-
715 \value Format_RGBX8888 The image is stored using a 32-bit byte-ordered RGB(x) format (8-8-8-8).-
716 This is the same as the Format_RGBA8888 except alpha must always be 255.-
717 \value Format_RGBA8888 The image is stored using a 32-bit byte-ordered RGBA format (8-8-8-8).-
718 Unlike ARGB32 this is a byte-ordered format, which means the 32bit-
719 encoding differs between big endian and little endian architectures,-
720 being respectively (0xRRGGBBAA) and (0xAABBGGRR). The order of the colors-
721 is the same on any architecture if read as bytes 0xRR,0xGG,0xBB,0xAA.-
722 \value Format_RGBA8888_Premultiplied The image is stored using a-
723 premultiplied 32-bit byte-ordered RGBA format (8-8-8-8).-
724 \value Format_BGR30 The image is stored using a 32-bit BGR format (x-10-10-10).-
725 \value Format_A2BGR30_Premultiplied The image is stored using a 32-bit premultiplied ABGR format (2-10-10-10).-
726 \value Format_RGB30 The image is stored using a 32-bit RGB format (x-10-10-10).-
727 \value Format_A2RGB30_Premultiplied The image is stored using a 32-bit premultiplied ARGB format (2-10-10-10).-
728 \value Format_Alpha8 The image is stored using an 8-bit alpha only format.-
729 \value Format_Grayscale8 The image is stored using an 8-bit grayscale format.-
730-
731 \note Drawing into a QImage with QImage::Format_Indexed8 is not-
732 supported.-
733-
734 \note Do not render into ARGB32 images using QPainter. Using-
735 QImage::Format_ARGB32_Premultiplied is significantly faster.-
736-
737 \note Formats with more than 8 bit per color channel will only be processed by the raster engine using 8 bit-
738 per color.-
739-
740 \sa format(), convertToFormat()-
741*/-
742-
743/*****************************************************************************-
744 QImage member functions-
745 *****************************************************************************/-
746-
747/*!-
748 Constructs a null image.-
749-
750 \sa isNull()-
751*/-
752-
753QImage::QImage() Q_DECL_NOEXCEPT-
754 : QPaintDevice()-
755{-
756 d = 0;-
757}
never executed: end of block
0
758-
759/*!-
760 Constructs an image with the given \a width, \a height and \a-
761 format.-
762-
763 A \l{isNull()}{null} image will be returned if memory cannot be allocated.-
764-
765 \warning This will create a QImage with uninitialized data. Call-
766 fill() to fill the image with an appropriate pixel value before-
767 drawing onto it with QPainter.-
768*/-
769QImage::QImage(int width, int height, Format format)-
770 : QPaintDevice()-
771{-
772 d = QImageData::create(QSize(width, height), format);-
773}
never executed: end of block
0
774-
775/*!-
776 Constructs an image with the given \a size and \a format.-
777-
778 A \l{isNull()}{null} image is returned if memory cannot be allocated.-
779-
780 \warning This will create a QImage with uninitialized data. Call-
781 fill() to fill the image with an appropriate pixel value before-
782 drawing onto it with QPainter.-
783*/-
784QImage::QImage(const QSize &size, Format format)-
785 : QPaintDevice()-
786{-
787 d = QImageData::create(size, format);-
788}
never executed: end of block
0
789-
790-
791-
792QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QImage::Format format, bool readOnly, QImageCleanupFunction cleanupFunction, void *cleanupInfo)-
793{-
794 QImageData *d = 0;-
795-
796 if (format == QImage::Format_Invalid)
format == QIma...Format_InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
0
797 return d;
never executed: return d;
0
798-
799 const int depth = qt_depthForFormat(format);-
800 const int calc_bytes_per_line = ((width * depth + 31)/32) * 4;-
801 const int min_bytes_per_line = (width * depth + 7)/8;-
802-
803 if (bpl <= 0)
bpl <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
804 bpl = calc_bytes_per_line;
never executed: bpl = calc_bytes_per_line;
0
805-
806 if (width <= 0 || height <= 0 || !data
width <= 0Description
TRUEnever evaluated
FALSEnever evaluated
height <= 0Description
TRUEnever evaluated
FALSEnever evaluated
!dataDescription
TRUEnever evaluated
FALSEnever evaluated
0
807 || INT_MAX/sizeof(uchar *) < uint(height)
2147483647/siz...< uint(height)Description
TRUEnever evaluated
FALSEnever evaluated
0
808 || INT_MAX/uint(depth) < uint(width)
2147483647/uin... < uint(width)Description
TRUEnever evaluated
FALSEnever evaluated
0
809 || bpl <= 0
bpl <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
810 || bpl < min_bytes_per_line
bpl < min_bytes_per_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
811 || INT_MAX/uint(bpl) < uint(height))
2147483647/uin...< uint(height)Description
TRUEnever evaluated
FALSEnever evaluated
0
812 return d; // invalid parameter(s)
never executed: return d;
0
813-
814 d = new QImageData;-
815 d->ref.ref();-
816-
817 d->own_data = false;-
818 d->ro_data = readOnly;-
819 d->data = data;-
820 d->width = width;-
821 d->height = height;-
822 d->depth = depth;-
823 d->format = format;-
824-
825 d->bytes_per_line = bpl;-
826 d->nbytes = d->bytes_per_line * height;-
827-
828 d->cleanupFunction = cleanupFunction;-
829 d->cleanupInfo = cleanupInfo;-
830-
831 return d;
never executed: return d;
0
832}-
833-
834/*!-
835 Constructs an image with the given \a width, \a height and \a-
836 format, that uses an existing memory buffer, \a data. The \a width-
837 and \a height must be specified in pixels, \a data must be 32-bit aligned,-
838 and each scanline of data in the image must also be 32-bit aligned.-
839-
840 The buffer must remain valid throughout the life of the QImage and-
841 all copies that have not been modified or otherwise detached from-
842 the original buffer. The image does not delete the buffer at destruction.-
843 You can provide a function pointer \a cleanupFunction along with an-
844 extra pointer \a cleanupInfo that will be called when the last copy-
845 is destroyed.-
846-
847 If \a format is an indexed color format, the image color table is-
848 initially empty and must be sufficiently expanded with-
849 setColorCount() or setColorTable() before the image is used.-
850*/-
851QImage::QImage(uchar* data, int width, int height, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo)-
852 : QPaintDevice()-
853{-
854 d = QImageData::create(data, width, height, 0, format, false, cleanupFunction, cleanupInfo);-
855}
never executed: end of block
0
856-
857/*!-
858 Constructs an image with the given \a width, \a height and \a-
859 format, that uses an existing read-only memory buffer, \a-
860 data. The \a width and \a height must be specified in pixels, \a-
861 data must be 32-bit aligned, and each scanline of data in the-
862 image must also be 32-bit aligned.-
863-
864 The buffer must remain valid throughout the life of the QImage and-
865 all copies that have not been modified or otherwise detached from-
866 the original buffer. The image does not delete the buffer at destruction.-
867 You can provide a function pointer \a cleanupFunction along with an-
868 extra pointer \a cleanupInfo that will be called when the last copy-
869 is destroyed.-
870-
871 If \a format is an indexed color format, the image color table is-
872 initially empty and must be sufficiently expanded with-
873 setColorCount() or setColorTable() before the image is used.-
874-
875 Unlike the similar QImage constructor that takes a non-const data buffer,-
876 this version will never alter the contents of the buffer. For example,-
877 calling QImage::bits() will return a deep copy of the image, rather than-
878 the buffer passed to the constructor. This allows for the efficiency of-
879 constructing a QImage from raw data, without the possibility of the raw-
880 data being changed.-
881*/-
882QImage::QImage(const uchar* data, int width, int height, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo)-
883 : QPaintDevice()-
884{-
885 d = QImageData::create(const_cast<uchar*>(data), width, height, 0, format, true, cleanupFunction, cleanupInfo);-
886}
never executed: end of block
0
887-
888/*!-
889 Constructs an image with the given \a width, \a height and \a-
890 format, that uses an existing memory buffer, \a data. The \a width-
891 and \a height must be specified in pixels. \a bytesPerLine-
892 specifies the number of bytes per line (stride).-
893-
894 The buffer must remain valid throughout the life of the QImage and-
895 all copies that have not been modified or otherwise detached from-
896 the original buffer. The image does not delete the buffer at destruction.-
897 You can provide a function pointer \a cleanupFunction along with an-
898 extra pointer \a cleanupInfo that will be called when the last copy-
899 is destroyed.-
900-
901 If \a format is an indexed color format, the image color table is-
902 initially empty and must be sufficiently expanded with-
903 setColorCount() or setColorTable() before the image is used.-
904*/-
905QImage::QImage(uchar *data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo)-
906 :QPaintDevice()-
907{-
908 d = QImageData::create(data, width, height, bytesPerLine, format, false, cleanupFunction, cleanupInfo);-
909}
never executed: end of block
0
910-
911-
912/*!-
913 Constructs an image with the given \a width, \a height and \a-
914 format, that uses an existing memory buffer, \a data. The \a width-
915 and \a height must be specified in pixels. \a bytesPerLine-
916 specifies the number of bytes per line (stride).-
917-
918 The buffer must remain valid throughout the life of the QImage and-
919 all copies that have not been modified or otherwise detached from-
920 the original buffer. The image does not delete the buffer at destruction.-
921 You can provide a function pointer \a cleanupFunction along with an-
922 extra pointer \a cleanupInfo that will be called when the last copy-
923 is destroyed.-
924-
925 If \a format is an indexed color format, the image color table is-
926 initially empty and must be sufficiently expanded with-
927 setColorCount() or setColorTable() before the image is used.-
928-
929 Unlike the similar QImage constructor that takes a non-const data buffer,-
930 this version will never alter the contents of the buffer. For example,-
931 calling QImage::bits() will return a deep copy of the image, rather than-
932 the buffer passed to the constructor. This allows for the efficiency of-
933 constructing a QImage from raw data, without the possibility of the raw-
934 data being changed.-
935*/-
936-
937QImage::QImage(const uchar *data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo)-
938 :QPaintDevice()-
939{-
940 d = QImageData::create(const_cast<uchar*>(data), width, height, bytesPerLine, format, true, cleanupFunction, cleanupInfo);-
941}
never executed: end of block
0
942-
943/*!-
944 Constructs an image and tries to load the image from the file with-
945 the given \a fileName.-
946-
947 The loader attempts to read the image using the specified \a-
948 format. If the \a format is not specified (which is the default),-
949 the loader probes the file for a header to guess the file format.-
950-
951 If the loading of the image failed, this object is a null image.-
952-
953 The file name can either refer to an actual file on disk or to one-
954 of the application's embedded resources. See the-
955 \l{resources.html}{Resource System} overview for details on how to-
956 embed images and other resource files in the application's-
957 executable.-
958-
959 \sa isNull(), {QImage#Reading and Writing Image Files}{Reading and Writing Image Files}-
960*/-
961-
962QImage::QImage(const QString &fileName, const char *format)-
963 : QPaintDevice()-
964{-
965 d = 0;-
966 load(fileName, format);-
967}
never executed: end of block
0
968-
969#ifndef QT_NO_IMAGEFORMAT_XPM-
970extern bool qt_read_xpm_image_or_array(QIODevice *device, const char * const *source, QImage &image);-
971-
972/*!-
973 Constructs an image from the given \a xpm image.-
974-
975 Make sure that the image is a valid XPM image. Errors are silently-
976 ignored.-
977-
978 Note that it's possible to squeeze the XPM variable a little bit-
979 by using an unusual declaration:-
980-
981 \snippet code/src_gui_image_qimage.cpp 2-
982-
983 The extra \c const makes the entire definition read-only, which is-
984 slightly more efficient (e.g., when the code is in a shared-
985 library) and able to be stored in ROM with the application.-
986*/-
987-
988QImage::QImage(const char * const xpm[])-
989 : QPaintDevice()-
990{-
991 d = 0;-
992 if (!xpm)
!xpmDescription
TRUEnever evaluated
FALSEnever evaluated
0
993 return;
never executed: return;
0
994 if (!qt_read_xpm_image_or_array(0, xpm, *this))
!qt_read_xpm_i...0, xpm, *this)Description
TRUEnever evaluated
FALSEnever evaluated
0
995 // Issue: Warning because the constructor may be ambigious-
996 qWarning("QImage::QImage(), XPM is not supported");
never executed: QMessageLogger(__FILE__, 996, __PRETTY_FUNCTION__).warning("QImage::QImage(), XPM is not supported");
0
997}
never executed: end of block
0
998#endif // QT_NO_IMAGEFORMAT_XPM-
999-
1000/*!-
1001 Constructs a shallow copy of the given \a image.-
1002-
1003 For more information about shallow copies, see the \l {Implicit-
1004 Data Sharing} documentation.-
1005-
1006 \sa copy()-
1007*/-
1008-
1009QImage::QImage(const QImage &image)-
1010 : QPaintDevice()-
1011{-
1012 if (image.paintingActive() || isLocked(image.d)) {
image.paintingActive()Description
TRUEnever evaluated
FALSEnever evaluated
isLocked(image.d)Description
TRUEnever evaluated
FALSEnever evaluated
0
1013 d = 0;-
1014 image.copy().swap(*this);-
1015 } else {
never executed: end of block
0
1016 d = image.d;-
1017 if (d)
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1018 d->ref.ref();
never executed: d->ref.ref();
0
1019 }
never executed: end of block
0
1020}-
1021-
1022/*!-
1023 Destroys the image and cleans up.-
1024*/-
1025-
1026QImage::~QImage()-
1027{-
1028 if (d && !d->ref.deref())
dDescription
TRUEnever evaluated
FALSEnever evaluated
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
1029 delete d;
never executed: delete d;
0
1030}
never executed: end of block
0
1031-
1032/*!-
1033 Assigns a shallow copy of the given \a image to this image and-
1034 returns a reference to this image.-
1035-
1036 For more information about shallow copies, see the \l {Implicit-
1037 Data Sharing} documentation.-
1038-
1039 \sa copy(), QImage()-
1040*/-
1041-
1042QImage &QImage::operator=(const QImage &image)-
1043{-
1044 if (image.paintingActive() || isLocked(image.d)) {
image.paintingActive()Description
TRUEnever evaluated
FALSEnever evaluated
isLocked(image.d)Description
TRUEnever evaluated
FALSEnever evaluated
0
1045 operator=(image.copy());-
1046 } else {
never executed: end of block
0
1047 if (image.d)
image.dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1048 image.d->ref.ref();
never executed: image.d->ref.ref();
0
1049 if (d && !d->ref.deref())
dDescription
TRUEnever evaluated
FALSEnever evaluated
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
1050 delete d;
never executed: delete d;
0
1051 d = image.d;-
1052 }
never executed: end of block
0
1053 return *this;
never executed: return *this;
0
1054}-
1055-
1056/*!-
1057 \fn void QImage::swap(QImage &other)-
1058 \since 4.8-
1059-
1060 Swaps image \a other with this image. This operation is very-
1061 fast and never fails.-
1062*/-
1063-
1064/*!-
1065 \internal-
1066*/-
1067int QImage::devType() const-
1068{-
1069 return QInternal::Image;
never executed: return QInternal::Image;
0
1070}-
1071-
1072/*!-
1073 Returns the image as a QVariant.-
1074*/-
1075QImage::operator QVariant() const-
1076{-
1077 return QVariant(QVariant::Image, this);
never executed: return QVariant(QVariant::Image, this);
0
1078}-
1079-
1080/*!-
1081 \internal-
1082-
1083 If multiple images share common data, this image makes a copy of-
1084 the data and detaches itself from the sharing mechanism, making-
1085 sure that this image is the only one referring to the data.-
1086-
1087 Nothing is done if there is just a single reference.-
1088-
1089 \sa copy(), isDetached(), {Implicit Data Sharing}-
1090*/-
1091void QImage::detach()-
1092{-
1093 if (d) {
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1094 if (d->is_cached && d->ref.load() == 1)
d->is_cachedDescription
TRUEnever evaluated
FALSEnever evaluated
d->ref.load() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1095 QImagePixmapCleanupHooks::executeImageHooks(cacheKey());
never executed: QImagePixmapCleanupHooks::executeImageHooks(cacheKey());
0
1096-
1097 if (d->ref.load() != 1 || d->ro_data)
d->ref.load() != 1Description
TRUEnever evaluated
FALSEnever evaluated
d->ro_dataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1098 *this = copy();
never executed: *this = copy();
0
1099-
1100 if (d)
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1101 ++d->detach_no;
never executed: ++d->detach_no;
0
1102 }
never executed: end of block
0
1103}
never executed: end of block
0
1104-
1105-
1106static void copyMetadata(QImageData *dst, const QImageData *src)-
1107{-
1108 // Doesn't copy colortable and alpha_clut, or offset.-
1109 dst->dpmx = src->dpmx;-
1110 dst->dpmy = src->dpmy;-
1111 dst->devicePixelRatio = src->devicePixelRatio;-
1112 dst->text = src->text;-
1113}
never executed: end of block
0
1114-
1115/*!-
1116 \fn QImage QImage::copy(int x, int y, int width, int height) const-
1117 \overload-
1118-
1119 The returned image is copied from the position (\a x, \a y) in-
1120 this image, and will always have the given \a width and \a height.-
1121 In areas beyond this image, pixels are set to 0.-
1122-
1123*/-
1124-
1125/*!-
1126 \fn QImage QImage::copy(const QRect& rectangle) const-
1127-
1128 Returns a sub-area of the image as a new image.-
1129-
1130 The returned image is copied from the position (\a-
1131 {rectangle}.x(), \a{rectangle}.y()) in this image, and will always-
1132 have the size of the given \a rectangle.-
1133-
1134 In areas beyond this image, pixels are set to 0. For 32-bit RGB-
1135 images, this means black; for 32-bit ARGB images, this means-
1136 transparent black; for 8-bit images, this means the color with-
1137 index 0 in the color table which can be anything; for 1-bit-
1138 images, this means Qt::color0.-
1139-
1140 If the given \a rectangle is a null rectangle the entire image is-
1141 copied.-
1142-
1143 \sa QImage()-
1144*/-
1145QImage QImage::copy(const QRect& r) const-
1146{-
1147 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1148 return QImage();
never executed: return QImage();
0
1149-
1150 if (r.isNull()) {
r.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1151 QImage image(d->width, d->height, d->format);-
1152 if (image.isNull())
image.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1153 return image;
never executed: return image;
0
1154-
1155 // Qt for Embedded Linux can create images with non-default bpl-
1156 // make sure we don't crash.-
1157 if (image.d->nbytes != d->nbytes) {
image.d->nbytes != d->nbytesDescription
TRUEnever evaluated
FALSEnever evaluated
0
1158 int bpl = qMin(bytesPerLine(), image.bytesPerLine());-
1159 for (int i = 0; i < height(); i++)
i < height()Description
TRUEnever evaluated
FALSEnever evaluated
0
1160 memcpy(image.scanLine(i), scanLine(i), bpl);
never executed: memcpy(image.scanLine(i), scanLine(i), bpl);
0
1161 } else
never executed: end of block
0
1162 memcpy(image.bits(), bits(), d->nbytes);
never executed: memcpy(image.bits(), bits(), d->nbytes);
0
1163 image.d->colortable = d->colortable;-
1164 image.d->offset = d->offset;-
1165 image.d->has_alpha_clut = d->has_alpha_clut;-
1166 copyMetadata(image.d, d);-
1167 return image;
never executed: return image;
0
1168 }-
1169-
1170 int x = r.x();-
1171 int y = r.y();-
1172 int w = r.width();-
1173 int h = r.height();-
1174-
1175 int dx = 0;-
1176 int dy = 0;-
1177 if (w <= 0 || h <= 0)
w <= 0Description
TRUEnever evaluated
FALSEnever evaluated
h <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1178 return QImage();
never executed: return QImage();
0
1179-
1180 QImage image(w, h, d->format);-
1181 if (image.isNull())
image.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1182 return image;
never executed: return image;
0
1183-
1184 if (x < 0 || y < 0 || x + w > d->width || y + h > d->height) {
x < 0Description
TRUEnever evaluated
FALSEnever evaluated
y < 0Description
TRUEnever evaluated
FALSEnever evaluated
x + w > d->widthDescription
TRUEnever evaluated
FALSEnever evaluated
y + h > d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
1185 // bitBlt will not cover entire image - clear it.-
1186 image.fill(0);-
1187 if (x < 0) {
x < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1188 dx = -x;-
1189 x = 0;-
1190 }
never executed: end of block
0
1191 if (y < 0) {
y < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1192 dy = -y;-
1193 y = 0;-
1194 }
never executed: end of block
0
1195 }
never executed: end of block
0
1196-
1197 image.d->colortable = d->colortable;-
1198-
1199 int pixels_to_copy = qMax(w - dx, 0);-
1200 if (x > d->width)
x > d->widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1201 pixels_to_copy = 0;
never executed: pixels_to_copy = 0;
0
1202 else if (pixels_to_copy > d->width - x)
pixels_to_copy > d->width - xDescription
TRUEnever evaluated
FALSEnever evaluated
0
1203 pixels_to_copy = d->width - x;
never executed: pixels_to_copy = d->width - x;
0
1204 int lines_to_copy = qMax(h - dy, 0);-
1205 if (y > d->height)
y > d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
1206 lines_to_copy = 0;
never executed: lines_to_copy = 0;
0
1207 else if (lines_to_copy > d->height - y)
lines_to_copy > d->height - yDescription
TRUEnever evaluated
FALSEnever evaluated
0
1208 lines_to_copy = d->height - y;
never executed: lines_to_copy = d->height - y;
0
1209-
1210 bool byteAligned = true;-
1211 if (d->format == Format_Mono || d->format == Format_MonoLSB)
d->format == Format_MonoDescription
TRUEnever evaluated
FALSEnever evaluated
d->format == Format_MonoLSBDescription
TRUEnever evaluated
FALSEnever evaluated
0
1212 byteAligned = !(dx & 7) && !(x & 7) && !(pixels_to_copy & 7);
never executed: byteAligned = !(dx & 7) && !(x & 7) && !(pixels_to_copy & 7);
!(dx & 7)Description
TRUEnever evaluated
FALSEnever evaluated
!(x & 7)Description
TRUEnever evaluated
FALSEnever evaluated
!(pixels_to_copy & 7)Description
TRUEnever evaluated
FALSEnever evaluated
0
1213-
1214 if (byteAligned) {
byteAlignedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1215 const uchar *src = d->data + ((x * d->depth) >> 3) + y * d->bytes_per_line;-
1216 uchar *dest = image.d->data + ((dx * d->depth) >> 3) + dy * image.d->bytes_per_line;-
1217 const int bytes_to_copy = (pixels_to_copy * d->depth) >> 3;-
1218 for (int i = 0; i < lines_to_copy; ++i) {
i < lines_to_copyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1219 memcpy(dest, src, bytes_to_copy);-
1220 src += d->bytes_per_line;-
1221 dest += image.d->bytes_per_line;-
1222 }
never executed: end of block
0
1223 } else if (d->format == Format_Mono) {
never executed: end of block
d->format == Format_MonoDescription
TRUEnever evaluated
FALSEnever evaluated
0
1224 const uchar *src = d->data + y * d->bytes_per_line;-
1225 uchar *dest = image.d->data + dy * image.d->bytes_per_line;-
1226 for (int i = 0; i < lines_to_copy; ++i) {
i < lines_to_copyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1227 for (int j = 0; j < pixels_to_copy; ++j) {
j < pixels_to_copyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1228 if (src[(x + j) >> 3] & (0x80 >> ((x + j) & 7)))
src[(x + j) >>...((x + j) & 7))Description
TRUEnever evaluated
FALSEnever evaluated
0
1229 dest[(dx + j) >> 3] |= (0x80 >> ((dx + j) & 7));
never executed: dest[(dx + j) >> 3] |= (0x80 >> ((dx + j) & 7));
0
1230 else-
1231 dest[(dx + j) >> 3] &= ~(0x80 >> ((dx + j) & 7));
never executed: dest[(dx + j) >> 3] &= ~(0x80 >> ((dx + j) & 7));
0
1232 }-
1233 src += d->bytes_per_line;-
1234 dest += image.d->bytes_per_line;-
1235 }
never executed: end of block
0
1236 } else { // Format_MonoLSB
never executed: end of block
0
1237 Q_ASSERT(d->format == Format_MonoLSB);-
1238 const uchar *src = d->data + y * d->bytes_per_line;-
1239 uchar *dest = image.d->data + dy * image.d->bytes_per_line;-
1240 for (int i = 0; i < lines_to_copy; ++i) {
i < lines_to_copyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1241 for (int j = 0; j < pixels_to_copy; ++j) {
j < pixels_to_copyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1242 if (src[(x + j) >> 3] & (0x1 << ((x + j) & 7)))
src[(x + j) >>...((x + j) & 7))Description
TRUEnever evaluated
FALSEnever evaluated
0
1243 dest[(dx + j) >> 3] |= (0x1 << ((dx + j) & 7));
never executed: dest[(dx + j) >> 3] |= (0x1 << ((dx + j) & 7));
0
1244 else-
1245 dest[(dx + j) >> 3] &= ~(0x1 << ((dx + j) & 7));
never executed: dest[(dx + j) >> 3] &= ~(0x1 << ((dx + j) & 7));
0
1246 }-
1247 src += d->bytes_per_line;-
1248 dest += image.d->bytes_per_line;-
1249 }
never executed: end of block
0
1250 }
never executed: end of block
0
1251-
1252 copyMetadata(image.d, d);-
1253 image.d->offset = offset();-
1254 image.d->has_alpha_clut = d->has_alpha_clut;-
1255 return image;
never executed: return image;
0
1256}-
1257-
1258-
1259/*!-
1260 \fn bool QImage::isNull() const-
1261-
1262 Returns \c true if it is a null image, otherwise returns \c false.-
1263-
1264 A null image has all parameters set to zero and no allocated data.-
1265*/-
1266bool QImage::isNull() const-
1267{-
1268 return !d;
never executed: return !d;
0
1269}-
1270-
1271/*!-
1272 \fn int QImage::width() const-
1273-
1274 Returns the width of the image.-
1275-
1276 \sa {QImage#Image Information}{Image Information}-
1277*/-
1278int QImage::width() const-
1279{-
1280 return d ? d->width : 0;
never executed: return d ? d->width : 0;
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1281}-
1282-
1283/*!-
1284 \fn int QImage::height() const-
1285-
1286 Returns the height of the image.-
1287-
1288 \sa {QImage#Image Information}{Image Information}-
1289*/-
1290int QImage::height() const-
1291{-
1292 return d ? d->height : 0;
never executed: return d ? d->height : 0;
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1293}-
1294-
1295/*!-
1296 \fn QSize QImage::size() const-
1297-
1298 Returns the size of the image, i.e. its width() and height().-
1299-
1300 \sa {QImage#Image Information}{Image Information}-
1301*/-
1302QSize QImage::size() const-
1303{-
1304 return d ? QSize(d->width, d->height) : QSize(0, 0);
never executed: return d ? QSize(d->width, d->height) : QSize(0, 0);
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1305}-
1306-
1307/*!-
1308 \fn QRect QImage::rect() const-
1309-
1310 Returns the enclosing rectangle (0, 0, width(), height()) of the-
1311 image.-
1312-
1313 \sa {QImage#Image Information}{Image Information}-
1314*/-
1315QRect QImage::rect() const-
1316{-
1317 return d ? QRect(0, 0, d->width, d->height) : QRect();
never executed: return d ? QRect(0, 0, d->width, d->height) : QRect();
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1318}-
1319-
1320/*!-
1321 Returns the depth of the image.-
1322-
1323 The image depth is the number of bits used to store a single-
1324 pixel, also called bits per pixel (bpp).-
1325-
1326 The supported depths are 1, 8, 16, 24 and 32.-
1327-
1328 \sa bitPlaneCount(), convertToFormat(), {QImage#Image Formats}{Image Formats},-
1329 {QImage#Image Information}{Image Information}-
1330-
1331*/-
1332int QImage::depth() const-
1333{-
1334 return d ? d->depth : 0;
never executed: return d ? d->depth : 0;
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1335}-
1336-
1337/*!-
1338 \obsolete-
1339 \fn int QImage::numColors() const-
1340-
1341 Returns the size of the color table for the image.-
1342-
1343 \sa setColorCount()-
1344*/-
1345-
1346/*!-
1347 \since 4.6-
1348 \fn int QImage::colorCount() const-
1349-
1350 Returns the size of the color table for the image.-
1351-
1352 Notice that colorCount() returns 0 for 32-bpp images because these-
1353 images do not use color tables, but instead encode pixel values as-
1354 ARGB quadruplets.-
1355-
1356 \sa setColorCount(), {QImage#Image Information}{Image Information}-
1357*/-
1358int QImage::colorCount() const-
1359{-
1360 return d ? d->colortable.size() : 0;
never executed: return d ? d->colortable.size() : 0;
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1361}-
1362-
1363/*!-
1364 Sets the color table used to translate color indexes to QRgb-
1365 values, to the specified \a colors.-
1366-
1367 When the image is used, the color table must be large enough to-
1368 have entries for all the pixel/index values present in the image,-
1369 otherwise the results are undefined.-
1370-
1371 \sa colorTable(), setColor(), {QImage#Image Transformations}{Image-
1372 Transformations}-
1373*/-
1374#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)-
1375void QImage::setColorTable(const QVector<QRgb> &colors)-
1376#else-
1377void QImage::setColorTable(const QVector<QRgb> colors)-
1378#endif-
1379{-
1380 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1381 return;
never executed: return;
0
1382 detach();-
1383-
1384 // In case detach() ran out of memory-
1385 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1386 return;
never executed: return;
0
1387-
1388#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)-
1389 d->colortable = colors;-
1390#else-
1391 d->colortable = qMove(const_cast<QVector<QRgb>&>(colors));-
1392#endif-
1393 d->has_alpha_clut = false;-
1394 for (int i = 0; i < d->colortable.size(); ++i) {
i < d->colortable.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1395 if (qAlpha(d->colortable.at(i)) != 255) {
qAlpha(d->colo....at(i)) != 255Description
TRUEnever evaluated
FALSEnever evaluated
0
1396 d->has_alpha_clut = true;-
1397 break;
never executed: break;
0
1398 }-
1399 }
never executed: end of block
0
1400}
never executed: end of block
0
1401-
1402/*!-
1403 Returns a list of the colors contained in the image's color table,-
1404 or an empty list if the image does not have a color table-
1405-
1406 \sa setColorTable(), colorCount(), color()-
1407*/-
1408QVector<QRgb> QImage::colorTable() const-
1409{-
1410 return d ? d->colortable : QVector<QRgb>();
never executed: return d ? d->colortable : QVector<QRgb>();
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1411}-
1412-
1413/*!-
1414 Returns the device pixel ratio for the image. This is the-
1415 ratio between \e{device pixels} and \e{device independent pixels}.-
1416-
1417 Use this function when calculating layout geometry based on-
1418 the image size: QSize layoutSize = image.size() / image.devicePixelRatio()-
1419-
1420 The default value is 1.0.-
1421-
1422 \sa setDevicePixelRatio(), QImageReader-
1423*/-
1424qreal QImage::devicePixelRatio() const-
1425{-
1426 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1427 return 1.0;
never executed: return 1.0;
0
1428 return d->devicePixelRatio;
never executed: return d->devicePixelRatio;
0
1429}-
1430-
1431/*!-
1432 Sets the device pixel ratio for the image. This is the-
1433 ratio between image pixels and device-independent pixels.-
1434-
1435 The default \a scaleFactor is 1.0. Setting it to something else has-
1436 two effects:-
1437-
1438 QPainters that are opened on the image will be scaled. For-
1439 example, painting on a 200x200 image if with a ratio of 2.0-
1440 will result in effective (device-independent) painting bounds-
1441 of 100x100.-
1442-
1443 Code paths in Qt that calculate layout geometry based on the-
1444 image size will take the ratio into account:-
1445 QSize layoutSize = image.size() / image.devicePixelRatio()-
1446 The net effect of this is that the image is displayed as-
1447 high-DPI image rather than a large image-
1448 (see \l{Drawing High Resolution Versions of Pixmaps and Images}).-
1449-
1450 \sa devicePixelRatio()-
1451*/-
1452void QImage::setDevicePixelRatio(qreal scaleFactor)-
1453{-
1454 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1455 return;
never executed: return;
0
1456-
1457 if (scaleFactor == d->devicePixelRatio)
scaleFactor ==...vicePixelRatioDescription
TRUEnever evaluated
FALSEnever evaluated
0
1458 return;
never executed: return;
0
1459-
1460 detach();-
1461 d->devicePixelRatio = scaleFactor;-
1462}
never executed: end of block
0
1463-
1464/*!-
1465 \since 4.6-
1466 Returns the number of bytes occupied by the image data.-
1467-
1468 \sa bytesPerLine(), bits(), {QImage#Image Information}{Image-
1469 Information}-
1470*/-
1471int QImage::byteCount() const-
1472{-
1473 return d ? d->nbytes : 0;
never executed: return d ? d->nbytes : 0;
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1474}-
1475-
1476/*!-
1477 Returns the number of bytes per image scanline.-
1478-
1479 This is equivalent to byteCount() / height().-
1480-
1481 \sa scanLine()-
1482*/-
1483int QImage::bytesPerLine() const-
1484{-
1485 return (d && d->height) ? d->nbytes / d->height : 0;
never executed: return (d && d->height) ? d->nbytes / d->height : 0;
dDescription
TRUEnever evaluated
FALSEnever evaluated
d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
1486}-
1487-
1488-
1489/*!-
1490 Returns the color in the color table at index \a i. The first-
1491 color is at index 0.-
1492-
1493 The colors in an image's color table are specified as ARGB-
1494 quadruplets (QRgb). Use the qAlpha(), qRed(), qGreen(), and-
1495 qBlue() functions to get the color value components.-
1496-
1497 \sa setColor(), pixelIndex(), {QImage#Pixel Manipulation}{Pixel-
1498 Manipulation}-
1499*/-
1500QRgb QImage::color(int i) const-
1501{-
1502 Q_ASSERT(i < colorCount());-
1503 return d ? d->colortable.at(i) : QRgb(uint(-1));
never executed: return d ? d->colortable.at(i) : QRgb(uint(-1));
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1504}-
1505-
1506/*!-
1507 \fn void QImage::setColor(int index, QRgb colorValue)-
1508-
1509 Sets the color at the given \a index in the color table, to the-
1510 given to \a colorValue. The color value is an ARGB quadruplet.-
1511-
1512 If \a index is outside the current size of the color table, it is-
1513 expanded with setColorCount().-
1514-
1515 \sa color(), colorCount(), setColorTable(), {QImage#Pixel Manipulation}{Pixel-
1516 Manipulation}-
1517*/-
1518void QImage::setColor(int i, QRgb c)-
1519{-
1520 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1521 return;
never executed: return;
0
1522 if (i < 0 || d->depth > 8 || i >= 1<<d->depth) {
i < 0Description
TRUEnever evaluated
FALSEnever evaluated
d->depth > 8Description
TRUEnever evaluated
FALSEnever evaluated
i >= 1<<d->depthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1523 qWarning("QImage::setColor: Index out of bound %d", i);-
1524 return;
never executed: return;
0
1525 }-
1526 detach();-
1527-
1528 // In case detach() run out of memory-
1529 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1530 return;
never executed: return;
0
1531-
1532 if (i >= d->colortable.size())
i >= d->colortable.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1533 setColorCount(i+1);
never executed: setColorCount(i+1);
0
1534 d->colortable[i] = c;-
1535 d->has_alpha_clut |= (qAlpha(c) != 255);-
1536}
never executed: end of block
0
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 \warning If you are accessing 32-bpp image data, cast the returned-
1545 pointer to \c{QRgb*} (QRgb has a 32-bit size) and use it to-
1546 read/write the pixel value. You cannot use the \c{uchar*} pointer-
1547 directly, because the pixel format depends on the byte order on-
1548 the underlying platform. Use qRed(), qGreen(), qBlue(), and-
1549 qAlpha() to access the pixels.-
1550-
1551 \sa bytesPerLine(), bits(), {QImage#Pixel Manipulation}{Pixel-
1552 Manipulation}, constScanLine()-
1553*/-
1554uchar *QImage::scanLine(int i)-
1555{-
1556 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1557 return 0;
never executed: return 0;
0
1558-
1559 detach();-
1560-
1561 // In case detach() ran out of memory-
1562 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1563 return 0;
never executed: return 0;
0
1564-
1565 return d->data + i * d->bytes_per_line;
never executed: return d->data + i * d->bytes_per_line;
0
1566}-
1567-
1568/*!-
1569 \overload-
1570*/-
1571const uchar *QImage::scanLine(int i) const-
1572{-
1573 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1574 return 0;
never executed: return 0;
0
1575-
1576 Q_ASSERT(i >= 0 && i < height());-
1577 return d->data + i * d->bytes_per_line;
never executed: return d->data + i * d->bytes_per_line;
0
1578}-
1579-
1580-
1581/*!-
1582 Returns a pointer to the pixel data at the scanline with index \a-
1583 i. The first scanline is at index 0.-
1584-
1585 The scanline data is aligned on a 32-bit boundary.-
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 \sa scanLine(), constBits()-
1592 \since 4.7-
1593*/-
1594const uchar *QImage::constScanLine(int i) const-
1595{-
1596 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1597 return 0;
never executed: return 0;
0
1598-
1599 Q_ASSERT(i >= 0 && i < height());-
1600 return d->data + i * d->bytes_per_line;
never executed: return d->data + i * d->bytes_per_line;
0
1601}-
1602-
1603/*!-
1604 Returns a pointer to the first pixel data. This is equivalent to-
1605 scanLine(0).-
1606-
1607 Note that QImage uses \l{Implicit Data Sharing} {implicit data-
1608 sharing}. This function performs a deep copy of the shared pixel-
1609 data, thus ensuring that this QImage is the only one using the-
1610 current return value.-
1611-
1612 \sa scanLine(), byteCount(), constBits()-
1613*/-
1614uchar *QImage::bits()-
1615{-
1616 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1617 return 0;
never executed: return 0;
0
1618 detach();-
1619-
1620 // In case detach ran out of memory...-
1621 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1622 return 0;
never executed: return 0;
0
1623-
1624 return d->data;
never executed: return d->data;
0
1625}-
1626-
1627/*!-
1628 \overload-
1629-
1630 Note that QImage uses \l{Implicit Data Sharing} {implicit data-
1631 sharing}, but this function does \e not perform a deep copy of the-
1632 shared pixel data, because the returned data is const.-
1633*/-
1634const uchar *QImage::bits() const-
1635{-
1636 return d ? d->data : 0;
never executed: return d ? d->data : 0;
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1637}-
1638-
1639-
1640/*!-
1641 Returns a pointer to the first pixel data.-
1642-
1643 Note that QImage uses \l{Implicit Data Sharing} {implicit data-
1644 sharing}, but this function does \e not perform a deep copy of the-
1645 shared pixel data, because the returned data is const.-
1646-
1647 \sa bits(), constScanLine()-
1648 \since 4.7-
1649*/-
1650const uchar *QImage::constBits() const-
1651{-
1652 return d ? d->data : 0;
never executed: return d ? d->data : 0;
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1653}-
1654-
1655/*!-
1656 \fn void QImage::fill(uint pixelValue)-
1657-
1658 Fills the entire image with the given \a pixelValue.-
1659-
1660 If the depth of this image is 1, only the lowest bit is used. If-
1661 you say fill(0), fill(2), etc., the image is filled with 0s. If-
1662 you say fill(1), fill(3), etc., the image is filled with 1s. If-
1663 the depth is 8, the lowest 8 bits are used and if the depth is 16-
1664 the lowest 16 bits are used.-
1665-
1666 Note: QImage::pixel() returns the color of the pixel at the given-
1667 coordinates while QColor::pixel() returns the pixel value of the-
1668 underlying window system (essentially an index value), so normally-
1669 you will want to use QImage::pixel() to use a color from an-
1670 existing image or QColor::rgb() to use a specific color.-
1671-
1672 \sa depth(), {QImage#Image Transformations}{Image Transformations}-
1673*/-
1674-
1675void QImage::fill(uint pixel)-
1676{-
1677 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1678 return;
never executed: return;
0
1679-
1680 detach();-
1681-
1682 // In case detach() ran out of memory-
1683 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1684 return;
never executed: return;
0
1685-
1686 if (d->depth == 1 || d->depth == 8) {
d->depth == 1Description
TRUEnever evaluated
FALSEnever evaluated
d->depth == 8Description
TRUEnever evaluated
FALSEnever evaluated
0
1687 int w = d->width;-
1688 if (d->depth == 1) {
d->depth == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1689 if (pixel & 1)
pixel & 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1690 pixel = 0xffffffff;
never executed: pixel = 0xffffffff;
0
1691 else-
1692 pixel = 0;
never executed: pixel = 0;
0
1693 w = (w + 7) / 8;-
1694 } else {
never executed: end of block
0
1695 pixel &= 0xff;-
1696 }
never executed: end of block
0
1697 qt_rectfill<quint8>(d->data, pixel, 0, 0,-
1698 w, d->height, d->bytes_per_line);-
1699 return;
never executed: return;
0
1700 } else if (d->depth == 16) {
d->depth == 16Description
TRUEnever evaluated
FALSEnever evaluated
0
1701 qt_rectfill<quint16>(reinterpret_cast<quint16*>(d->data), pixel,-
1702 0, 0, d->width, d->height, d->bytes_per_line);-
1703 return;
never executed: return;
0
1704 } else if (d->depth == 24) {
d->depth == 24Description
TRUEnever evaluated
FALSEnever evaluated
0
1705 qt_rectfill<quint24>(reinterpret_cast<quint24*>(d->data), pixel,-
1706 0, 0, d->width, d->height, d->bytes_per_line);-
1707 return;
never executed: return;
0
1708 }-
1709-
1710 if (d->format == Format_RGB32)
d->format == Format_RGB32Description
TRUEnever evaluated
FALSEnever evaluated
0
1711 pixel |= 0xff000000;
never executed: pixel |= 0xff000000;
0
1712 if (d->format == Format_RGBX8888)
d->format == Format_RGBX8888Description
TRUEnever evaluated
FALSEnever evaluated
0
1713#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN-
1714 pixel |= 0xff000000;
never executed: pixel |= 0xff000000;
0
1715#else-
1716 pixel |= 0x000000ff;-
1717#endif-
1718 if (d->format == Format_BGR30 || d->format == Format_RGB30)
d->format == Format_BGR30Description
TRUEnever evaluated
FALSEnever evaluated
d->format == Format_RGB30Description
TRUEnever evaluated
FALSEnever evaluated
0
1719 pixel |= 0xc0000000;
never executed: pixel |= 0xc0000000;
0
1720-
1721 qt_rectfill<uint>(reinterpret_cast<uint*>(d->data), pixel,-
1722 0, 0, d->width, d->height, d->bytes_per_line);-
1723}
never executed: end of block
0
1724-
1725-
1726/*!-
1727 \fn void QImage::fill(Qt::GlobalColor color)-
1728 \overload-
1729 \since 4.8-
1730-
1731 Fills the image with the given \a color, described as a standard global-
1732 color.-
1733 */-
1734-
1735void QImage::fill(Qt::GlobalColor color)-
1736{-
1737 fill(QColor(color));-
1738}
never executed: end of block
0
1739-
1740-
1741-
1742/*!-
1743 \fn void QImage::fill(const QColor &color)-
1744-
1745 \overload-
1746-
1747 Fills the entire image with the given \a color.-
1748-
1749 If the depth of the image is 1, the image will be filled with 1 if-
1750 \a color equals Qt::color1; it will otherwise be filled with 0.-
1751-
1752 If the depth of the image is 8, the image will be filled with the-
1753 index corresponding the \a color in the color table if present; it-
1754 will otherwise be filled with 0.-
1755-
1756 \since 4.8-
1757*/-
1758-
1759void QImage::fill(const QColor &color)-
1760{-
1761 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1762 return;
never executed: return;
0
1763 detach();-
1764-
1765 // In case we run out of memory-
1766 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1767 return;
never executed: return;
0
1768-
1769 switch (d->format) {-
1770 case QImage::Format_RGB32:
never executed: case QImage::Format_RGB32:
0
1771 case QImage::Format_ARGB32:
never executed: case QImage::Format_ARGB32:
0
1772 fill(color.rgba());-
1773 break;
never executed: break;
0
1774 case QImage::Format_ARGB32_Premultiplied:
never executed: case QImage::Format_ARGB32_Premultiplied:
0
1775 fill(qPremultiply(color.rgba()));-
1776 break;
never executed: break;
0
1777 case QImage::Format_RGBX8888:
never executed: case QImage::Format_RGBX8888:
0
1778 fill(ARGB2RGBA(color.rgba() | 0xff000000));-
1779 break;
never executed: break;
0
1780 case QImage::Format_RGBA8888:
never executed: case QImage::Format_RGBA8888:
0
1781 fill(ARGB2RGBA(color.rgba()));-
1782 break;
never executed: break;
0
1783 case QImage::Format_RGBA8888_Premultiplied:
never executed: case QImage::Format_RGBA8888_Premultiplied:
0
1784 fill(ARGB2RGBA(qPremultiply(color.rgba())));-
1785 break;
never executed: break;
0
1786 case QImage::Format_BGR30:
never executed: case QImage::Format_BGR30:
0
1787 case QImage::Format_A2BGR30_Premultiplied:
never executed: case QImage::Format_A2BGR30_Premultiplied:
0
1788 fill(qConvertRgb64ToRgb30<PixelOrderBGR>(color.rgba64()));-
1789 break;
never executed: break;
0
1790 case QImage::Format_RGB30:
never executed: case QImage::Format_RGB30:
0
1791 case QImage::Format_A2RGB30_Premultiplied:
never executed: case QImage::Format_A2RGB30_Premultiplied:
0
1792 fill(qConvertRgb64ToRgb30<PixelOrderRGB>(color.rgba64()));-
1793 break;
never executed: break;
0
1794 case QImage::Format_RGB16:
never executed: case QImage::Format_RGB16:
0
1795 fill((uint) qConvertRgb32To16(color.rgba()));-
1796 break;
never executed: break;
0
1797 case QImage::Format_Indexed8: {
never executed: case QImage::Format_Indexed8:
0
1798 uint pixel = 0;-
1799 for (int i=0; i<d->colortable.size(); ++i) {
i<d->colortable.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1800 if (color.rgba() == d->colortable.at(i)) {
color.rgba() =...lortable.at(i)Description
TRUEnever evaluated
FALSEnever evaluated
0
1801 pixel = i;-
1802 break;
never executed: break;
0
1803 }-
1804 }
never executed: end of block
0
1805 fill(pixel);-
1806 break;
never executed: break;
0
1807 }-
1808 case QImage::Format_Mono:
never executed: case QImage::Format_Mono:
0
1809 case QImage::Format_MonoLSB:
never executed: case QImage::Format_MonoLSB:
0
1810 if (color == Qt::color1)
color == Qt::color1Description
TRUEnever evaluated
FALSEnever evaluated
0
1811 fill((uint) 1);
never executed: fill((uint) 1);
0
1812 else-
1813 fill((uint) 0);
never executed: fill((uint) 0);
0
1814 break;
never executed: break;
0
1815 default: {
never executed: default:
0
1816 QPainter p(this);-
1817 p.setCompositionMode(QPainter::CompositionMode_Source);-
1818 p.fillRect(rect(), color);-
1819 }}
never executed: end of block
0
1820}-
1821-
1822-
1823-
1824/*!-
1825 Inverts all pixel values in the image.-
1826-
1827 The given invert \a mode only have a meaning when the image's-
1828 depth is 32. The default \a mode is InvertRgb, which leaves the-
1829 alpha channel unchanged. If the \a mode is InvertRgba, the alpha-
1830 bits are also inverted.-
1831-
1832 Inverting an 8-bit image means to replace all pixels using color-
1833 index \e i with a pixel using color index 255 minus \e i. The same-
1834 is the case for a 1-bit image. Note that the color table is \e not-
1835 changed.-
1836-
1837 If the image has a premultiplied alpha channel, the image is first-
1838 converted to ARGB32 to be inverted and then converted back.-
1839-
1840 \sa {QImage#Image Transformations}{Image Transformations}-
1841*/-
1842-
1843void QImage::invertPixels(InvertMode mode)-
1844{-
1845 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1846 return;
never executed: return;
0
1847-
1848 detach();-
1849-
1850 // In case detach() ran out of memory-
1851 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1852 return;
never executed: return;
0
1853-
1854 QImage::Format originalFormat = d->format;-
1855 // Inverting premultiplied pixels would produce invalid image data.-
1856 if (hasAlphaChannel() && qPixelLayouts[d->format].premultiplied) {
hasAlphaChannel()Description
TRUEnever evaluated
FALSEnever evaluated
qPixelLayouts[....premultipliedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1857 if (!d->convertInPlace(QImage::Format_ARGB32, 0))
!d->convertInP...mat_ARGB32, 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1858 *this = convertToFormat(QImage::Format_ARGB32);
never executed: *this = convertToFormat(QImage::Format_ARGB32);
0
1859 }
never executed: end of block
0
1860-
1861 if (depth() < 32) {
depth() < 32Description
TRUEnever evaluated
FALSEnever evaluated
0
1862 // This assumes no alpha-channel as the only formats with non-premultipled alpha are 32bit.-
1863 int bpl = (d->width * d->depth + 7) / 8;-
1864 int pad = d->bytes_per_line - bpl;-
1865 uchar *sl = d->data;-
1866 for (int y=0; y<d->height; ++y) {
y<d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
1867 for (int x=0; x<bpl; ++x)
x<bplDescription
TRUEnever evaluated
FALSEnever evaluated
0
1868 *sl++ ^= 0xff;
never executed: *sl++ ^= 0xff;
0
1869 sl += pad;-
1870 }
never executed: end of block
0
1871 } else {
never executed: end of block
0
1872 quint32 *p = (quint32*)d->data;-
1873 quint32 *end = (quint32*)(d->data + d->nbytes);-
1874 quint32 xorbits = 0xffffffff;-
1875 switch (d->format) {-
1876 case QImage::Format_RGBA8888:
never executed: case QImage::Format_RGBA8888:
0
1877 if (mode == InvertRgba)
mode == InvertRgbaDescription
TRUEnever evaluated
FALSEnever evaluated
0
1878 break;
never executed: break;
0
1879 // no break-
1880 case QImage::Format_RGBX8888:
code before this statement never executed: case QImage::Format_RGBX8888:
never executed: case QImage::Format_RGBX8888:
0
1881#if Q_BYTE_ORDER == Q_BIG_ENDIAN-
1882 xorbits = 0xffffff00;-
1883 break;-
1884#else-
1885 xorbits = 0x00ffffff;-
1886 break;
never executed: break;
0
1887#endif-
1888 case QImage::Format_ARGB32:
never executed: case QImage::Format_ARGB32:
0
1889 if (mode == InvertRgba)
mode == InvertRgbaDescription
TRUEnever evaluated
FALSEnever evaluated
0
1890 break;
never executed: break;
0
1891 // no break-
1892 case QImage::Format_RGB32:
code before this statement never executed: case QImage::Format_RGB32:
never executed: case QImage::Format_RGB32:
0
1893 xorbits = 0x00ffffff;-
1894 break;
never executed: break;
0
1895 case QImage::Format_BGR30:
never executed: case QImage::Format_BGR30:
0
1896 case QImage::Format_RGB30:
never executed: case QImage::Format_RGB30:
0
1897 xorbits = 0x3fffffff;-
1898 break;
never executed: break;
0
1899 default:
never executed: default:
0
1900 Q_UNREACHABLE();-
1901 xorbits = 0;-
1902 break;
never executed: break;
0
1903 }-
1904 while (p < end)
p < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
1905 *p++ ^= xorbits;
never executed: *p++ ^= xorbits;
0
1906 }
never executed: end of block
0
1907-
1908 if (originalFormat != d->format) {
originalFormat != d->formatDescription
TRUEnever evaluated
FALSEnever evaluated
0
1909 if (!d->convertInPlace(originalFormat, 0))
!d->convertInP...inalFormat, 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1910 *this = convertToFormat(originalFormat);
never executed: *this = convertToFormat(originalFormat);
0
1911 }
never executed: end of block
0
1912}
never executed: end of block
0
1913-
1914// Windows defines these-
1915#if defined(write)-
1916# undef write-
1917#endif-
1918#if defined(close)-
1919# undef close-
1920#endif-
1921#if defined(read)-
1922# undef read-
1923#endif-
1924-
1925/*!-
1926 \since 4.6-
1927 Resizes the color table to contain \a colorCount entries.-
1928-
1929 If the color table is expanded, all the extra colors will be set to-
1930 transparent (i.e qRgba(0, 0, 0, 0)).-
1931-
1932 When the image is used, the color table must be large enough to-
1933 have entries for all the pixel/index values present in the image,-
1934 otherwise the results are undefined.-
1935-
1936 \sa colorCount(), colorTable(), setColor(), {QImage#Image-
1937 Transformations}{Image Transformations}-
1938*/-
1939-
1940void QImage::setColorCount(int colorCount)-
1941{-
1942 if (!d) {
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1943 qWarning("QImage::setColorCount: null image");-
1944 return;
never executed: return;
0
1945 }-
1946-
1947 detach();-
1948-
1949 // In case detach() ran out of memory-
1950 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1951 return;
never executed: return;
0
1952-
1953 if (colorCount == d->colortable.size())
colorCount == ...ortable.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1954 return;
never executed: return;
0
1955 if (colorCount <= 0) { // use no color table
colorCount <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1956 d->colortable = QVector<QRgb>();-
1957 return;
never executed: return;
0
1958 }-
1959 int nc = d->colortable.size();-
1960 d->colortable.resize(colorCount);-
1961 for (int i = nc; i < colorCount; ++i)
i < colorCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1962 d->colortable[i] = 0;
never executed: d->colortable[i] = 0;
0
1963}
never executed: end of block
0
1964-
1965/*!-
1966 Returns the format of the image.-
1967-
1968 \sa {QImage#Image Formats}{Image Formats}-
1969*/-
1970QImage::Format QImage::format() const-
1971{-
1972 return d ? d->format : Format_Invalid;
never executed: return d ? d->format : Format_Invalid;
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1973}-
1974-
1975/*!-
1976 \fn QImage QImage::convertToFormat(Format format, Qt::ImageConversionFlags flags) const-
1977-
1978 Returns a copy of the image in the given \a format.-
1979-
1980 The specified image conversion \a flags control how the image data-
1981 is handled during the conversion process.-
1982-
1983 \sa {Image Formats}-
1984*/-
1985-
1986/*!-
1987 \internal-
1988*/-
1989QImage QImage::convertToFormat_helper(Format format, Qt::ImageConversionFlags flags) const-
1990{-
1991 if (!d || d->format == format)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
d->format == formatDescription
TRUEnever evaluated
FALSEnever evaluated
0
1992 return *this;
never executed: return *this;
0
1993-
1994 if (format == Format_Invalid || d->format == Format_Invalid)
format == Format_InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
d->format == Format_InvalidDescription
TRUEnever evaluated
FALSEnever evaluated
0
1995 return QImage();
never executed: return QImage();
0
1996-
1997 Image_Converter converter = qimage_converter_map[d->format][format];-
1998 if (!converter && format > QImage::Format_Indexed8 && d->format > QImage::Format_Indexed8)
!converterDescription
TRUEnever evaluated
FALSEnever evaluated
format > QImag...ormat_Indexed8Description
TRUEnever evaluated
FALSEnever evaluated
d->format > QI...ormat_Indexed8Description
TRUEnever evaluated
FALSEnever evaluated
0
1999 converter = convert_generic;
never executed: converter = convert_generic;
0
2000 if (converter) {
converterDescription
TRUEnever evaluated
FALSEnever evaluated
0
2001 QImage image(d->width, d->height, format);-
2002-
2003 QIMAGE_SANITYCHECK_MEMORY(image);
never executed: return QImage();
(image).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2004-
2005 image.d->offset = offset();-
2006 copyMetadata(image.d, d);-
2007-
2008 converter(image.d, d, flags);-
2009 return image;
never executed: return image;
0
2010 }-
2011-
2012 // Convert indexed formats over ARGB32 or RGB32 to the final format.-
2013 Q_ASSERT(format != QImage::Format_ARGB32 && format != QImage::Format_RGB32);-
2014 Q_ASSERT(d->format != QImage::Format_ARGB32 && d->format != QImage::Format_RGB32);-
2015-
2016 if (!hasAlphaChannel())
!hasAlphaChannel()Description
TRUEnever evaluated
FALSEnever evaluated
0
2017 return convertToFormat(Format_RGB32, flags).convertToFormat(format, flags);
never executed: return convertToFormat(Format_RGB32, flags).convertToFormat(format, flags);
0
2018-
2019 return convertToFormat(Format_ARGB32, flags).convertToFormat(format, flags);
never executed: return convertToFormat(Format_ARGB32, flags).convertToFormat(format, flags);
0
2020}-
2021-
2022/*!-
2023 \internal-
2024*/-
2025bool QImage::convertToFormat_inplace(Format format, Qt::ImageConversionFlags flags)-
2026{-
2027 return d && d->convertInPlace(format, flags);
never executed: return d && d->convertInPlace(format, flags);
dDescription
TRUEnever evaluated
FALSEnever evaluated
d->convertInPl...format, flags)Description
TRUEnever evaluated
FALSEnever evaluated
0
2028}-
2029-
2030static inline int pixel_distance(QRgb p1, QRgb p2) {-
2031 int r1 = qRed(p1);-
2032 int g1 = qGreen(p1);-
2033 int b1 = qBlue(p1);-
2034 int a1 = qAlpha(p1);-
2035-
2036 int r2 = qRed(p2);-
2037 int g2 = qGreen(p2);-
2038 int b2 = qBlue(p2);-
2039 int a2 = qAlpha(p2);-
2040-
2041 return abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2) + abs(a1 - a2);
never executed: return abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2) + abs(a1 - a2);
0
2042}-
2043-
2044static inline int closestMatch(QRgb pixel, const QVector<QRgb> &clut) {-
2045 int idx = 0;-
2046 int current_distance = INT_MAX;-
2047 for (int i=0; i<clut.size(); ++i) {
i<clut.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
2048 int dist = pixel_distance(pixel, clut.at(i));-
2049 if (dist < current_distance) {
dist < current_distanceDescription
TRUEnever evaluated
FALSEnever evaluated
0
2050 current_distance = dist;-
2051 idx = i;-
2052 }
never executed: end of block
0
2053 }
never executed: end of block
0
2054 return idx;
never executed: return idx;
0
2055}-
2056-
2057static QImage convertWithPalette(const QImage &src, QImage::Format format,-
2058 const QVector<QRgb> &clut) {-
2059 QImage dest(src.size(), format);-
2060 dest.setColorTable(clut);-
2061-
2062 QString textsKeys = src.text();-
2063 QStringList textKeyList = textsKeys.split(QLatin1Char('\n'), QString::SkipEmptyParts);-
2064 foreach (const QString &textKey, textKeyList) {-
2065 QStringList textKeySplitted = textKey.split(QLatin1String(": "));-
2066 dest.setText(textKeySplitted[0], textKeySplitted[1]);-
2067 }
never executed: end of block
0
2068-
2069 int h = src.height();-
2070 int w = src.width();-
2071-
2072 QHash<QRgb, int> cache;-
2073-
2074 if (format == QImage::Format_Indexed8) {
format == QIma...ormat_Indexed8Description
TRUEnever evaluated
FALSEnever evaluated
0
2075 for (int y=0; y<h; ++y) {
y<hDescription
TRUEnever evaluated
FALSEnever evaluated
0
2076 const QRgb *src_pixels = (const QRgb *) src.scanLine(y);-
2077 uchar *dest_pixels = (uchar *) dest.scanLine(y);-
2078 for (int x=0; x<w; ++x) {
x<wDescription
TRUEnever evaluated
FALSEnever evaluated
0
2079 int src_pixel = src_pixels[x];-
2080 int value = cache.value(src_pixel, -1);-
2081 if (value == -1) {
value == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
2082 value = closestMatch(src_pixel, clut);-
2083 cache.insert(src_pixel, value);-
2084 }
never executed: end of block
0
2085 dest_pixels[x] = (uchar) value;-
2086 }
never executed: end of block
0
2087 }
never executed: end of block
0
2088 } else {
never executed: end of block
0
2089 QVector<QRgb> table = clut;-
2090 table.resize(2);-
2091 for (int y=0; y<h; ++y) {
y<hDescription
TRUEnever evaluated
FALSEnever evaluated
0
2092 const QRgb *src_pixels = (const QRgb *) src.scanLine(y);-
2093 for (int x=0; x<w; ++x) {
x<wDescription
TRUEnever evaluated
FALSEnever evaluated
0
2094 int src_pixel = src_pixels[x];-
2095 int value = cache.value(src_pixel, -1);-
2096 if (value == -1) {
value == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
2097 value = closestMatch(src_pixel, table);-
2098 cache.insert(src_pixel, value);-
2099 }
never executed: end of block
0
2100 dest.setPixel(x, y, value);-
2101 }
never executed: end of block
0
2102 }
never executed: end of block
0
2103 }
never executed: end of block
0
2104-
2105 return dest;
never executed: return dest;
0
2106}-
2107-
2108/*!-
2109 \overload-
2110-
2111 Returns a copy of the image converted to the given \a format,-
2112 using the specified \a colorTable.-
2113-
2114 Conversion from 32 bit to 8 bit indexed is a slow operation and-
2115 will use a straightforward nearest color approach, with no-
2116 dithering.-
2117*/-
2118QImage QImage::convertToFormat(Format format, const QVector<QRgb> &colorTable, Qt::ImageConversionFlags flags) const-
2119{-
2120 if (!d || d->format == format)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
d->format == formatDescription
TRUEnever evaluated
FALSEnever evaluated
0
2121 return *this;
never executed: return *this;
0
2122-
2123 if (format <= QImage::Format_Indexed8 && depth() == 32) {
format <= QIma...ormat_Indexed8Description
TRUEnever evaluated
FALSEnever evaluated
depth() == 32Description
TRUEnever evaluated
FALSEnever evaluated
0
2124 return convertWithPalette(*this, format, colorTable);
never executed: return convertWithPalette(*this, format, colorTable);
0
2125 }-
2126-
2127 const Image_Converter *converterPtr = &qimage_converter_map[d->format][format];-
2128 Image_Converter converter = *converterPtr;-
2129 if (!converter)
!converterDescription
TRUEnever evaluated
FALSEnever evaluated
0
2130 return QImage();
never executed: return QImage();
0
2131-
2132 QImage image(d->width, d->height, format);-
2133 QIMAGE_SANITYCHECK_MEMORY(image);
never executed: return QImage();
(image).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2134-
2135 image.d->offset = offset();-
2136 copyMetadata(image.d, d);-
2137-
2138 converter(image.d, d, flags);-
2139 return image;
never executed: return image;
0
2140}-
2141-
2142/*!-
2143 \fn bool QImage::valid(const QPoint &pos) const-
2144-
2145 Returns \c true if \a pos is a valid coordinate pair within the-
2146 image; otherwise returns \c false.-
2147-
2148 \sa rect(), QRect::contains()-
2149*/-
2150-
2151/*!-
2152 \overload-
2153-
2154 Returns \c true if QPoint(\a x, \a y) is a valid coordinate pair-
2155 within the image; otherwise returns \c false.-
2156*/-
2157bool QImage::valid(int x, int y) const-
2158{-
2159 return d
never executed: return d && x >= 0 && x < d->width && y >= 0 && y < d->height;
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
2160 && x >= 0 && x < d->width
never executed: return d && x >= 0 && x < d->width && y >= 0 && y < d->height;
x >= 0Description
TRUEnever evaluated
FALSEnever evaluated
x < d->widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2161 && y >= 0 && y < d->height;
never executed: return d && x >= 0 && x < d->width && y >= 0 && y < d->height;
y >= 0Description
TRUEnever evaluated
FALSEnever evaluated
y < d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2162}-
2163-
2164/*!-
2165 \fn int QImage::pixelIndex(const QPoint &position) const-
2166-
2167 Returns the pixel index at the given \a position.-
2168-
2169 If \a position is not valid, or if the image is not a paletted-
2170 image (depth() > 8), the results are undefined.-
2171-
2172 \sa valid(), depth(), {QImage#Pixel Manipulation}{Pixel Manipulation}-
2173*/-
2174-
2175/*!-
2176 \overload-
2177-
2178 Returns the pixel index at (\a x, \a y).-
2179*/-
2180int QImage::pixelIndex(int x, int y) const-
2181{-
2182 if (!d || x < 0 || x >= d->width || y < 0 || y >= height()) {
!dDescription
TRUEnever evaluated
FALSEnever evaluated
x < 0Description
TRUEnever evaluated
FALSEnever evaluated
x >= d->widthDescription
TRUEnever evaluated
FALSEnever evaluated
y < 0Description
TRUEnever evaluated
FALSEnever evaluated
y >= height()Description
TRUEnever evaluated
FALSEnever evaluated
0
2183 qWarning("QImage::pixelIndex: coordinate (%d,%d) out of range", x, y);-
2184 return -12345;
never executed: return -12345;
0
2185 }-
2186 const uchar * s = scanLine(y);-
2187 switch(d->format) {-
2188 case Format_Mono:
never executed: case Format_Mono:
0
2189 return (*(s + (x >> 3)) >> (7- (x & 7))) & 1;
never executed: return (*(s + (x >> 3)) >> (7- (x & 7))) & 1;
0
2190 case Format_MonoLSB:
never executed: case Format_MonoLSB:
0
2191 return (*(s + (x >> 3)) >> (x & 7)) & 1;
never executed: return (*(s + (x >> 3)) >> (x & 7)) & 1;
0
2192 case Format_Indexed8:
never executed: case Format_Indexed8:
0
2193 return (int)s[x];
never executed: return (int)s[x];
0
2194 default:
never executed: default:
0
2195 qWarning("QImage::pixelIndex: Not applicable for %d-bpp images (no palette)", d->depth);-
2196 }
never executed: end of block
0
2197 return 0;
never executed: return 0;
0
2198}-
2199-
2200-
2201/*!-
2202 \fn QRgb QImage::pixel(const QPoint &position) const-
2203-
2204 Returns the color of the pixel at the given \a position.-
2205-
2206 If the \a position is not valid, the results are undefined.-
2207-
2208 \warning This function is expensive when used for massive pixel-
2209 manipulations. Use constBits() or constScanLine() when many-
2210 pixels needs to be read.-
2211-
2212 \sa setPixel(), valid(), constBits(), constScanLine(), {QImage#Pixel Manipulation}{Pixel-
2213 Manipulation}-
2214*/-
2215-
2216/*!-
2217 \overload-
2218-
2219 Returns the color of the pixel at coordinates (\a x, \a y).-
2220*/-
2221QRgb QImage::pixel(int x, int y) const-
2222{-
2223 if (!d || x < 0 || x >= d->width || y < 0 || y >= d->height) {
!dDescription
TRUEnever evaluated
FALSEnever evaluated
x < 0Description
TRUEnever evaluated
FALSEnever evaluated
x >= d->widthDescription
TRUEnever evaluated
FALSEnever evaluated
y < 0Description
TRUEnever evaluated
FALSEnever evaluated
y >= d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2224 qWarning("QImage::pixel: coordinate (%d,%d) out of range", x, y);-
2225 return 12345;
never executed: return 12345;
0
2226 }-
2227-
2228 const uchar *s = d->data + y * d->bytes_per_line;-
2229-
2230 int index = -1;-
2231 switch (d->format) {-
2232 case Format_Mono:
never executed: case Format_Mono:
0
2233 index = (*(s + (x >> 3)) >> (~x & 7)) & 1;-
2234 break;
never executed: break;
0
2235 case Format_MonoLSB:
never executed: case Format_MonoLSB:
0
2236 index = (*(s + (x >> 3)) >> (x & 7)) & 1;-
2237 break;
never executed: break;
0
2238 case Format_Indexed8:
never executed: case Format_Indexed8:
0
2239 index = s[x];-
2240 break;
never executed: break;
0
2241 default:
never executed: default:
0
2242 break;
never executed: break;
0
2243 }-
2244 if (index >= 0) { // Indexed format
index >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2245 if (index >= d->colortable.size()) {
index >= d->colortable.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
2246 qWarning("QImage::pixel: color table index %d out of range.", index);-
2247 return 0;
never executed: return 0;
0
2248 }-
2249 return d->colortable.at(index);
never executed: return d->colortable.at(index);
0
2250 }-
2251-
2252 switch (d->format) {-
2253 case Format_RGB32:
never executed: case Format_RGB32:
0
2254 return 0xff000000 | reinterpret_cast<const QRgb *>(s)[x];
never executed: return 0xff000000 | reinterpret_cast<const QRgb *>(s)[x];
0
2255 case Format_ARGB32: // Keep old behaviour.
never executed: case Format_ARGB32:
0
2256 case Format_ARGB32_Premultiplied:
never executed: case Format_ARGB32_Premultiplied:
0
2257 return reinterpret_cast<const QRgb *>(s)[x];
never executed: return reinterpret_cast<const QRgb *>(s)[x];
0
2258 case Format_RGBX8888:
never executed: case Format_RGBX8888:
0
2259 case Format_RGBA8888: // Match ARGB32 behavior.
never executed: case Format_RGBA8888:
0
2260 case Format_RGBA8888_Premultiplied:
never executed: case Format_RGBA8888_Premultiplied:
0
2261 return RGBA2ARGB(reinterpret_cast<const quint32 *>(s)[x]);
never executed: return RGBA2ARGB(reinterpret_cast<const quint32 *>(s)[x]);
0
2262 case Format_BGR30:
never executed: case Format_BGR30:
0
2263 case Format_A2BGR30_Premultiplied:
never executed: case Format_A2BGR30_Premultiplied:
0
2264 return qConvertA2rgb30ToArgb32<PixelOrderBGR>(reinterpret_cast<const quint32 *>(s)[x]);
never executed: return qConvertA2rgb30ToArgb32<PixelOrderBGR>(reinterpret_cast<const quint32 *>(s)[x]);
0
2265 case Format_RGB30:
never executed: case Format_RGB30:
0
2266 case Format_A2RGB30_Premultiplied:
never executed: case Format_A2RGB30_Premultiplied:
0
2267 return qConvertA2rgb30ToArgb32<PixelOrderRGB>(reinterpret_cast<const quint32 *>(s)[x]);
never executed: return qConvertA2rgb30ToArgb32<PixelOrderRGB>(reinterpret_cast<const quint32 *>(s)[x]);
0
2268 case Format_RGB16:
never executed: case Format_RGB16:
0
2269 return qConvertRgb16To32(reinterpret_cast<const quint16 *>(s)[x]);
never executed: return qConvertRgb16To32(reinterpret_cast<const quint16 *>(s)[x]);
0
2270 default:
never executed: default:
0
2271 break;
never executed: break;
0
2272 }-
2273 const QPixelLayout *layout = &qPixelLayouts[d->format];-
2274 uint result;-
2275 const uint *ptr = qFetchPixels[layout->bpp](&result, s, x, 1);-
2276 return *layout->convertToARGB32PM(&result, ptr, 1, layout, 0);
never executed: return *layout->convertToARGB32PM(&result, ptr, 1, layout, 0);
0
2277}-
2278-
2279/*!-
2280 \fn void QImage::setPixel(const QPoint &position, uint index_or_rgb)-
2281-
2282 Sets the pixel index or color at the given \a position to \a-
2283 index_or_rgb.-
2284-
2285 If the image's format is either monochrome or paletted, the given \a-
2286 index_or_rgb value must be an index in the image's color table,-
2287 otherwise the parameter must be a QRgb value.-
2288-
2289 If \a position is not a valid coordinate pair in the image, or if-
2290 \a index_or_rgb >= colorCount() in the case of monochrome and-
2291 paletted images, the result is undefined.-
2292-
2293 \warning This function is expensive due to the call of the internal-
2294 \c{detach()} function called within; if performance is a concern, we-
2295 recommend the use of scanLine() or bits() to access pixel data directly.-
2296-
2297 \sa pixel(), {QImage#Pixel Manipulation}{Pixel Manipulation}-
2298*/-
2299-
2300/*!-
2301 \overload-
2302-
2303 Sets the pixel index or color at (\a x, \a y) to \a index_or_rgb.-
2304*/-
2305void QImage::setPixel(int x, int y, uint index_or_rgb)-
2306{-
2307 if (!d || x < 0 || x >= width() || y < 0 || y >= height()) {
!dDescription
TRUEnever evaluated
FALSEnever evaluated
x < 0Description
TRUEnever evaluated
FALSEnever evaluated
x >= width()Description
TRUEnever evaluated
FALSEnever evaluated
y < 0Description
TRUEnever evaluated
FALSEnever evaluated
y >= height()Description
TRUEnever evaluated
FALSEnever evaluated
0
2308 qWarning("QImage::setPixel: coordinate (%d,%d) out of range", x, y);-
2309 return;
never executed: return;
0
2310 }-
2311 // detach is called from within scanLine-
2312 uchar * s = scanLine(y);-
2313 switch(d->format) {-
2314 case Format_Mono:
never executed: case Format_Mono:
0
2315 case Format_MonoLSB:
never executed: case Format_MonoLSB:
0
2316 if (index_or_rgb > 1) {
index_or_rgb > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
2317 qWarning("QImage::setPixel: Index %d out of range", index_or_rgb);-
2318 } else if (format() == Format_MonoLSB) {
never executed: end of block
format() == Format_MonoLSBDescription
TRUEnever evaluated
FALSEnever evaluated
0
2319 if (index_or_rgb==0)
index_or_rgb==0Description
TRUEnever evaluated
FALSEnever evaluated
0
2320 *(s + (x >> 3)) &= ~(1 << (x & 7));
never executed: *(s + (x >> 3)) &= ~(1 << (x & 7));
0
2321 else-
2322 *(s + (x >> 3)) |= (1 << (x & 7));
never executed: *(s + (x >> 3)) |= (1 << (x & 7));
0
2323 } else {-
2324 if (index_or_rgb==0)
index_or_rgb==0Description
TRUEnever evaluated
FALSEnever evaluated
0
2325 *(s + (x >> 3)) &= ~(1 << (7-(x & 7)));
never executed: *(s + (x >> 3)) &= ~(1 << (7-(x & 7)));
0
2326 else-
2327 *(s + (x >> 3)) |= (1 << (7-(x & 7)));
never executed: *(s + (x >> 3)) |= (1 << (7-(x & 7)));
0
2328 }-
2329 return;
never executed: return;
0
2330 case Format_Indexed8:
never executed: case Format_Indexed8:
0
2331 if (index_or_rgb >= (uint)d->colortable.size()) {
index_or_rgb >...ortable.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
2332 qWarning("QImage::setPixel: Index %d out of range", index_or_rgb);-
2333 return;
never executed: return;
0
2334 }-
2335 s[x] = index_or_rgb;-
2336 return;
never executed: return;
0
2337 case Format_RGB32:
never executed: case Format_RGB32:
0
2338 //make sure alpha is 255, we depend on it in qdrawhelper for cases-
2339 // when image is set as a texture pattern on a qbrush-
2340 ((uint *)s)[x] = 0xff000000 | index_or_rgb;-
2341 return;
never executed: return;
0
2342 case Format_ARGB32:
never executed: case Format_ARGB32:
0
2343 case Format_ARGB32_Premultiplied:
never executed: case Format_ARGB32_Premultiplied:
0
2344 ((uint *)s)[x] = index_or_rgb;-
2345 return;
never executed: return;
0
2346 case Format_RGB16:
never executed: case Format_RGB16:
0
2347 ((quint16 *)s)[x] = qConvertRgb32To16(qUnpremultiply(index_or_rgb));-
2348 return;
never executed: return;
0
2349 case Format_RGBX8888:
never executed: case Format_RGBX8888:
0
2350 ((uint *)s)[x] = ARGB2RGBA(0xff000000 | index_or_rgb);-
2351 return;
never executed: return;
0
2352 case Format_RGBA8888:
never executed: case Format_RGBA8888:
0
2353 case Format_RGBA8888_Premultiplied:
never executed: case Format_RGBA8888_Premultiplied:
0
2354 ((uint *)s)[x] = ARGB2RGBA(index_or_rgb);-
2355 return;
never executed: return;
0
2356 case Format_BGR30:
never executed: case Format_BGR30:
0
2357 ((uint *)s)[x] = qConvertRgb32ToRgb30<PixelOrderBGR>(index_or_rgb);-
2358 return;
never executed: return;
0
2359 case Format_A2BGR30_Premultiplied:
never executed: case Format_A2BGR30_Premultiplied:
0
2360 ((uint *)s)[x] = qConvertArgb32ToA2rgb30<PixelOrderBGR>(index_or_rgb);-
2361 return;
never executed: return;
0
2362 case Format_RGB30:
never executed: case Format_RGB30:
0
2363 ((uint *)s)[x] = qConvertRgb32ToRgb30<PixelOrderRGB>(index_or_rgb);-
2364 return;
never executed: return;
0
2365 case Format_A2RGB30_Premultiplied:
never executed: case Format_A2RGB30_Premultiplied:
0
2366 ((uint *)s)[x] = qConvertArgb32ToA2rgb30<PixelOrderRGB>(index_or_rgb);-
2367 return;
never executed: return;
0
2368 case Format_Invalid:
never executed: case Format_Invalid:
0
2369 case NImageFormats:
never executed: case NImageFormats:
0
2370 Q_ASSERT(false);-
2371 return;
never executed: return;
0
2372 default:
never executed: default:
0
2373 break;
never executed: break;
0
2374 }-
2375-
2376 const QPixelLayout *layout = &qPixelLayouts[d->format];-
2377 uint result;-
2378 const uint *ptr = layout->convertFromARGB32PM(&result, &index_or_rgb, 1, layout, 0);-
2379 qStorePixels[layout->bpp](s, ptr, x, 1);-
2380}
never executed: end of block
0
2381-
2382/*!-
2383 \fn QColor QImage::pixelColor(const QPoint &position) const-
2384 \since 5.6-
2385-
2386 Returns the color of the pixel at the given \a position as a QColor.-
2387-
2388 If the \a position is not valid, an invalid QColor is returned.-
2389-
2390 \warning This function is expensive when used for massive pixel-
2391 manipulations. Use constBits() or constScanLine() when many-
2392 pixels needs to be read.-
2393-
2394 \sa setPixel(), valid(), constBits(), constScanLine(), {QImage#Pixel Manipulation}{Pixel-
2395 Manipulation}-
2396*/-
2397-
2398/*!-
2399 \overload-
2400 \since 5.6-
2401-
2402 Returns the color of the pixel at coordinates (\a x, \a y) as a QColor.-
2403*/-
2404QColor QImage::pixelColor(int x, int y) const-
2405{-
2406 if (!d || x < 0 || x >= d->width || y < 0 || y >= height()) {
!dDescription
TRUEnever evaluated
FALSEnever evaluated
x < 0Description
TRUEnever evaluated
FALSEnever evaluated
x >= d->widthDescription
TRUEnever evaluated
FALSEnever evaluated
y < 0Description
TRUEnever evaluated
FALSEnever evaluated
y >= height()Description
TRUEnever evaluated
FALSEnever evaluated
0
2407 qWarning("QImage::pixelColor: coordinate (%d,%d) out of range", x, y);-
2408 return QColor();
never executed: return QColor();
0
2409 }-
2410-
2411 QRgba64 c;-
2412 const uchar * s = constScanLine(y);-
2413 switch (d->format) {-
2414 case Format_BGR30:
never executed: case Format_BGR30:
0
2415 case Format_A2BGR30_Premultiplied:
never executed: case Format_A2BGR30_Premultiplied:
0
2416 c = qConvertA2rgb30ToRgb64<PixelOrderBGR>(reinterpret_cast<const quint32 *>(s)[x]);-
2417 break;
never executed: break;
0
2418 case Format_RGB30:
never executed: case Format_RGB30:
0
2419 case Format_A2RGB30_Premultiplied:
never executed: case Format_A2RGB30_Premultiplied:
0
2420 c = qConvertA2rgb30ToRgb64<PixelOrderRGB>(reinterpret_cast<const quint32 *>(s)[x]);-
2421 break;
never executed: break;
0
2422 default:
never executed: default:
0
2423 c = QRgba64::fromArgb32(pixel(x, y));-
2424 break;
never executed: break;
0
2425 }-
2426 // QColor is always unpremultiplied-
2427 if (hasAlphaChannel() && qPixelLayouts[d->format].premultiplied)
hasAlphaChannel()Description
TRUEnever evaluated
FALSEnever evaluated
qPixelLayouts[....premultipliedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2428 c = c.unpremultiplied();
never executed: c = c.unpremultiplied();
0
2429 return QColor(c);
never executed: return QColor(c);
0
2430}-
2431-
2432/*!-
2433 \fn void QImage::setPixelColor(const QPoint &position, const QColor &color)-
2434 \since 5.6-
2435-
2436 Sets the color at the given \a position to \a color.-
2437-
2438 If \a position is not a valid coordinate pair in the image, or-
2439 the image's format is either monochrome or paletted, the result is undefined.-
2440-
2441 \warning This function is expensive due to the call of the internal-
2442 \c{detach()} function called within; if performance is a concern, we-
2443 recommend the use of scanLine() or bits() to access pixel data directly.-
2444-
2445 \sa pixel(), bits(), scanLine(), {QImage#Pixel Manipulation}{Pixel Manipulation}-
2446*/-
2447-
2448/*!-
2449 \overload-
2450 \since 5.6-
2451-
2452 Sets the pixel color at (\a x, \a y) to \a color.-
2453*/-
2454void QImage::setPixelColor(int x, int y, const QColor &color)-
2455{-
2456 if (!d || x < 0 || x >= width() || y < 0 || y >= height() || !color.isValid()) {
!dDescription
TRUEnever evaluated
FALSEnever evaluated
x < 0Description
TRUEnever evaluated
FALSEnever evaluated
x >= width()Description
TRUEnever evaluated
FALSEnever evaluated
y < 0Description
TRUEnever evaluated
FALSEnever evaluated
y >= height()Description
TRUEnever evaluated
FALSEnever evaluated
!color.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
2457 qWarning("QImage::setPixelColor: coordinate (%d,%d) out of range", x, y);-
2458 return;
never executed: return;
0
2459 }-
2460 // QColor is always unpremultiplied-
2461 QRgba64 c = color.rgba64();-
2462 if (!hasAlphaChannel())
!hasAlphaChannel()Description
TRUEnever evaluated
FALSEnever evaluated
0
2463 c.setAlpha(65535);
never executed: c.setAlpha(65535);
0
2464 else if (qPixelLayouts[d->format].premultiplied)
qPixelLayouts[....premultipliedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2465 c = c.premultiplied();
never executed: c = c.premultiplied();
0
2466 // detach is called from within scanLine-
2467 uchar * s = scanLine(y);-
2468 switch (d->format) {-
2469 case Format_Mono:
never executed: case Format_Mono:
0
2470 case Format_MonoLSB:
never executed: case Format_MonoLSB:
0
2471 case Format_Indexed8:
never executed: case Format_Indexed8:
0
2472 qWarning("QImage::setPixelColor: called on monochrome or indexed format");-
2473 return;
never executed: return;
0
2474 case Format_BGR30:
never executed: case Format_BGR30:
0
2475 ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderBGR>(c) | 0xc0000000;-
2476 return;
never executed: return;
0
2477 case Format_A2BGR30_Premultiplied:
never executed: case Format_A2BGR30_Premultiplied:
0
2478 ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderBGR>(c);-
2479 return;
never executed: return;
0
2480 case Format_RGB30:
never executed: case Format_RGB30:
0
2481 ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderRGB>(c) | 0xc0000000;-
2482 return;
never executed: return;
0
2483 case Format_A2RGB30_Premultiplied:
never executed: case Format_A2RGB30_Premultiplied:
0
2484 ((uint *)s)[x] = qConvertRgb64ToRgb30<PixelOrderRGB>(c);-
2485 return;
never executed: return;
0
2486 default:
never executed: default:
0
2487 setPixel(x, y, c.toArgb32());-
2488 return;
never executed: return;
0
2489 }-
2490}-
2491-
2492/*!-
2493 Returns \c true if all the colors in the image are shades of gray-
2494 (i.e. their red, green and blue components are equal); otherwise-
2495 false.-
2496-
2497 Note that this function is slow for images without color table.-
2498-
2499 \sa isGrayscale()-
2500*/-
2501bool QImage::allGray() const-
2502{-
2503 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
2504 return true;
never executed: return true;
0
2505-
2506 switch (d->format) {-
2507 case Format_Mono:
never executed: case Format_Mono:
0
2508 case Format_MonoLSB:
never executed: case Format_MonoLSB:
0
2509 case Format_Indexed8:
never executed: case Format_Indexed8:
0
2510 for (int i = 0; i < d->colortable.size(); ++i) {
i < d->colortable.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
2511 if (!qIsGray(d->colortable.at(i)))
!qIsGray(d->colortable.at(i))Description
TRUEnever evaluated
FALSEnever evaluated
0
2512 return false;
never executed: return false;
0
2513 }
never executed: end of block
0
2514 return true;
never executed: return true;
0
2515 case Format_Alpha8:
never executed: case Format_Alpha8:
0
2516 return false;
never executed: return false;
0
2517 case Format_Grayscale8:
never executed: case Format_Grayscale8:
0
2518 return true;
never executed: return true;
0
2519 case Format_RGB32:
never executed: case Format_RGB32:
0
2520 case Format_ARGB32:
never executed: case Format_ARGB32:
0
2521 case Format_ARGB32_Premultiplied:
never executed: case Format_ARGB32_Premultiplied:
0
2522#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN-
2523 case Format_RGBX8888:
never executed: case Format_RGBX8888:
0
2524 case Format_RGBA8888:
never executed: case Format_RGBA8888:
0
2525 case Format_RGBA8888_Premultiplied:
never executed: case Format_RGBA8888_Premultiplied:
0
2526#endif-
2527 for (int j = 0; j < d->height; ++j) {
j < d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2528 const QRgb *b = (const QRgb *)constScanLine(j);-
2529 for (int i = 0; i < d->width; ++i) {
i < d->widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2530 if (!qIsGray(b[i]))
!qIsGray(b[i])Description
TRUEnever evaluated
FALSEnever evaluated
0
2531 return false;
never executed: return false;
0
2532 }
never executed: end of block
0
2533 }
never executed: end of block
0
2534 return true;
never executed: return true;
0
2535 case Format_RGB16:
never executed: case Format_RGB16:
0
2536 for (int j = 0; j < d->height; ++j) {
j < d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2537 const quint16 *b = (const quint16 *)constScanLine(j);-
2538 for (int i = 0; i < d->width; ++i) {
i < d->widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2539 if (!qIsGray(qConvertRgb16To32(b[i])))
!qIsGray(qConv...b16To32(b[i]))Description
TRUEnever evaluated
FALSEnever evaluated
0
2540 return false;
never executed: return false;
0
2541 }
never executed: end of block
0
2542 }
never executed: end of block
0
2543 return true;
never executed: return true;
0
2544 default:
never executed: default:
0
2545 break;
never executed: break;
0
2546 }-
2547-
2548 const int buffer_size = 2048;-
2549 uint buffer[buffer_size];-
2550 const QPixelLayout *layout = &qPixelLayouts[d->format];-
2551 FetchPixelsFunc fetch = qFetchPixels[layout->bpp];-
2552 for (int j = 0; j < d->height; ++j) {
j < d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2553 const uchar *b = constScanLine(j);-
2554 int x = 0;-
2555 while (x < d->width) {
x < d->widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2556 int l = qMin(d->width - x, buffer_size);-
2557 const uint *ptr = fetch(buffer, b, x, l);-
2558 ptr = layout->convertToARGB32PM(buffer, ptr, l, layout, 0);-
2559 for (int i = 0; i < l; ++i) {
i < lDescription
TRUEnever evaluated
FALSEnever evaluated
0
2560 if (!qIsGray(ptr[i]))
!qIsGray(ptr[i])Description
TRUEnever evaluated
FALSEnever evaluated
0
2561 return false;
never executed: return false;
0
2562 }
never executed: end of block
0
2563 x += l;-
2564 }
never executed: end of block
0
2565 }
never executed: end of block
0
2566 return true;
never executed: return true;
0
2567}-
2568-
2569/*!-
2570 For 32-bit images, this function is equivalent to allGray().-
2571-
2572 For color indexed images, this function returns \c true if-
2573 color(i) is QRgb(i, i, i) for all indexes of the color table;-
2574 otherwise returns \c false.-
2575-
2576 \sa allGray(), {QImage#Image Formats}{Image Formats}-
2577*/-
2578bool QImage::isGrayscale() const-
2579{-
2580 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
2581 return false;
never executed: return false;
0
2582-
2583 if (d->format == QImage::Format_Alpha8)
d->format == Q...:Format_Alpha8Description
TRUEnever evaluated
FALSEnever evaluated
0
2584 return false;
never executed: return false;
0
2585-
2586 if (d->format == QImage::Format_Grayscale8)
d->format == Q...mat_Grayscale8Description
TRUEnever evaluated
FALSEnever evaluated
0
2587 return true;
never executed: return true;
0
2588-
2589 switch (depth()) {-
2590 case 32:
never executed: case 32:
0
2591 case 24:
never executed: case 24:
0
2592 case 16:
never executed: case 16:
0
2593 return allGray();
never executed: return allGray();
0
2594 case 8: {
never executed: case 8:
0
2595 Q_ASSERT(d->format == QImage::Format_Indexed8);-
2596 for (int i = 0; i < colorCount(); i++)
i < colorCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
2597 if (d->colortable.at(i) != qRgb(i,i,i))
d->colortable....!= qRgb(i,i,i)Description
TRUEnever evaluated
FALSEnever evaluated
0
2598 return false;
never executed: return false;
0
2599 return true;
never executed: return true;
0
2600 }-
2601 }-
2602 return false;
never executed: return false;
0
2603}-
2604-
2605/*!-
2606 \fn QImage QImage::scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode,-
2607 Qt::TransformationMode transformMode) const-
2608 \overload-
2609-
2610 Returns a copy of the image scaled to a rectangle with the given-
2611 \a width and \a height according to the given \a aspectRatioMode-
2612 and \a transformMode.-
2613-
2614 If either the \a width or the \a height is zero or negative, this-
2615 function returns a null image.-
2616*/-
2617-
2618/*!-
2619 \fn QImage QImage::scaled(const QSize &size, Qt::AspectRatioMode aspectRatioMode,-
2620 Qt::TransformationMode transformMode) const-
2621-
2622 Returns a copy of the image scaled to a rectangle defined by the-
2623 given \a size according to the given \a aspectRatioMode and \a-
2624 transformMode.-
2625-
2626 \image qimage-scaling.png-
2627-
2628 \list-
2629 \li If \a aspectRatioMode is Qt::IgnoreAspectRatio, the image-
2630 is scaled to \a size.-
2631 \li If \a aspectRatioMode is Qt::KeepAspectRatio, the image is-
2632 scaled to a rectangle as large as possible inside \a size, preserving the aspect ratio.-
2633 \li If \a aspectRatioMode is Qt::KeepAspectRatioByExpanding,-
2634 the image is scaled to a rectangle as small as possible-
2635 outside \a size, preserving the aspect ratio.-
2636 \endlist-
2637-
2638 If the given \a size is empty, this function returns a null image.-
2639-
2640 \sa isNull(), {QImage#Image Transformations}{Image-
2641 Transformations}-
2642*/-
2643QImage QImage::scaled(const QSize& s, Qt::AspectRatioMode aspectMode, Qt::TransformationMode mode) const-
2644{-
2645 if (!d) {
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
2646 qWarning("QImage::scaled: Image is a null image");-
2647 return QImage();
never executed: return QImage();
0
2648 }-
2649 if (s.isEmpty())
s.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2650 return QImage();
never executed: return QImage();
0
2651-
2652 QSize newSize = size();-
2653 newSize.scale(s, aspectMode);-
2654 newSize.rwidth() = qMax(newSize.width(), 1);-
2655 newSize.rheight() = qMax(newSize.height(), 1);-
2656 if (newSize == size())
newSize == size()Description
TRUEnever evaluated
FALSEnever evaluated
0
2657 return *this;
never executed: return *this;
0
2658-
2659 QTransform wm = QTransform::fromScale((qreal)newSize.width() / width(), (qreal)newSize.height() / height());-
2660 QImage img = transformed(wm, mode);-
2661 return img;
never executed: return img;
0
2662}-
2663-
2664/*!-
2665 \fn QImage QImage::scaledToWidth(int width, Qt::TransformationMode mode) const-
2666-
2667 Returns a scaled copy of the image. The returned image is scaled-
2668 to the given \a width using the specified transformation \a-
2669 mode.-
2670-
2671 This function automatically calculates the height of the image so-
2672 that its aspect ratio is preserved.-
2673-
2674 If the given \a width is 0 or negative, a null image is returned.-
2675-
2676 \sa {QImage#Image Transformations}{Image Transformations}-
2677*/-
2678QImage QImage::scaledToWidth(int w, Qt::TransformationMode mode) const-
2679{-
2680 if (!d) {
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
2681 qWarning("QImage::scaleWidth: Image is a null image");-
2682 return QImage();
never executed: return QImage();
0
2683 }-
2684 if (w <= 0)
w <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2685 return QImage();
never executed: return QImage();
0
2686-
2687 qreal factor = (qreal) w / width();-
2688 QTransform wm = QTransform::fromScale(factor, factor);-
2689 return transformed(wm, mode);
never executed: return transformed(wm, mode);
0
2690}-
2691-
2692/*!-
2693 \fn QImage QImage::scaledToHeight(int height, Qt::TransformationMode mode) const-
2694-
2695 Returns a scaled copy of the image. The returned image is scaled-
2696 to the given \a height using the specified transformation \a-
2697 mode.-
2698-
2699 This function automatically calculates the width of the image so that-
2700 the ratio of the image is preserved.-
2701-
2702 If the given \a height is 0 or negative, a null image is returned.-
2703-
2704 \sa {QImage#Image Transformations}{Image Transformations}-
2705*/-
2706QImage QImage::scaledToHeight(int h, Qt::TransformationMode mode) const-
2707{-
2708 if (!d) {
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
2709 qWarning("QImage::scaleHeight: Image is a null image");-
2710 return QImage();
never executed: return QImage();
0
2711 }-
2712 if (h <= 0)
h <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2713 return QImage();
never executed: return QImage();
0
2714-
2715 qreal factor = (qreal) h / height();-
2716 QTransform wm = QTransform::fromScale(factor, factor);-
2717 return transformed(wm, mode);
never executed: return transformed(wm, mode);
0
2718}-
2719-
2720-
2721/*!-
2722 \fn QMatrix QImage::trueMatrix(const QMatrix &matrix, int width, int height)-
2723-
2724 Returns the actual matrix used for transforming an image with the-
2725 given \a width, \a height and \a matrix.-
2726-
2727 When transforming an image using the transformed() function, the-
2728 transformation matrix is internally adjusted to compensate for-
2729 unwanted translation, i.e. transformed() returns the smallest-
2730 image containing all transformed points of the original image.-
2731 This function returns the modified matrix, which maps points-
2732 correctly from the original image into the new image.-
2733-
2734 \sa transformed(), {QImage#Image Transformations}{Image-
2735 Transformations}-
2736*/-
2737QMatrix QImage::trueMatrix(const QMatrix &matrix, int w, int h)-
2738{-
2739 return trueMatrix(QTransform(matrix), w, h).toAffine();
never executed: return trueMatrix(QTransform(matrix), w, h).toAffine();
0
2740}-
2741-
2742/*!-
2743 Returns a copy of the image that is transformed using the given-
2744 transformation \a matrix and transformation \a mode.-
2745-
2746 The transformation \a matrix is internally adjusted to compensate-
2747 for unwanted translation; i.e. the image produced is the smallest-
2748 image that contains all the transformed points of the original-
2749 image. Use the trueMatrix() function to retrieve the actual matrix-
2750 used for transforming an image.-
2751-
2752 \sa trueMatrix(), {QImage#Image Transformations}{Image-
2753 Transformations}-
2754*/-
2755QImage QImage::transformed(const QMatrix &matrix, Qt::TransformationMode mode) const-
2756{-
2757 return transformed(QTransform(matrix), mode);
never executed: return transformed(QTransform(matrix), mode);
0
2758}-
2759-
2760/*!-
2761 Builds and returns a 1-bpp mask from the alpha buffer in this-
2762 image. Returns a null image if the image's format is-
2763 QImage::Format_RGB32.-
2764-
2765 The \a flags argument is a bitwise-OR of the-
2766 Qt::ImageConversionFlags, and controls the conversion-
2767 process. Passing 0 for flags sets all the default options.-
2768-
2769 The returned image has little-endian bit order (i.e. the image's-
2770 format is QImage::Format_MonoLSB), which you can convert to-
2771 big-endian (QImage::Format_Mono) using the convertToFormat()-
2772 function.-
2773-
2774 \sa createHeuristicMask(), {QImage#Image Transformations}{Image-
2775 Transformations}-
2776*/-
2777QImage QImage::createAlphaMask(Qt::ImageConversionFlags flags) const-
2778{-
2779 if (!d || d->format == QImage::Format_RGB32)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
d->format == Q...::Format_RGB32Description
TRUEnever evaluated
FALSEnever evaluated
0
2780 return QImage();
never executed: return QImage();
0
2781-
2782 if (d->depth == 1) {
d->depth == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
2783 // A monochrome pixmap, with alpha channels on those two colors.-
2784 // Pretty unlikely, so use less efficient solution.-
2785 return convertToFormat(Format_Indexed8, flags).createAlphaMask(flags);
never executed: return convertToFormat(Format_Indexed8, flags).createAlphaMask(flags);
0
2786 }-
2787-
2788 QImage mask(d->width, d->height, Format_MonoLSB);-
2789 if (!mask.isNull())
!mask.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2790 dither_to_Mono(mask.d, d, flags, true);
never executed: dither_to_Mono(mask.d, d, flags, true);
0
2791 return mask;
never executed: return mask;
0
2792}-
2793-
2794#ifndef QT_NO_IMAGE_HEURISTIC_MASK-
2795/*!-
2796 Creates and returns a 1-bpp heuristic mask for this image.-
2797-
2798 The function works by selecting a color from one of the corners,-
2799 then chipping away pixels of that color starting at all the edges.-
2800 The four corners vote for which color is to be masked away. In-
2801 case of a draw (this generally means that this function is not-
2802 applicable to the image), the result is arbitrary.-
2803-
2804 The returned image has little-endian bit order (i.e. the image's-
2805 format is QImage::Format_MonoLSB), which you can convert to-
2806 big-endian (QImage::Format_Mono) using the convertToFormat()-
2807 function.-
2808-
2809 If \a clipTight is true (the default) the mask is just large-
2810 enough to cover the pixels; otherwise, the mask is larger than the-
2811 data pixels.-
2812-
2813 Note that this function disregards the alpha buffer.-
2814-
2815 \sa createAlphaMask(), {QImage#Image Transformations}{Image-
2816 Transformations}-
2817*/-
2818-
2819QImage QImage::createHeuristicMask(bool clipTight) const-
2820{-
2821 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
2822 return QImage();
never executed: return QImage();
0
2823-
2824 if (d->depth != 32) {
d->depth != 32Description
TRUEnever evaluated
FALSEnever evaluated
0
2825 QImage img32 = convertToFormat(Format_RGB32);-
2826 return img32.createHeuristicMask(clipTight);
never executed: return img32.createHeuristicMask(clipTight);
0
2827 }-
2828-
2829#define PIX(x,y) (*((const QRgb*)scanLine(y)+x) & 0x00ffffff)-
2830-
2831 int w = width();-
2832 int h = height();-
2833 QImage m(w, h, Format_MonoLSB);-
2834 QIMAGE_SANITYCHECK_MEMORY(m);
never executed: return QImage();
(m).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2835 m.setColorCount(2);-
2836 m.setColor(0, QColor(Qt::color0).rgba());-
2837 m.setColor(1, QColor(Qt::color1).rgba());-
2838 m.fill(0xff);-
2839-
2840 QRgb background = PIX(0,0);-
2841 if (background != PIX(w-1,0) &&
background != ... & 0x00ffffff)Description
TRUEnever evaluated
FALSEnever evaluated
0
2842 background != PIX(0,h-1) &&
background != ... & 0x00ffffff)Description
TRUEnever evaluated
FALSEnever evaluated
0
2843 background != PIX(w-1,h-1)) {
background != ... & 0x00ffffff)Description
TRUEnever evaluated
FALSEnever evaluated
0
2844 background = PIX(w-1,0);-
2845 if (background != PIX(w-1,h-1) &&
background != ... & 0x00ffffff)Description
TRUEnever evaluated
FALSEnever evaluated
0
2846 background != PIX(0,h-1) &&
background != ... & 0x00ffffff)Description
TRUEnever evaluated
FALSEnever evaluated
0
2847 PIX(0,h-1) == PIX(w-1,h-1)) {
(*((const QRgb... & 0x00ffffff)Description
TRUEnever evaluated
FALSEnever evaluated
0
2848 background = PIX(w-1,h-1);-
2849 }
never executed: end of block
0
2850 }
never executed: end of block
0
2851-
2852 int x,y;-
2853 bool done = false;-
2854 uchar *ypp, *ypc, *ypn;-
2855 while(!done) {
!doneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2856 done = true;-
2857 ypn = m.scanLine(0);-
2858 ypc = 0;-
2859 for (y = 0; y < h; y++) {
y < hDescription
TRUEnever evaluated
FALSEnever evaluated
0
2860 ypp = ypc;-
2861 ypc = ypn;-
2862 ypn = (y == h-1) ? 0 : m.scanLine(y+1);
(y == h-1)Description
TRUEnever evaluated
FALSEnever evaluated
0
2863 const QRgb *p = (const QRgb *)scanLine(y);-
2864 for (x = 0; x < w; x++) {
x < wDescription
TRUEnever evaluated
FALSEnever evaluated
0
2865 // slowness here - it's possible to do six of these tests-
2866 // together in one go. oh well.-
2867 if ((x == 0 || y == 0 || x == w-1 || y == h-1 ||
x == 0Description
TRUEnever evaluated
FALSEnever evaluated
y == 0Description
TRUEnever evaluated
FALSEnever evaluated
x == w-1Description
TRUEnever evaluated
FALSEnever evaluated
y == h-1Description
TRUEnever evaluated
FALSEnever evaluated
0
2868 !(*(ypc + ((x-1) >> 3)) & (1 << ((x-1) & 7))) ||
!(*(ypc + ((x-... ((x-1) & 7)))Description
TRUEnever evaluated
FALSEnever evaluated
0
2869 !(*(ypc + ((x+1) >> 3)) & (1 << ((x+1) & 7))) ||
!(*(ypc + ((x+... ((x+1) & 7)))Description
TRUEnever evaluated
FALSEnever evaluated
0
2870 !(*(ypp + (x >> 3)) & (1 << (x & 7))) ||
!(*(ypp + (x >...1 << (x & 7)))Description
TRUEnever evaluated
FALSEnever evaluated
0
2871 !(*(ypn + (x >> 3)) & (1 << (x & 7)))) &&
!(*(ypn + (x >...1 << (x & 7)))Description
TRUEnever evaluated
FALSEnever evaluated
0
2872 ( (*(ypc + (x >> 3)) & (1 << (x & 7)))) &&
( (*(ypc + (x ... << (x & 7))))Description
TRUEnever evaluated
FALSEnever evaluated
0
2873 ((*p & 0x00ffffff) == background)) {
((*p & 0x00fff...== background)Description
TRUEnever evaluated
FALSEnever evaluated
0
2874 done = false;-
2875 *(ypc + (x >> 3)) &= ~(1 << (x & 7));-
2876 }
never executed: end of block
0
2877 p++;-
2878 }
never executed: end of block
0
2879 }
never executed: end of block
0
2880 }
never executed: end of block
0
2881-
2882 if (!clipTight) {
!clipTightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2883 ypn = m.scanLine(0);-
2884 ypc = 0;-
2885 for (y = 0; y < h; y++) {
y < hDescription
TRUEnever evaluated
FALSEnever evaluated
0
2886 ypp = ypc;-
2887 ypc = ypn;-
2888 ypn = (y == h-1) ? 0 : m.scanLine(y+1);
(y == h-1)Description
TRUEnever evaluated
FALSEnever evaluated
0
2889 const QRgb *p = (const QRgb *)scanLine(y);-
2890 for (x = 0; x < w; x++) {
x < wDescription
TRUEnever evaluated
FALSEnever evaluated
0
2891 if ((*p & 0x00ffffff) != background) {
(*p & 0x00ffff... != backgroundDescription
TRUEnever evaluated
FALSEnever evaluated
0
2892 if (x > 0)
x > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2893 *(ypc + ((x-1) >> 3)) |= (1 << ((x-1) & 7));
never executed: *(ypc + ((x-1) >> 3)) |= (1 << ((x-1) & 7));
0
2894 if (x < w-1)
x < w-1Description
TRUEnever evaluated
FALSEnever evaluated
0
2895 *(ypc + ((x+1) >> 3)) |= (1 << ((x+1) & 7));
never executed: *(ypc + ((x+1) >> 3)) |= (1 << ((x+1) & 7));
0
2896 if (y > 0)
y > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2897 *(ypp + (x >> 3)) |= (1 << (x & 7));
never executed: *(ypp + (x >> 3)) |= (1 << (x & 7));
0
2898 if (y < h-1)
y < h-1Description
TRUEnever evaluated
FALSEnever evaluated
0
2899 *(ypn + (x >> 3)) |= (1 << (x & 7));
never executed: *(ypn + (x >> 3)) |= (1 << (x & 7));
0
2900 }
never executed: end of block
0
2901 p++;-
2902 }
never executed: end of block
0
2903 }
never executed: end of block
0
2904 }
never executed: end of block
0
2905-
2906#undef PIX-
2907-
2908 return m;
never executed: return m;
0
2909}-
2910#endif //QT_NO_IMAGE_HEURISTIC_MASK-
2911-
2912/*!-
2913 Creates and returns a mask for this image based on the given \a-
2914 color value. If the \a mode is MaskInColor (the default value),-
2915 all pixels matching \a color will be opaque pixels in the mask. If-
2916 \a mode is MaskOutColor, all pixels matching the given color will-
2917 be transparent.-
2918-
2919 \sa createAlphaMask(), createHeuristicMask()-
2920*/-
2921-
2922QImage QImage::createMaskFromColor(QRgb color, Qt::MaskMode mode) const-
2923{-
2924 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
2925 return QImage();
never executed: return QImage();
0
2926 QImage maskImage(size(), QImage::Format_MonoLSB);-
2927 QIMAGE_SANITYCHECK_MEMORY(maskImage);
never executed: return QImage();
(maskImage).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
2928 maskImage.fill(0);-
2929 uchar *s = maskImage.bits();-
2930-
2931 if (depth() == 32) {
depth() == 32Description
TRUEnever evaluated
FALSEnever evaluated
0
2932 for (int h = 0; h < d->height; h++) {
h < d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2933 const uint *sl = (const uint *) scanLine(h);-
2934 for (int w = 0; w < d->width; w++) {
w < d->widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2935 if (sl[w] == color)
sl[w] == colorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2936 *(s + (w >> 3)) |= (1 << (w & 7));
never executed: *(s + (w >> 3)) |= (1 << (w & 7));
0
2937 }
never executed: end of block
0
2938 s += maskImage.bytesPerLine();-
2939 }
never executed: end of block
0
2940 } else {
never executed: end of block
0
2941 for (int h = 0; h < d->height; h++) {
h < d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
2942 for (int w = 0; w < d->width; w++) {
w < d->widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
2943 if ((uint) pixel(w, h) == color)
(uint) pixel(w, h) == colorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2944 *(s + (w >> 3)) |= (1 << (w & 7));
never executed: *(s + (w >> 3)) |= (1 << (w & 7));
0
2945 }
never executed: end of block
0
2946 s += maskImage.bytesPerLine();-
2947 }
never executed: end of block
0
2948 }
never executed: end of block
0
2949 if (mode == Qt::MaskOutColor)
mode == Qt::MaskOutColorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2950 maskImage.invertPixels();
never executed: maskImage.invertPixels();
0
2951 return maskImage;
never executed: return maskImage;
0
2952}-
2953-
2954/*!-
2955 \fn QImage QImage::mirrored(bool horizontal = false, bool vertical = true) const-
2956 Returns a mirror of the image, mirrored in the horizontal and/or-
2957 the vertical direction depending on whether \a horizontal and \a-
2958 vertical are set to true or false.-
2959-
2960 Note that the original image is not changed.-
2961-
2962 \sa {QImage#Image Transformations}{Image Transformations}-
2963*/-
2964-
2965template<class T> inline void do_mirror_data(QImageData *dst, QImageData *src,-
2966 int dstX0, int dstY0,-
2967 int dstXIncr, int dstYIncr,-
2968 int w, int h)-
2969{-
2970 if (dst == src) {
dst == srcDescription
TRUEnever evaluated
FALSEnever evaluated
0
2971 // When mirroring in-place, stop in the middle for one of the directions, since we-
2972 // are swapping the bytes instead of merely copying.-
2973 const int srcXEnd = (dstX0 && !dstY0) ? w / 2 : w;-
2974 const int srcYEnd = dstY0 ? h / 2 : h;-
2975 for (int srcY = 0, dstY = dstY0; srcY < srcYEnd; ++srcY, dstY += dstYIncr) {
srcY < srcYEndDescription
TRUEnever evaluated
FALSEnever evaluated
0
2976 T *srcPtr = (T *) (src->data + srcY * src->bytes_per_line);-
2977 T *dstPtr = (T *) (dst->data + dstY * dst->bytes_per_line);-
2978 for (int srcX = 0, dstX = dstX0; srcX < srcXEnd; ++srcX, dstX += dstXIncr)
srcX < srcXEndDescription
TRUEnever evaluated
FALSEnever evaluated
0
2979 std::swap(srcPtr[srcX], dstPtr[dstX]);
never executed: std::swap(srcPtr[srcX], dstPtr[dstX]);
0
2980 }
never executed: end of block
0
2981 // If mirroring both ways, the middle line needs to be mirrored horizontally only.-
2982 if (dstX0 && dstY0 && (h & 1)) {
dstX0Description
TRUEnever evaluated
FALSEnever evaluated
dstY0Description
TRUEnever evaluated
FALSEnever evaluated
(h & 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
2983 int srcY = h / 2;-
2984 int srcXEnd2 = w / 2;-
2985 T *srcPtr = (T *) (src->data + srcY * src->bytes_per_line);-
2986 for (int srcX = 0, dstX = dstX0; srcX < srcXEnd2; ++srcX, dstX += dstXIncr)
srcX < srcXEnd2Description
TRUEnever evaluated
FALSEnever evaluated
0
2987 std::swap(srcPtr[srcX], srcPtr[dstX]);
never executed: std::swap(srcPtr[srcX], srcPtr[dstX]);
0
2988 }
never executed: end of block
0
2989 } else {
never executed: end of block
0
2990 for (int srcY = 0, dstY = dstY0; srcY < h; ++srcY, dstY += dstYIncr) {
srcY < hDescription
TRUEnever evaluated
FALSEnever evaluated
0
2991 T *srcPtr = (T *) (src->data + srcY * src->bytes_per_line);-
2992 T *dstPtr = (T *) (dst->data + dstY * dst->bytes_per_line);-
2993 for (int srcX = 0, dstX = dstX0; srcX < w; ++srcX, dstX += dstXIncr)
srcX < wDescription
TRUEnever evaluated
FALSEnever evaluated
0
2994 dstPtr[dstX] = srcPtr[srcX];
never executed: dstPtr[dstX] = srcPtr[srcX];
0
2995 }
never executed: end of block
0
2996 }
never executed: end of block
0
2997}-
2998-
2999inline void do_mirror(QImageData *dst, QImageData *src, bool horizontal, bool vertical)-
3000{-
3001 Q_ASSERT(src->width == dst->width && src->height == dst->height && src->depth == dst->depth);-
3002 int w = src->width;-
3003 int h = src->height;-
3004 int depth = src->depth;-
3005-
3006 if (src->depth == 1) {
src->depth == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
3007 w = (w + 7) / 8; // byte aligned width-
3008 depth = 8;-
3009 }
never executed: end of block
0
3010-
3011 int dstX0 = 0, dstXIncr = 1;-
3012 int dstY0 = 0, dstYIncr = 1;-
3013 if (horizontal) {
horizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
3014 // 0 -> w-1, 1 -> w-2, 2 -> w-3, ...-
3015 dstX0 = w - 1;-
3016 dstXIncr = -1;-
3017 }
never executed: end of block
0
3018 if (vertical) {
verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
3019 // 0 -> h-1, 1 -> h-2, 2 -> h-3, ...-
3020 dstY0 = h - 1;-
3021 dstYIncr = -1;-
3022 }
never executed: end of block
0
3023-
3024 switch (depth) {-
3025 case 32:
never executed: case 32:
0
3026 do_mirror_data<quint32>(dst, src, dstX0, dstY0, dstXIncr, dstYIncr, w, h);-
3027 break;
never executed: break;
0
3028 case 24:
never executed: case 24:
0
3029 do_mirror_data<quint24>(dst, src, dstX0, dstY0, dstXIncr, dstYIncr, w, h);-
3030 break;
never executed: break;
0
3031 case 16:
never executed: case 16:
0
3032 do_mirror_data<quint16>(dst, src, dstX0, dstY0, dstXIncr, dstYIncr, w, h);-
3033 break;
never executed: break;
0
3034 case 8:
never executed: case 8:
0
3035 do_mirror_data<quint8>(dst, src, dstX0, dstY0, dstXIncr, dstYIncr, w, h);-
3036 break;
never executed: break;
0
3037 default:
never executed: default:
0
3038 Q_ASSERT(false);-
3039 break;
never executed: break;
0
3040 }-
3041-
3042 // The bytes are now all in the correct place. In addition, the bits in the individual-
3043 // bytes have to be flipped too when horizontally mirroring a 1 bit-per-pixel image.-
3044 if (horizontal && dst->depth == 1) {
horizontalDescription
TRUEnever evaluated
FALSEnever evaluated
dst->depth == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
3045 Q_ASSERT(dst->format == QImage::Format_Mono || dst->format == QImage::Format_MonoLSB);-
3046 const int shift = 8 - (dst->width % 8);-
3047 const uchar *bitflip = qt_get_bitflip_array();-
3048 for (int y = 0; y < h; ++y) {
y < hDescription
TRUEnever evaluated
FALSEnever evaluated
0
3049 uchar *begin = dst->data + y * dst->bytes_per_line;-
3050 uchar *end = begin + dst->bytes_per_line;-
3051 for (uchar *p = begin; p < end; ++p) {
p < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
3052 *p = bitflip[*p];-
3053 // When the data is non-byte aligned, an extra bit shift (of the number of-
3054 // unused bits at the end) is needed for the entire scanline.-
3055 if (shift != 8 && p != begin) {
shift != 8Description
TRUEnever evaluated
FALSEnever evaluated
p != beginDescription
TRUEnever evaluated
FALSEnever evaluated
0
3056 if (dst->format == QImage::Format_Mono) {
dst->format ==...e::Format_MonoDescription
TRUEnever evaluated
FALSEnever evaluated
0
3057 for (int i = 0; i < shift; ++i) {
i < shiftDescription
TRUEnever evaluated
FALSEnever evaluated
0
3058 p[-1] <<= 1;-
3059 p[-1] |= (*p & (128 >> i)) >> (7 - i);-
3060 }
never executed: end of block
0
3061 } else {
never executed: end of block
0
3062 for (int i = 0; i < shift; ++i) {
i < shiftDescription
TRUEnever evaluated
FALSEnever evaluated
0
3063 p[-1] >>= 1;-
3064 p[-1] |= (*p & (1 << i)) << (7 - i);-
3065 }
never executed: end of block
0
3066 }
never executed: end of block
0
3067 }-
3068 }
never executed: end of block
0
3069 if (shift != 8) {
shift != 8Description
TRUEnever evaluated
FALSEnever evaluated
0
3070 if (dst->format == QImage::Format_Mono)
dst->format ==...e::Format_MonoDescription
TRUEnever evaluated
FALSEnever evaluated
0
3071 end[-1] <<= shift;
never executed: end[-1] <<= shift;
0
3072 else-
3073 end[-1] >>= shift;
never executed: end[-1] >>= shift;
0
3074 }-
3075 }
never executed: end of block
0
3076 }
never executed: end of block
0
3077}
never executed: end of block
0
3078-
3079/*!-
3080 \internal-
3081*/-
3082QImage QImage::mirrored_helper(bool horizontal, bool vertical) const-
3083{-
3084 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3085 return QImage();
never executed: return QImage();
0
3086-
3087 if ((d->width <= 1 && d->height <= 1) || (!horizontal && !vertical))
d->width <= 1Description
TRUEnever evaluated
FALSEnever evaluated
d->height <= 1Description
TRUEnever evaluated
FALSEnever evaluated
!horizontalDescription
TRUEnever evaluated
FALSEnever evaluated
!verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
3088 return *this;
never executed: return *this;
0
3089-
3090 // Create result image, copy colormap-
3091 QImage result(d->width, d->height, d->format);-
3092 QIMAGE_SANITYCHECK_MEMORY(result);
never executed: return QImage();
(result).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3093-
3094 // check if we ran out of of memory..-
3095 if (!result.d)
!result.dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3096 return QImage();
never executed: return QImage();
0
3097-
3098 result.d->colortable = d->colortable;-
3099 result.d->has_alpha_clut = d->has_alpha_clut;-
3100 copyMetadata(result.d, d);-
3101-
3102 do_mirror(result.d, d, horizontal, vertical);-
3103-
3104 return result;
never executed: return result;
0
3105}-
3106-
3107/*!-
3108 \internal-
3109*/-
3110void QImage::mirrored_inplace(bool horizontal, bool vertical)-
3111{-
3112 if (!d || (d->width <= 1 && d->height <= 1) || (!horizontal && !vertical))
!dDescription
TRUEnever evaluated
FALSEnever evaluated
d->width <= 1Description
TRUEnever evaluated
FALSEnever evaluated
d->height <= 1Description
TRUEnever evaluated
FALSEnever evaluated
!horizontalDescription
TRUEnever evaluated
FALSEnever evaluated
!verticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
3113 return;
never executed: return;
0
3114-
3115 detach();-
3116 if (!d->own_data)
!d->own_dataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3117 *this = copy();
never executed: *this = copy();
0
3118-
3119 do_mirror(d, d, horizontal, vertical);-
3120}
never executed: end of block
0
3121-
3122/*!-
3123 \fn QImage QImage::rgbSwapped() const-
3124 Returns a QImage in which the values of the red and blue-
3125 components of all pixels have been swapped, effectively converting-
3126 an RGB image to an BGR image.-
3127-
3128 The original QImage is not changed.-
3129-
3130 \sa {QImage#Image Transformations}{Image Transformations}-
3131*/-
3132-
3133inline void rgbSwapped_generic(int width, int height, const QImage *src, QImage *dst, const QPixelLayout* layout)-
3134{-
3135 Q_ASSERT(layout->redWidth == layout->blueWidth);-
3136 FetchPixelsFunc fetch = qFetchPixels[layout->bpp];-
3137 StorePixelsFunc store = qStorePixels[layout->bpp];-
3138-
3139 const uint redBlueMask = (1 << layout->redWidth) - 1;-
3140 const uint alphaGreenMask = (((1 << layout->alphaWidth) - 1) << layout->alphaShift)-
3141 | (((1 << layout->greenWidth) - 1) << layout->greenShift);-
3142-
3143 const int buffer_size = 2048;-
3144 uint buffer[buffer_size];-
3145 for (int i = 0; i < height; ++i) {
i < heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
3146 uchar *q = dst->scanLine(i);-
3147 const uchar *p = src->constScanLine(i);-
3148 int x = 0;-
3149 while (x < width) {
x < widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
3150 int l = qMin(width - x, buffer_size);-
3151 const uint *ptr = fetch(buffer, p, x, l);-
3152 for (int j = 0; j < l; ++j) {
j < lDescription
TRUEnever evaluated
FALSEnever evaluated
0
3153 uint red = (ptr[j] >> layout->redShift) & redBlueMask;-
3154 uint blue = (ptr[j] >> layout->blueShift) & redBlueMask;-
3155 buffer[j] = (ptr[j] & alphaGreenMask)-
3156 | (red << layout->blueShift)-
3157 | (blue << layout->redShift);-
3158 }
never executed: end of block
0
3159 store(q, buffer, x, l);-
3160 x += l;-
3161 }
never executed: end of block
0
3162 }
never executed: end of block
0
3163}
never executed: end of block
0
3164-
3165/*!-
3166 \internal-
3167*/-
3168QImage QImage::rgbSwapped_helper() const-
3169{-
3170 if (isNull())
isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3171 return *this;
never executed: return *this;
0
3172-
3173 QImage res;-
3174-
3175 switch (d->format) {-
3176 case Format_Invalid:
never executed: case Format_Invalid:
0
3177 case NImageFormats:
never executed: case NImageFormats:
0
3178 Q_ASSERT(false);-
3179 break;
never executed: break;
0
3180 case Format_Alpha8:
never executed: case Format_Alpha8:
0
3181 case Format_Grayscale8:
never executed: case Format_Grayscale8:
0
3182 return *this;
never executed: return *this;
0
3183 case Format_Mono:
never executed: case Format_Mono:
0
3184 case Format_MonoLSB:
never executed: case Format_MonoLSB:
0
3185 case Format_Indexed8:
never executed: case Format_Indexed8:
0
3186 res = copy();-
3187 for (int i = 0; i < res.d->colortable.size(); i++) {
i < res.d->colortable.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
3188 QRgb c = res.d->colortable.at(i);-
3189 res.d->colortable[i] = QRgb(((c << 16) & 0xff0000) | ((c >> 16) & 0xff) | (c & 0xff00ff00));-
3190 }
never executed: end of block
0
3191 break;
never executed: break;
0
3192 case Format_RGB32:
never executed: case Format_RGB32:
0
3193 case Format_ARGB32:
never executed: case Format_ARGB32:
0
3194 case Format_ARGB32_Premultiplied:
never executed: case Format_ARGB32_Premultiplied:
0
3195#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN-
3196 case Format_RGBX8888:
never executed: case Format_RGBX8888:
0
3197 case Format_RGBA8888:
never executed: case Format_RGBA8888:
0
3198 case Format_RGBA8888_Premultiplied:
never executed: case Format_RGBA8888_Premultiplied:
0
3199#endif-
3200 res = QImage(d->width, d->height, d->format);-
3201 QIMAGE_SANITYCHECK_MEMORY(res);
never executed: return QImage();
(res).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3202 for (int i = 0; i < d->height; i++) {
i < d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
3203 uint *q = (uint*)res.scanLine(i);-
3204 const uint *p = (const uint*)constScanLine(i);-
3205 const uint *end = p + d->width;-
3206 while (p < end) {
p < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
3207 uint c = *p;-
3208 *q = ((c << 16) & 0xff0000) | ((c >> 16) & 0xff) | (c & 0xff00ff00);-
3209 p++;-
3210 q++;-
3211 }
never executed: end of block
0
3212 }
never executed: end of block
0
3213 break;
never executed: break;
0
3214 case Format_RGB16:
never executed: case Format_RGB16:
0
3215 res = QImage(d->width, d->height, d->format);-
3216 QIMAGE_SANITYCHECK_MEMORY(res);
never executed: return QImage();
(res).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3217 for (int i = 0; i < d->height; i++) {
i < d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
3218 ushort *q = (ushort*)res.scanLine(i);-
3219 const ushort *p = (const ushort*)constScanLine(i);-
3220 const ushort *end = p + d->width;-
3221 while (p < end) {
p < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
3222 ushort c = *p;-
3223 *q = ((c << 11) & 0xf800) | ((c >> 11) & 0x1f) | (c & 0x07e0);-
3224 p++;-
3225 q++;-
3226 }
never executed: end of block
0
3227 }
never executed: end of block
0
3228 break;
never executed: break;
0
3229 case Format_BGR30:
never executed: case Format_BGR30:
0
3230 case Format_A2BGR30_Premultiplied:
never executed: case Format_A2BGR30_Premultiplied:
0
3231 case Format_RGB30:
never executed: case Format_RGB30:
0
3232 case Format_A2RGB30_Premultiplied:
never executed: case Format_A2RGB30_Premultiplied:
0
3233 res = QImage(d->width, d->height, d->format);-
3234 QIMAGE_SANITYCHECK_MEMORY(res);
never executed: return QImage();
(res).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3235 for (int i = 0; i < d->height; i++) {
i < d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
3236 uint *q = (uint*)res.scanLine(i);-
3237 const uint *p = (const uint*)constScanLine(i);-
3238 const uint *end = p + d->width;-
3239 while (p < end) {
p < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
3240 *q = qRgbSwapRgb30(*p);-
3241 p++;-
3242 q++;-
3243 }
never executed: end of block
0
3244 }
never executed: end of block
0
3245 break;
never executed: break;
0
3246 default:
never executed: default:
0
3247 res = QImage(d->width, d->height, d->format);-
3248 rgbSwapped_generic(d->width, d->height, this, &res, &qPixelLayouts[d->format]);-
3249 break;
never executed: break;
0
3250 }-
3251 copyMetadata(res.d, d);-
3252 return res;
never executed: return res;
0
3253}-
3254-
3255/*!-
3256 \internal-
3257*/-
3258void QImage::rgbSwapped_inplace()-
3259{-
3260 if (isNull())
isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3261 return;
never executed: return;
0
3262-
3263 detach();-
3264 if (!d->own_data)
!d->own_dataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3265 *this = copy();
never executed: *this = copy();
0
3266-
3267 switch (d->format) {-
3268 case Format_Invalid:
never executed: case Format_Invalid:
0
3269 case NImageFormats:
never executed: case NImageFormats:
0
3270 Q_ASSERT(false);-
3271 break;
never executed: break;
0
3272 case Format_Alpha8:
never executed: case Format_Alpha8:
0
3273 case Format_Grayscale8:
never executed: case Format_Grayscale8:
0
3274 return;
never executed: return;
0
3275 case Format_Mono:
never executed: case Format_Mono:
0
3276 case Format_MonoLSB:
never executed: case Format_MonoLSB:
0
3277 case Format_Indexed8:
never executed: case Format_Indexed8:
0
3278 for (int i = 0; i < d->colortable.size(); i++) {
i < d->colortable.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
3279 QRgb c = d->colortable.at(i);-
3280 d->colortable[i] = QRgb(((c << 16) & 0xff0000) | ((c >> 16) & 0xff) | (c & 0xff00ff00));-
3281 }
never executed: end of block
0
3282 break;
never executed: break;
0
3283 case Format_RGB32:
never executed: case Format_RGB32:
0
3284 case Format_ARGB32:
never executed: case Format_ARGB32:
0
3285 case Format_ARGB32_Premultiplied:
never executed: case Format_ARGB32_Premultiplied:
0
3286#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN-
3287 case Format_RGBX8888:
never executed: case Format_RGBX8888:
0
3288 case Format_RGBA8888:
never executed: case Format_RGBA8888:
0
3289 case Format_RGBA8888_Premultiplied:
never executed: case Format_RGBA8888_Premultiplied:
0
3290#endif-
3291 for (int i = 0; i < d->height; i++) {
i < d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
3292 uint *p = (uint*)scanLine(i);-
3293 uint *end = p + d->width;-
3294 while (p < end) {
p < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
3295 uint c = *p;-
3296 *p = ((c << 16) & 0xff0000) | ((c >> 16) & 0xff) | (c & 0xff00ff00);-
3297 p++;-
3298 }
never executed: end of block
0
3299 }
never executed: end of block
0
3300 break;
never executed: break;
0
3301 case Format_RGB16:
never executed: case Format_RGB16:
0
3302 for (int i = 0; i < d->height; i++) {
i < d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
3303 ushort *p = (ushort*)scanLine(i);-
3304 ushort *end = p + d->width;-
3305 while (p < end) {
p < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
3306 ushort c = *p;-
3307 *p = ((c << 11) & 0xf800) | ((c >> 11) & 0x1f) | (c & 0x07e0);-
3308 p++;-
3309 }
never executed: end of block
0
3310 }
never executed: end of block
0
3311 break;
never executed: break;
0
3312 case Format_BGR30:
never executed: case Format_BGR30:
0
3313 case Format_A2BGR30_Premultiplied:
never executed: case Format_A2BGR30_Premultiplied:
0
3314 case Format_RGB30:
never executed: case Format_RGB30:
0
3315 case Format_A2RGB30_Premultiplied:
never executed: case Format_A2RGB30_Premultiplied:
0
3316 for (int i = 0; i < d->height; i++) {
i < d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
3317 uint *p = (uint*)scanLine(i);-
3318 uint *end = p + d->width;-
3319 while (p < end) {
p < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
3320 *p = qRgbSwapRgb30(*p);-
3321 p++;-
3322 }
never executed: end of block
0
3323 }
never executed: end of block
0
3324 break;
never executed: break;
0
3325 default:
never executed: default:
0
3326 rgbSwapped_generic(d->width, d->height, this, this, &qPixelLayouts[d->format]);-
3327 break;
never executed: break;
0
3328 }-
3329}-
3330-
3331/*!-
3332 Loads an image from the file with the given \a fileName. Returns \c true if-
3333 the image was successfully loaded; otherwise invalidates the image-
3334 and returns \c false.-
3335-
3336 The loader attempts to read the image using the specified \a format, e.g.,-
3337 PNG or JPG. If \a format is not specified (which is the default), the-
3338 loader probes the file for a header to guess the file format.-
3339-
3340 The file name can either refer to an actual file on disk or to one-
3341 of the application's embedded resources. See the-
3342 \l{resources.html}{Resource System} overview for details on how to-
3343 embed images and other resource files in the application's-
3344 executable.-
3345-
3346 \sa {QImage#Reading and Writing Image Files}{Reading and Writing Image Files}-
3347*/-
3348-
3349bool QImage::load(const QString &fileName, const char* format)-
3350{-
3351 QImage image = QImageReader(fileName, format).read();-
3352 operator=(image);-
3353 return !isNull();
never executed: return !isNull();
0
3354}-
3355-
3356/*!-
3357 \overload-
3358-
3359 This function reads a QImage from the given \a device. This can,-
3360 for example, be used to load an image directly into a QByteArray.-
3361*/-
3362-
3363bool QImage::load(QIODevice* device, const char* format)-
3364{-
3365 QImage image = QImageReader(device, format).read();-
3366 operator=(image);-
3367 return !isNull();
never executed: return !isNull();
0
3368}-
3369-
3370/*!-
3371 \fn bool QImage::loadFromData(const uchar *data, int len, const char *format)-
3372-
3373 Loads an image from the first \a len bytes of the given binary \a-
3374 data. Returns \c true if the image was successfully loaded; otherwise-
3375 invalidates the image and returns \c false.-
3376-
3377 The loader attempts to read the image using the specified \a format, e.g.,-
3378 PNG or JPG. If \a format is not specified (which is the default), the-
3379 loader probes the file for a header to guess the file format.-
3380-
3381 \sa {QImage#Reading and Writing Image Files}{Reading and Writing Image Files}-
3382*/-
3383-
3384bool QImage::loadFromData(const uchar *data, int len, const char *format)-
3385{-
3386 QImage image = fromData(data, len, format);-
3387 operator=(image);-
3388 return !isNull();
never executed: return !isNull();
0
3389}-
3390-
3391/*!-
3392 \fn bool QImage::loadFromData(const QByteArray &data, const char *format)-
3393-
3394 \overload-
3395-
3396 Loads an image from the given QByteArray \a data.-
3397*/-
3398-
3399/*!-
3400 \fn QImage QImage::fromData(const uchar *data, int size, const char *format)-
3401-
3402 Constructs a QImage from the first \a size bytes of the given-
3403 binary \a data. The loader attempts to read the image using the-
3404 specified \a format. If \a format is not specified (which is the default),-
3405 the loader probes the file for a header to guess the file format.-
3406 binary \a data. The loader attempts to read the image, either using the-
3407 optional image \a format specified or by determining the image format from-
3408 the data.-
3409-
3410 If \a format is not specified (which is the default), the loader probes the-
3411 file for a header to determine the file format. If \a format is specified,-
3412 it must be one of the values returned by QImageReader::supportedImageFormats().-
3413-
3414 If the loading of the image fails, the image returned will be a null image.-
3415-
3416 \sa load(), save(), {QImage#Reading and Writing Image Files}{Reading and Writing Image Files}-
3417 */-
3418-
3419QImage QImage::fromData(const uchar *data, int size, const char *format)-
3420{-
3421 QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(data), size);-
3422 QBuffer b;-
3423 b.setData(a);-
3424 b.open(QIODevice::ReadOnly);-
3425 return QImageReader(&b, format).read();
never executed: return QImageReader(&b, format).read();
0
3426}-
3427-
3428/*!-
3429 \fn QImage QImage::fromData(const QByteArray &data, const char *format)-
3430-
3431 \overload-
3432-
3433 Loads an image from the given QByteArray \a data.-
3434*/-
3435-
3436/*!-
3437 Saves the image to the file with the given \a fileName, using the-
3438 given image file \a format and \a quality factor. If \a format is-
3439 0, QImage will attempt to guess the format by looking at \a fileName's-
3440 suffix.-
3441-
3442 The \a quality factor must be in the range 0 to 100 or -1. Specify-
3443 0 to obtain small compressed files, 100 for large uncompressed-
3444 files, and -1 (the default) to use the default settings.-
3445-
3446 Returns \c true if the image was successfully saved; otherwise-
3447 returns \c false.-
3448-
3449 \sa {QImage#Reading and Writing Image Files}{Reading and Writing-
3450 Image Files}-
3451*/-
3452bool QImage::save(const QString &fileName, const char *format, int quality) const-
3453{-
3454 if (isNull())
isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3455 return false;
never executed: return false;
0
3456 QImageWriter writer(fileName, format);-
3457 return d->doImageIO(this, &writer, quality);
never executed: return d->doImageIO(this, &writer, quality);
0
3458}-
3459-
3460/*!-
3461 \overload-
3462-
3463 This function writes a QImage to the given \a device.-
3464-
3465 This can, for example, be used to save an image directly into a-
3466 QByteArray:-
3467-
3468 \snippet image/image.cpp 0-
3469*/-
3470-
3471bool QImage::save(QIODevice* device, const char* format, int quality) const-
3472{-
3473 if (isNull())
isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3474 return false; // nothing to save
never executed: return false;
0
3475 QImageWriter writer(device, format);-
3476 return d->doImageIO(this, &writer, quality);
never executed: return d->doImageIO(this, &writer, quality);
0
3477}-
3478-
3479/* \internal-
3480*/-
3481-
3482bool QImageData::doImageIO(const QImage *image, QImageWriter *writer, int quality) const-
3483{-
3484 if (quality > 100 || quality < -1)
quality > 100Description
TRUEnever evaluated
FALSEnever evaluated
quality < -1Description
TRUEnever evaluated
FALSEnever evaluated
0
3485 qWarning("QPixmap::save: Quality out of range [-1, 100]");
never executed: QMessageLogger(__FILE__, 3485, __PRETTY_FUNCTION__).warning("QPixmap::save: Quality out of range [-1, 100]");
0
3486 if (quality >= 0)
quality >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3487 writer->setQuality(qMin(quality,100));
never executed: writer->setQuality(qMin(quality,100));
0
3488 return writer->write(*image);
never executed: return writer->write(*image);
0
3489}-
3490-
3491/*****************************************************************************-
3492 QImage stream functions-
3493 *****************************************************************************/-
3494#if !defined(QT_NO_DATASTREAM)-
3495/*!-
3496 \fn QDataStream &operator<<(QDataStream &stream, const QImage &image)-
3497 \relates QImage-
3498-
3499 Writes the given \a image to the given \a stream as a PNG image,-
3500 or as a BMP image if the stream's version is 1. Note that writing-
3501 the stream to a file will not produce a valid image file.-
3502-
3503 \sa QImage::save(), {Serializing Qt Data Types}-
3504*/-
3505-
3506QDataStream &operator<<(QDataStream &s, const QImage &image)-
3507{-
3508 if (s.version() >= 5) {
s.version() >= 5Description
TRUEnever evaluated
FALSEnever evaluated
0
3509 if (image.isNull()) {
image.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3510 s << (qint32) 0; // null image marker-
3511 return s;
never executed: return s;
0
3512 } else {-
3513 s << (qint32) 1;-
3514 // continue ...-
3515 }
never executed: end of block
0
3516 }-
3517 QImageWriter writer(s.device(), s.version() == 1 ? "bmp" : "png");-
3518 writer.write(image);-
3519 return s;
never executed: return s;
0
3520}-
3521-
3522/*!-
3523 \fn QDataStream &operator>>(QDataStream &stream, QImage &image)-
3524 \relates QImage-
3525-
3526 Reads an image from the given \a stream and stores it in the given-
3527 \a image.-
3528-
3529 \sa QImage::load(), {Serializing Qt Data Types}-
3530*/-
3531-
3532QDataStream &operator>>(QDataStream &s, QImage &image)-
3533{-
3534 if (s.version() >= 5) {
s.version() >= 5Description
TRUEnever evaluated
FALSEnever evaluated
0
3535 qint32 nullMarker;-
3536 s >> nullMarker;-
3537 if (!nullMarker) {
!nullMarkerDescription
TRUEnever evaluated
FALSEnever evaluated
0
3538 image = QImage(); // null image-
3539 return s;
never executed: return s;
0
3540 }-
3541 }
never executed: end of block
0
3542 image = QImageReader(s.device(), 0).read();-
3543 return s;
never executed: return s;
0
3544}-
3545#endif // QT_NO_DATASTREAM-
3546-
3547-
3548-
3549/*!-
3550 \fn bool QImage::operator==(const QImage & image) const-
3551-
3552 Returns \c true if this image and the given \a image have the same-
3553 contents; otherwise returns \c false.-
3554-
3555 The comparison can be slow, unless there is some obvious-
3556 difference (e.g. different size or format), in which case the-
3557 function will return quickly.-
3558-
3559 \sa operator=()-
3560*/-
3561-
3562bool QImage::operator==(const QImage & i) const-
3563{-
3564 // same object, or shared?-
3565 if (i.d == d)
i.d == dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3566 return true;
never executed: return true;
0
3567 if (!i.d || !d)
!i.dDescription
TRUEnever evaluated
FALSEnever evaluated
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3568 return false;
never executed: return false;
0
3569-
3570 // obviously different stuff?-
3571 if (i.d->height != d->height || i.d->width != d->width || i.d->format != d->format)
i.d->height != d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
i.d->width != d->widthDescription
TRUEnever evaluated
FALSEnever evaluated
i.d->format != d->formatDescription
TRUEnever evaluated
FALSEnever evaluated
0
3572 return false;
never executed: return false;
0
3573-
3574 if (d->format != Format_RGB32) {
d->format != Format_RGB32Description
TRUEnever evaluated
FALSEnever evaluated
0
3575 if (d->format >= Format_ARGB32) { // all bits defined
d->format >= Format_ARGB32Description
TRUEnever evaluated
FALSEnever evaluated
0
3576 const int n = d->width * d->depth / 8;-
3577 if (n == d->bytes_per_line && n == i.d->bytes_per_line) {
n == d->bytes_per_lineDescription
TRUEnever evaluated
FALSEnever evaluated
n == i.d->bytes_per_lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3578 if (memcmp(bits(), i.bits(), d->nbytes))
memcmp(bits(),...(), d->nbytes)Description
TRUEnever evaluated
FALSEnever evaluated
0
3579 return false;
never executed: return false;
0
3580 } else {
never executed: end of block
0
3581 for (int y = 0; y < d->height; ++y) {
y < d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
3582 if (memcmp(scanLine(y), i.scanLine(y), n))
memcmp(scanLin...canLine(y), n)Description
TRUEnever evaluated
FALSEnever evaluated
0
3583 return false;
never executed: return false;
0
3584 }
never executed: end of block
0
3585 }
never executed: end of block
0
3586 } else {-
3587 const int w = width();-
3588 const int h = height();-
3589 const QVector<QRgb> &colortable = d->colortable;-
3590 const QVector<QRgb> &icolortable = i.d->colortable;-
3591 for (int y=0; y<h; ++y) {
y<hDescription
TRUEnever evaluated
FALSEnever evaluated
0
3592 for (int x=0; x<w; ++x) {
x<wDescription
TRUEnever evaluated
FALSEnever evaluated
0
3593 if (colortable[pixelIndex(x, y)] != icolortable[i.pixelIndex(x, y)])
colortable[pix...elIndex(x, y)]Description
TRUEnever evaluated
FALSEnever evaluated
0
3594 return false;
never executed: return false;
0
3595 }
never executed: end of block
0
3596 }
never executed: end of block
0
3597 }
never executed: end of block
0
3598 } else {-
3599 //alpha channel undefined, so we must mask it out-
3600 for(int l = 0; l < d->height; l++) {
l < d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
3601 int w = d->width;-
3602 const uint *p1 = reinterpret_cast<const uint*>(scanLine(l));-
3603 const uint *p2 = reinterpret_cast<const uint*>(i.scanLine(l));-
3604 while (w--) {
w--Description
TRUEnever evaluated
FALSEnever evaluated
0
3605 if ((*p1++ & 0x00ffffff) != (*p2++ & 0x00ffffff))
(*p1++ & 0x00f... & 0x00ffffff)Description
TRUEnever evaluated
FALSEnever evaluated
0
3606 return false;
never executed: return false;
0
3607 }
never executed: end of block
0
3608 }
never executed: end of block
0
3609 }
never executed: end of block
0
3610 return true;
never executed: return true;
0
3611}-
3612-
3613-
3614/*!-
3615 \fn bool QImage::operator!=(const QImage & image) const-
3616-
3617 Returns \c true if this image and the given \a image have different-
3618 contents; otherwise returns \c false.-
3619-
3620 The comparison can be slow, unless there is some obvious-
3621 difference, such as different widths, in which case the function-
3622 will return quickly.-
3623-
3624 \sa operator=()-
3625*/-
3626-
3627bool QImage::operator!=(const QImage & i) const-
3628{-
3629 return !(*this == i);
never executed: return !(*this == i);
0
3630}-
3631-
3632-
3633-
3634-
3635/*!-
3636 Returns the number of pixels that fit horizontally in a physical-
3637 meter. Together with dotsPerMeterY(), this number defines the-
3638 intended scale and aspect ratio of the image.-
3639-
3640 \sa setDotsPerMeterX(), {QImage#Image Information}{Image-
3641 Information}-
3642*/-
3643int QImage::dotsPerMeterX() const-
3644{-
3645 return d ? qRound(d->dpmx) : 0;
never executed: return d ? qRound(d->dpmx) : 0;
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3646}-
3647-
3648/*!-
3649 Returns the number of pixels that fit vertically in a physical-
3650 meter. Together with dotsPerMeterX(), this number defines the-
3651 intended scale and aspect ratio of the image.-
3652-
3653 \sa setDotsPerMeterY(), {QImage#Image Information}{Image-
3654 Information}-
3655*/-
3656int QImage::dotsPerMeterY() const-
3657{-
3658 return d ? qRound(d->dpmy) : 0;
never executed: return d ? qRound(d->dpmy) : 0;
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3659}-
3660-
3661/*!-
3662 Sets the number of pixels that fit horizontally in a physical-
3663 meter, to \a x.-
3664-
3665 Together with dotsPerMeterY(), this number defines the intended-
3666 scale and aspect ratio of the image, and determines the scale-
3667 at which QPainter will draw graphics on the image. It does not-
3668 change the scale or aspect ratio of the image when it is rendered-
3669 on other paint devices.-
3670-
3671 \sa dotsPerMeterX(), {QImage#Image Information}{Image Information}-
3672*/-
3673void QImage::setDotsPerMeterX(int x)-
3674{-
3675 if (!d || !x)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
!xDescription
TRUEnever evaluated
FALSEnever evaluated
0
3676 return;
never executed: return;
0
3677 detach();-
3678-
3679 if (d)
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3680 d->dpmx = x;
never executed: d->dpmx = x;
0
3681}
never executed: end of block
0
3682-
3683/*!-
3684 Sets the number of pixels that fit vertically in a physical meter,-
3685 to \a y.-
3686-
3687 Together with dotsPerMeterX(), this number defines the intended-
3688 scale and aspect ratio of the image, and determines the scale-
3689 at which QPainter will draw graphics on the image. It does not-
3690 change the scale or aspect ratio of the image when it is rendered-
3691 on other paint devices.-
3692-
3693 \sa dotsPerMeterY(), {QImage#Image Information}{Image Information}-
3694*/-
3695void QImage::setDotsPerMeterY(int y)-
3696{-
3697 if (!d || !y)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
!yDescription
TRUEnever evaluated
FALSEnever evaluated
0
3698 return;
never executed: return;
0
3699 detach();-
3700-
3701 if (d)
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3702 d->dpmy = y;
never executed: d->dpmy = y;
0
3703}
never executed: end of block
0
3704-
3705/*!-
3706 \fn QPoint QImage::offset() const-
3707-
3708 Returns the number of pixels by which the image is intended to be-
3709 offset by when positioning relative to other images.-
3710-
3711 \sa setOffset(), {QImage#Image Information}{Image Information}-
3712*/-
3713QPoint QImage::offset() const-
3714{-
3715 return d ? d->offset : QPoint();
never executed: return d ? d->offset : QPoint();
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3716}-
3717-
3718-
3719/*!-
3720 \fn void QImage::setOffset(const QPoint& offset)-
3721-
3722 Sets the number of pixels by which the image is intended to be-
3723 offset by when positioning relative to other images, to \a offset.-
3724-
3725 \sa offset(), {QImage#Image Information}{Image Information}-
3726*/-
3727void QImage::setOffset(const QPoint& p)-
3728{-
3729 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3730 return;
never executed: return;
0
3731 detach();-
3732-
3733 if (d)
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3734 d->offset = p;
never executed: d->offset = p;
0
3735}
never executed: end of block
0
3736-
3737/*!-
3738 Returns the text keys for this image.-
3739-
3740 You can use these keys with text() to list the image text for a-
3741 certain key.-
3742-
3743 \sa text()-
3744*/-
3745QStringList QImage::textKeys() const-
3746{-
3747 return d ? QStringList(d->text.keys()) : QStringList();
never executed: return d ? QStringList(d->text.keys()) : QStringList();
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3748}-
3749-
3750/*!-
3751 Returns the image text associated with the given \a key. If the-
3752 specified \a key is an empty string, the whole image text is-
3753 returned, with each key-text pair separated by a newline.-
3754-
3755 \sa setText(), textKeys()-
3756*/-
3757QString QImage::text(const QString &key) const-
3758{-
3759 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3760 return QString();
never executed: return QString();
0
3761-
3762 if (!key.isEmpty())
!key.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3763 return d->text.value(key);
never executed: return d->text.value(key);
0
3764-
3765 QString tmp;-
3766 foreach (const QString &key, d->text.keys()) {-
3767 if (!tmp.isEmpty())
!tmp.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3768 tmp += QLatin1String("\n\n");
never executed: tmp += QLatin1String("\n\n");
0
3769 tmp += key + QLatin1String(": ") + d->text.value(key).simplified();-
3770 }
never executed: end of block
0
3771 return tmp;
never executed: return tmp;
0
3772}-
3773-
3774/*!-
3775 \fn void QImage::setText(const QString &key, const QString &text)-
3776-
3777 Sets the image text to the given \a text and associate it with the-
3778 given \a key.-
3779-
3780 If you just want to store a single text block (i.e., a "comment"-
3781 or just a description), you can either pass an empty key, or use a-
3782 generic key like "Description".-
3783-
3784 The image text is embedded into the image data when you-
3785 call save() or QImageWriter::write().-
3786-
3787 Not all image formats support embedded text. You can find out-
3788 if a specific image or format supports embedding text-
3789 by using QImageWriter::supportsOption(). We give an example:-
3790-
3791 \snippet image/supportedformat.cpp 0-
3792-
3793 You can use QImageWriter::supportedImageFormats() to find out-
3794 which image formats are available to you.-
3795-
3796 \sa text(), textKeys()-
3797*/-
3798void QImage::setText(const QString &key, const QString &value)-
3799{-
3800 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3801 return;
never executed: return;
0
3802 detach();-
3803-
3804 if (d)
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3805 d->text.insert(key, value);
never executed: d->text.insert(key, value);
0
3806}
never executed: end of block
0
3807-
3808/*!-
3809 \fn QString QImage::text(const char* key, const char* language) const-
3810 \obsolete-
3811-
3812 Returns the text recorded for the given \a key in the given \a-
3813 language, or in a default language if \a language is 0.-
3814-
3815 Use text() instead.-
3816-
3817 The language the text is recorded in is no longer relevant since-
3818 the text is always set using QString and UTF-8 representation.-
3819*/-
3820-
3821/*!-
3822 \fn QString QImage::text(const QImageTextKeyLang& keywordAndLanguage) const-
3823 \overload-
3824 \obsolete-
3825-
3826 Returns the text recorded for the given \a keywordAndLanguage.-
3827-
3828 Use text() instead.-
3829-
3830 The language the text is recorded in is no longer relevant since-
3831 the text is always set using QString and UTF-8 representation.-
3832*/-
3833-
3834/*!-
3835 \fn void QImage::setText(const char* key, const char* language, const QString& text)-
3836 \obsolete-
3837-
3838 Sets the image text to the given \a text and associate it with the-
3839 given \a key. The text is recorded in the specified \a language,-
3840 or in a default language if \a language is 0.-
3841-
3842 Use setText() instead.-
3843-
3844 The language the text is recorded in is no longer relevant since-
3845 the text is always set using QString and UTF-8 representation.-
3846-
3847 \omit-
3848 Records string \a for the keyword \a key. The \a key should be-
3849 a portable keyword recognizable by other software - some suggested-
3850 values can be found in-
3851 \l{http://www.libpng.org/pub/png/spec/1.2/png-1.2-pdg.html#C.Anc-text}-
3852 {the PNG specification}. \a s can be any text. \a lang should-
3853 specify the language code (see-
3854 \l{http://www.rfc-editor.org/rfc/rfc1766.txt}{RFC 1766}) or 0.-
3855 \endomit-
3856*/-
3857-
3858/*-
3859 Sets the image bits to the \a pixmap contents and returns a-
3860 reference to the image.-
3861-
3862 If the image shares data with other images, it will first-
3863 dereference the shared data.-
3864-
3865 Makes a call to QPixmap::convertToImage().-
3866*/-
3867-
3868/*!-
3869 \internal-
3870-
3871 Used by QPainter to retrieve a paint engine for the image.-
3872*/-
3873-
3874QPaintEngine *QImage::paintEngine() const-
3875{-
3876 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3877 return 0;
never executed: return 0;
0
3878-
3879 if (!d->paintEngine) {
!d->paintEngineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3880 QPaintDevice *paintDevice = const_cast<QImage *>(this);-
3881 QPaintEngine *paintEngine = 0;-
3882 QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration();-
3883 if (platformIntegration)
platformIntegrationDescription
TRUEnever evaluated
FALSEnever evaluated
0
3884 paintEngine = platformIntegration->createImagePaintEngine(paintDevice);
never executed: paintEngine = platformIntegration->createImagePaintEngine(paintDevice);
0
3885 d->paintEngine = paintEngine ? paintEngine : new QRasterPaintEngine(paintDevice);
paintEngineDescription
TRUEnever evaluated
FALSEnever evaluated
0
3886 }
never executed: end of block
0
3887-
3888 return d->paintEngine;
never executed: return d->paintEngine;
0
3889}-
3890-
3891-
3892/*!-
3893 \internal-
3894-
3895 Returns the size for the specified \a metric on the device.-
3896*/-
3897int QImage::metric(PaintDeviceMetric metric) const-
3898{-
3899 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
3900 return 0;
never executed: return 0;
0
3901-
3902 switch (metric) {-
3903 case PdmWidth:
never executed: case PdmWidth:
0
3904 return d->width;
never executed: return d->width;
0
3905-
3906 case PdmHeight:
never executed: case PdmHeight:
0
3907 return d->height;
never executed: return d->height;
0
3908-
3909 case PdmWidthMM:
never executed: case PdmWidthMM:
0
3910 return qRound(d->width * 1000 / d->dpmx);
never executed: return qRound(d->width * 1000 / d->dpmx);
0
3911-
3912 case PdmHeightMM:
never executed: case PdmHeightMM:
0
3913 return qRound(d->height * 1000 / d->dpmy);
never executed: return qRound(d->height * 1000 / d->dpmy);
0
3914-
3915 case PdmNumColors:
never executed: case PdmNumColors:
0
3916 return d->colortable.size();
never executed: return d->colortable.size();
0
3917-
3918 case PdmDepth:
never executed: case PdmDepth:
0
3919 return d->depth;
never executed: return d->depth;
0
3920-
3921 case PdmDpiX:
never executed: case PdmDpiX:
0
3922 return qRound(d->dpmx * 0.0254);
never executed: return qRound(d->dpmx * 0.0254);
0
3923 break;
dead code: break;
-
3924-
3925 case PdmDpiY:
never executed: case PdmDpiY:
0
3926 return qRound(d->dpmy * 0.0254);
never executed: return qRound(d->dpmy * 0.0254);
0
3927 break;
dead code: break;
-
3928-
3929 case PdmPhysicalDpiX:
never executed: case PdmPhysicalDpiX:
0
3930 return qRound(d->dpmx * 0.0254);
never executed: return qRound(d->dpmx * 0.0254);
0
3931 break;
dead code: break;
-
3932-
3933 case PdmPhysicalDpiY:
never executed: case PdmPhysicalDpiY:
0
3934 return qRound(d->dpmy * 0.0254);
never executed: return qRound(d->dpmy * 0.0254);
0
3935 break;
dead code: break;
-
3936-
3937 case PdmDevicePixelRatio:
never executed: case PdmDevicePixelRatio:
0
3938 return d->devicePixelRatio;
never executed: return d->devicePixelRatio;
0
3939 break;
dead code: break;
-
3940-
3941 case PdmDevicePixelRatioScaled:
never executed: case PdmDevicePixelRatioScaled:
0
3942 return d->devicePixelRatio * QPaintDevice::devicePixelRatioFScale();
never executed: return d->devicePixelRatio * QPaintDevice::devicePixelRatioFScale();
0
3943 break;
dead code: break;
-
3944-
3945 default:
never executed: default:
0
3946 qWarning("QImage::metric(): Unhandled metric type %d", metric);-
3947 break;
never executed: break;
0
3948 }-
3949 return 0;
never executed: return 0;
0
3950}-
3951-
3952-
3953-
3954/*****************************************************************************-
3955 QPixmap (and QImage) helper functions-
3956 *****************************************************************************/-
3957/*-
3958 This internal function contains the common (i.e. platform independent) code-
3959 to do a transformation of pixel data. It is used by QPixmap::transform() and by-
3960 QImage::transform().-
3961-
3962 \a trueMat is the true transformation matrix (see QPixmap::trueMatrix()) and-
3963 \a xoffset is an offset to the matrix.-
3964-
3965 \a msbfirst specifies for 1bpp images, if the MSB or LSB comes first and \a-
3966 depth specifies the colordepth of the data.-
3967-
3968 \a dptr is a pointer to the destination data, \a dbpl specifies the bits per-
3969 line for the destination data, \a p_inc is the offset that we advance for-
3970 every scanline and \a dHeight is the height of the destination image.-
3971-
3972 \a sprt is the pointer to the source data, \a sbpl specifies the bits per-
3973 line of the source data, \a sWidth and \a sHeight are the width and height of-
3974 the source data.-
3975*/-
3976-
3977#undef IWX_MSB-
3978#define IWX_MSB(b) if (trigx < maxws && trigy < maxhs) { \-
3979 if (*(sptr+sbpl*(trigy>>12)+(trigx>>15)) & \-
3980 (1 << (7-((trigx>>12)&7)))) \-
3981 *dptr |= b; \-
3982 } \-
3983 trigx += m11; \-
3984 trigy += m12;-
3985 // END OF MACRO-
3986#undef IWX_LSB-
3987#define IWX_LSB(b) if (trigx < maxws && trigy < maxhs) { \-
3988 if (*(sptr+sbpl*(trigy>>12)+(trigx>>15)) & \-
3989 (1 << ((trigx>>12)&7))) \-
3990 *dptr |= b; \-
3991 } \-
3992 trigx += m11; \-
3993 trigy += m12;-
3994 // END OF MACRO-
3995#undef IWX_PIX-
3996#define IWX_PIX(b) if (trigx < maxws && trigy < maxhs) { \-
3997 if ((*(sptr+sbpl*(trigy>>12)+(trigx>>15)) & \-
3998 (1 << (7-((trigx>>12)&7)))) == 0) \-
3999 *dptr &= ~b; \-
4000 } \-
4001 trigx += m11; \-
4002 trigy += m12;-
4003 // END OF MACRO-
4004bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth,-
4005 uchar *dptr, int dbpl, int p_inc, int dHeight,-
4006 const uchar *sptr, int sbpl, int sWidth, int sHeight)-
4007{-
4008 int m11 = int(trueMat.m11()*4096.0);-
4009 int m12 = int(trueMat.m12()*4096.0);-
4010 int m21 = int(trueMat.m21()*4096.0);-
4011 int m22 = int(trueMat.m22()*4096.0);-
4012 int dx = qRound(trueMat.dx()*4096.0);-
4013 int dy = qRound(trueMat.dy()*4096.0);-
4014-
4015 int m21ydx = dx + (xoffset<<16) + (m11 + m21) / 2;-
4016 int m22ydy = dy + (m12 + m22) / 2;-
4017 uint trigx;-
4018 uint trigy;-
4019 uint maxws = sWidth<<12;-
4020 uint maxhs = sHeight<<12;-
4021-
4022 for (int y=0; y<dHeight; y++) { // for each target scanline
y<dHeightDescription
TRUEnever evaluated
FALSEnever evaluated
0
4023 trigx = m21ydx;-
4024 trigy = m22ydy;-
4025 uchar *maxp = dptr + dbpl;-
4026 if (depth != 1) {
depth != 1Description
TRUEnever evaluated
FALSEnever evaluated
0
4027 switch (depth) {-
4028 case 8: // 8 bpp transform
never executed: case 8:
0
4029 while (dptr < maxp) {
dptr < maxpDescription
TRUEnever evaluated
FALSEnever evaluated
0
4030 if (trigx < maxws && trigy < maxhs)
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4031 *dptr = *(sptr+sbpl*(trigy>>12)+(trigx>>12));
never executed: *dptr = *(sptr+sbpl*(trigy>>12)+(trigx>>12));
0
4032 trigx += m11;-
4033 trigy += m12;-
4034 dptr++;-
4035 }
never executed: end of block
0
4036 break;
never executed: break;
0
4037-
4038 case 16: // 16 bpp transform
never executed: case 16:
0
4039 while (dptr < maxp) {
dptr < maxpDescription
TRUEnever evaluated
FALSEnever evaluated
0
4040 if (trigx < maxws && trigy < maxhs)
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4041 *((ushort*)dptr) = *((const ushort *)(sptr+sbpl*(trigy>>12) +
never executed: *((ushort*)dptr) = *((const ushort *)(sptr+sbpl*(trigy>>12) + ((trigx>>12)<<1)));
0
4042 ((trigx>>12)<<1)));
never executed: *((ushort*)dptr) = *((const ushort *)(sptr+sbpl*(trigy>>12) + ((trigx>>12)<<1)));
0
4043 trigx += m11;-
4044 trigy += m12;-
4045 dptr++;-
4046 dptr++;-
4047 }
never executed: end of block
0
4048 break;
never executed: break;
0
4049-
4050 case 24: // 24 bpp transform
never executed: case 24:
0
4051 while (dptr < maxp) {
dptr < maxpDescription
TRUEnever evaluated
FALSEnever evaluated
0
4052 if (trigx < maxws && trigy < maxhs) {
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4053 const uchar *p2 = sptr+sbpl*(trigy>>12) + ((trigx>>12)*3);-
4054 dptr[0] = p2[0];-
4055 dptr[1] = p2[1];-
4056 dptr[2] = p2[2];-
4057 }
never executed: end of block
0
4058 trigx += m11;-
4059 trigy += m12;-
4060 dptr += 3;-
4061 }
never executed: end of block
0
4062 break;
never executed: break;
0
4063-
4064 case 32: // 32 bpp transform
never executed: case 32:
0
4065 while (dptr < maxp) {
dptr < maxpDescription
TRUEnever evaluated
FALSEnever evaluated
0
4066 if (trigx < maxws && trigy < maxhs)
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4067 *((uint*)dptr) = *((const uint *)(sptr+sbpl*(trigy>>12) +
never executed: *((uint*)dptr) = *((const uint *)(sptr+sbpl*(trigy>>12) + ((trigx>>12)<<2)));
0
4068 ((trigx>>12)<<2)));
never executed: *((uint*)dptr) = *((const uint *)(sptr+sbpl*(trigy>>12) + ((trigx>>12)<<2)));
0
4069 trigx += m11;-
4070 trigy += m12;-
4071 dptr += 4;-
4072 }
never executed: end of block
0
4073 break;
never executed: break;
0
4074-
4075 default: {
never executed: default:
0
4076 return false;
never executed: return false;
0
4077 }-
4078 }-
4079 } else {-
4080 switch (type) {-
4081 case QT_XFORM_TYPE_MSBFIRST:
never executed: case 0:
0
4082 while (dptr < maxp) {
dptr < maxpDescription
TRUEnever evaluated
FALSEnever evaluated
0
4083 IWX_MSB(128);
never executed: *dptr |= 128;
never executed: end of block
*(sptr+sbpl*(t...rigx>>12)&7)))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4084 IWX_MSB(64);
never executed: *dptr |= 64;
never executed: end of block
*(sptr+sbpl*(t...rigx>>12)&7)))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4085 IWX_MSB(32);
never executed: *dptr |= 32;
never executed: end of block
*(sptr+sbpl*(t...rigx>>12)&7)))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4086 IWX_MSB(16);
never executed: *dptr |= 16;
never executed: end of block
*(sptr+sbpl*(t...rigx>>12)&7)))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4087 IWX_MSB(8);
never executed: *dptr |= 8;
never executed: end of block
*(sptr+sbpl*(t...rigx>>12)&7)))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4088 IWX_MSB(4);
never executed: *dptr |= 4;
never executed: end of block
*(sptr+sbpl*(t...rigx>>12)&7)))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4089 IWX_MSB(2);
never executed: *dptr |= 2;
never executed: end of block
*(sptr+sbpl*(t...rigx>>12)&7)))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4090 IWX_MSB(1);
never executed: *dptr |= 1;
never executed: end of block
*(sptr+sbpl*(t...rigx>>12)&7)))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4091 dptr++;-
4092 }
never executed: end of block
0
4093 break;
never executed: break;
0
4094 case QT_XFORM_TYPE_LSBFIRST:
never executed: case 1:
0
4095 while (dptr < maxp) {
dptr < maxpDescription
TRUEnever evaluated
FALSEnever evaluated
0
4096 IWX_LSB(1);
never executed: *dptr |= 1;
never executed: end of block
*(sptr+sbpl*(t...trigx>>12)&7))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4097 IWX_LSB(2);
never executed: *dptr |= 2;
never executed: end of block
*(sptr+sbpl*(t...trigx>>12)&7))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4098 IWX_LSB(4);
never executed: *dptr |= 4;
never executed: end of block
*(sptr+sbpl*(t...trigx>>12)&7))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4099 IWX_LSB(8);
never executed: *dptr |= 8;
never executed: end of block
*(sptr+sbpl*(t...trigx>>12)&7))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4100 IWX_LSB(16);
never executed: *dptr |= 16;
never executed: end of block
*(sptr+sbpl*(t...trigx>>12)&7))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4101 IWX_LSB(32);
never executed: *dptr |= 32;
never executed: end of block
*(sptr+sbpl*(t...trigx>>12)&7))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4102 IWX_LSB(64);
never executed: *dptr |= 64;
never executed: end of block
*(sptr+sbpl*(t...trigx>>12)&7))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4103 IWX_LSB(128);
never executed: *dptr |= 128;
never executed: end of block
*(sptr+sbpl*(t...trigx>>12)&7))Description
TRUEnever evaluated
FALSEnever evaluated
trigx < maxwsDescription
TRUEnever evaluated
FALSEnever evaluated
trigy < maxhsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4104 dptr++;-
4105 }
never executed: end of block
0
4106 break;
never executed: break;
0
4107 }-
4108 }
never executed: end of block
0
4109 m21ydx += m21;-
4110 m22ydy += m22;-
4111 dptr += p_inc;-
4112 }
never executed: end of block
0
4113 return true;
never executed: return true;
0
4114}-
4115#undef IWX_MSB-
4116#undef IWX_LSB-
4117#undef IWX_PIX-
4118-
4119/*! \fn int QImage::serialNumber() const-
4120 \obsolete-
4121 Returns a number that identifies the contents of this-
4122 QImage object. Distinct QImage objects can only have the same-
4123 serial number if they refer to the same contents (but they don't-
4124 have to).-
4125-
4126 Use cacheKey() instead.-
4127-
4128 \warning The serial number doesn't necessarily change when the-
4129 image is altered. This means that it may be dangerous to use-
4130 it as a cache key.-
4131-
4132 \sa operator==()-
4133*/-
4134-
4135/*!-
4136 Returns a number that identifies the contents of this QImage-
4137 object. Distinct QImage objects can only have the same key if they-
4138 refer to the same contents.-
4139-
4140 The key will change when the image is altered.-
4141*/-
4142qint64 QImage::cacheKey() const-
4143{-
4144 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
4145 return 0;
never executed: return 0;
0
4146 else-
4147 return (((qint64) d->ser_no) << 32) | ((qint64) d->detach_no);
never executed: return (((qint64) d->ser_no) << 32) | ((qint64) d->detach_no);
0
4148}-
4149-
4150/*!-
4151 \internal-
4152-
4153 Returns \c true if the image is detached; otherwise returns \c false.-
4154-
4155 \sa detach(), {Implicit Data Sharing}-
4156*/-
4157-
4158bool QImage::isDetached() const-
4159{-
4160 return d && d->ref.load() == 1;
never executed: return d && d->ref.load() == 1;
dDescription
TRUEnever evaluated
FALSEnever evaluated
d->ref.load() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
4161}-
4162-
4163-
4164/*!-
4165 \obsolete-
4166 Sets the alpha channel of this image to the given \a alphaChannel.-
4167-
4168 If \a alphaChannel is an 8 bit grayscale image, the intensity values are-
4169 written into this buffer directly. Otherwise, \a alphaChannel is converted-
4170 to 32 bit and the intensity of the RGB pixel values is used.-
4171-
4172 Note that the image will be converted to the Format_ARGB32_Premultiplied-
4173 format if the function succeeds.-
4174-
4175 Use one of the composition modes in QPainter::CompositionMode instead.-
4176-
4177 \warning This function is expensive.-
4178-
4179 \sa alphaChannel(), {QImage#Image Transformations}{Image-
4180 Transformations}, {QImage#Image Formats}{Image Formats}-
4181*/-
4182-
4183void QImage::setAlphaChannel(const QImage &alphaChannel)-
4184{-
4185 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
4186 return;
never executed: return;
0
4187-
4188 int w = d->width;-
4189 int h = d->height;-
4190-
4191 if (w != alphaChannel.d->width || h != alphaChannel.d->height) {
w != alphaChannel.d->widthDescription
TRUEnever evaluated
FALSEnever evaluated
h != alphaChannel.d->heightDescription
TRUEnever evaluated
FALSEnever evaluated
0
4192 qWarning("QImage::setAlphaChannel: "-
4193 "Alpha channel must have same dimensions as the target image");-
4194 return;
never executed: return;
0
4195 }-
4196-
4197 if (d->paintEngine && d->paintEngine->isActive()) {
d->paintEngineDescription
TRUEnever evaluated
FALSEnever evaluated
d->paintEngine->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
4198 qWarning("QImage::setAlphaChannel: "-
4199 "Unable to set alpha channel while image is being painted on");-
4200 return;
never executed: return;
0
4201 }-
4202-
4203 if (d->format == QImage::Format_ARGB32_Premultiplied)
d->format == Q..._PremultipliedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4204 detach();
never executed: detach();
0
4205 else-
4206 *this = convertToFormat(QImage::Format_ARGB32_Premultiplied);
never executed: *this = convertToFormat(QImage::Format_ARGB32_Premultiplied);
0
4207-
4208 if (isNull())
isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
4209 return;
never executed: return;
0
4210-
4211 // Slight optimization since alphachannels are returned as 8-bit grays.-
4212 if (alphaChannel.format() == QImage::Format_Alpha8 ||( alphaChannel.d->depth == 8 && alphaChannel.isGrayscale())) {
alphaChannel.f...:Format_Alpha8Description
TRUEnever evaluated
FALSEnever evaluated
alphaChannel.d->depth == 8Description
TRUEnever evaluated
FALSEnever evaluated
alphaChannel.isGrayscale()Description
TRUEnever evaluated
FALSEnever evaluated
0
4213 const uchar *src_data = alphaChannel.d->data;-
4214 uchar *dest_data = d->data;-
4215 for (int y=0; y<h; ++y) {
y<hDescription
TRUEnever evaluated
FALSEnever evaluated
0
4216 const uchar *src = src_data;-
4217 QRgb *dest = (QRgb *)dest_data;-
4218 for (int x=0; x<w; ++x) {
x<wDescription
TRUEnever evaluated
FALSEnever evaluated
0
4219 int alpha = *src;-
4220 int destAlpha = qt_div_255(alpha * qAlpha(*dest));-
4221 *dest = ((destAlpha << 24)-
4222 | (qt_div_255(qRed(*dest) * alpha) << 16)-
4223 | (qt_div_255(qGreen(*dest) * alpha) << 8)-
4224 | (qt_div_255(qBlue(*dest) * alpha)));-
4225 ++dest;-
4226 ++src;-
4227 }
never executed: end of block
0
4228 src_data += alphaChannel.d->bytes_per_line;-
4229 dest_data += d->bytes_per_line;-
4230 }
never executed: end of block
0
4231-
4232 } else {
never executed: end of block
0
4233 const QImage sourceImage = alphaChannel.convertToFormat(QImage::Format_RGB32);-
4234 if (sourceImage.isNull())
sourceImage.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
4235 return;
never executed: return;
0
4236 const uchar *src_data = sourceImage.d->data;-
4237 uchar *dest_data = d->data;-
4238 for (int y=0; y<h; ++y) {
y<hDescription
TRUEnever evaluated
FALSEnever evaluated
0
4239 const QRgb *src = (const QRgb *) src_data;-
4240 QRgb *dest = (QRgb *) dest_data;-
4241 for (int x=0; x<w; ++x) {
x<wDescription
TRUEnever evaluated
FALSEnever evaluated
0
4242 int alpha = qGray(*src);-
4243 int destAlpha = qt_div_255(alpha * qAlpha(*dest));-
4244 *dest = ((destAlpha << 24)-
4245 | (qt_div_255(qRed(*dest) * alpha) << 16)-
4246 | (qt_div_255(qGreen(*dest) * alpha) << 8)-
4247 | (qt_div_255(qBlue(*dest) * alpha)));-
4248 ++dest;-
4249 ++src;-
4250 }
never executed: end of block
0
4251 src_data += sourceImage.d->bytes_per_line;-
4252 dest_data += d->bytes_per_line;-
4253 }
never executed: end of block
0
4254 }
never executed: end of block
0
4255}-
4256-
4257-
4258/*!-
4259 \obsolete-
4260-
4261 Returns the alpha channel of the image as a new grayscale QImage in which-
4262 each pixel's red, green, and blue values are given the alpha value of the-
4263 original image. The color depth of the returned image is 8-bit.-
4264-
4265 You can see an example of use of this function in QPixmap's-
4266 \l{QPixmap::}{alphaChannel()}, which works in the same way as-
4267 this function on QPixmaps.-
4268-
4269 Most usecases for this function can be replaced with QPainter and-
4270 using composition modes.-
4271-
4272 Note this returns a color-indexed image if you want the alpha channel in-
4273 the alpha8 format instead use convertToFormat(Format_Alpha8) on the source-
4274 image.-
4275-
4276 \warning This is an expensive function.-
4277-
4278 \sa setAlphaChannel(), hasAlphaChannel(), convertToFormat(),-
4279 {QPixmap#Pixmap Information}{Pixmap},-
4280 {QImage#Image Transformations}{Image Transformations}-
4281*/-
4282-
4283QImage QImage::alphaChannel() const-
4284{-
4285 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
4286 return QImage();
never executed: return QImage();
0
4287-
4288 int w = d->width;-
4289 int h = d->height;-
4290-
4291 QImage image(w, h, Format_Indexed8);-
4292 image.setColorCount(256);-
4293-
4294 // set up gray scale table.-
4295 for (int i=0; i<256; ++i)
i<256Description
TRUEnever evaluated
FALSEnever evaluated
0
4296 image.setColor(i, qRgb(i, i, i));
never executed: image.setColor(i, qRgb(i, i, i));
0
4297-
4298 if (!hasAlphaChannel()) {
!hasAlphaChannel()Description
TRUEnever evaluated
FALSEnever evaluated
0
4299 image.fill(255);-
4300 return image;
never executed: return image;
0
4301 }-
4302-
4303 if (d->format == Format_Indexed8) {
d->format == Format_Indexed8Description
TRUEnever evaluated
FALSEnever evaluated
0
4304 const uchar *src_data = d->data;-
4305 uchar *dest_data = image.d->data;-
4306 for (int y=0; y<h; ++y) {
y<hDescription
TRUEnever evaluated
FALSEnever evaluated
0
4307 const uchar *src = src_data;-
4308 uchar *dest = dest_data;-
4309 for (int x=0; x<w; ++x) {
x<wDescription
TRUEnever evaluated
FALSEnever evaluated
0
4310 *dest = qAlpha(d->colortable.at(*src));-
4311 ++dest;-
4312 ++src;-
4313 }
never executed: end of block
0
4314 src_data += d->bytes_per_line;-
4315 dest_data += image.d->bytes_per_line;-
4316 }
never executed: end of block
0
4317 } else if (d->format == Format_Alpha8) {
never executed: end of block
d->format == Format_Alpha8Description
TRUEnever evaluated
FALSEnever evaluated
0
4318 const uchar *src_data = d->data;-
4319 uchar *dest_data = image.d->data;-
4320 memcpy(dest_data, src_data, d->bytes_per_line * h);-
4321 } else {
never executed: end of block
0
4322 QImage alpha32 = *this;-
4323 bool canSkipConversion = (d->format == Format_ARGB32 || d->format == Format_ARGB32_Premultiplied);
d->format == Format_ARGB32Description
TRUEnever evaluated
FALSEnever evaluated
d->format == F..._PremultipliedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4324#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN-
4325 canSkipConversion = canSkipConversion || (d->format == Format_RGBA8888 || d->format == Format_RGBA8888_Premultiplied);
canSkipConversionDescription
TRUEnever evaluated
FALSEnever evaluated
d->format == Format_RGBA8888Description
TRUEnever evaluated
FALSEnever evaluated
d->format == F..._PremultipliedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4326#endif-
4327 if (!canSkipConversion)
!canSkipConversionDescription
TRUEnever evaluated
FALSEnever evaluated
0
4328 alpha32 = convertToFormat(Format_ARGB32);
never executed: alpha32 = convertToFormat(Format_ARGB32);
0
4329-
4330 const uchar *src_data = alpha32.d->data;-
4331 uchar *dest_data = image.d->data;-
4332 for (int y=0; y<h; ++y) {
y<hDescription
TRUEnever evaluated
FALSEnever evaluated
0
4333 const QRgb *src = (const QRgb *) src_data;-
4334 uchar *dest = dest_data;-
4335 for (int x=0; x<w; ++x) {
x<wDescription
TRUEnever evaluated
FALSEnever evaluated
0
4336 *dest = qAlpha(*src);-
4337 ++dest;-
4338 ++src;-
4339 }
never executed: end of block
0
4340 src_data += alpha32.d->bytes_per_line;-
4341 dest_data += image.d->bytes_per_line;-
4342 }
never executed: end of block
0
4343 }
never executed: end of block
0
4344-
4345 return image;
never executed: return image;
0
4346}-
4347-
4348/*!-
4349 Returns \c true if the image has a format that respects the alpha-
4350 channel, otherwise returns \c false.-
4351-
4352 \sa {QImage#Image Information}{Image Information}-
4353*/-
4354bool QImage::hasAlphaChannel() const-
4355{-
4356 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
4357 return false;
never executed: return false;
0
4358 const QPixelFormat format = pixelFormat();-
4359 if (format.alphaUsage() == QPixelFormat::UsesAlpha)
format.alphaUs...mat::UsesAlphaDescription
TRUEnever evaluated
FALSEnever evaluated
0
4360 return true;
never executed: return true;
0
4361 if (format.colorModel() == QPixelFormat::Indexed)
format.colorMo...ormat::IndexedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4362 return d->has_alpha_clut;
never executed: return d->has_alpha_clut;
0
4363 return false;
never executed: return false;
0
4364}-
4365-
4366/*!-
4367 \since 4.7-
4368 Returns the number of bit planes in the image.-
4369-
4370 The number of bit planes is the number of bits of color and-
4371 transparency information for each pixel. This is different from-
4372 (i.e. smaller than) the depth when the image format contains-
4373 unused bits.-
4374-
4375 \sa depth(), format(), {QImage#Image Formats}{Image Formats}-
4376*/-
4377int QImage::bitPlaneCount() const-
4378{-
4379 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
4380 return 0;
never executed: return 0;
0
4381 int bpc = 0;-
4382 switch (d->format) {-
4383 case QImage::Format_Invalid:
never executed: case QImage::Format_Invalid:
0
4384 break;
never executed: break;
0
4385 case QImage::Format_BGR30:
never executed: case QImage::Format_BGR30:
0
4386 case QImage::Format_RGB30:
never executed: case QImage::Format_RGB30:
0
4387 bpc = 30;-
4388 break;
never executed: break;
0
4389 case QImage::Format_RGB32:
never executed: case QImage::Format_RGB32:
0
4390 case QImage::Format_RGBX8888:
never executed: case QImage::Format_RGBX8888:
0
4391 bpc = 24;-
4392 break;
never executed: break;
0
4393 case QImage::Format_RGB666:
never executed: case QImage::Format_RGB666:
0
4394 bpc = 18;-
4395 break;
never executed: break;
0
4396 case QImage::Format_RGB555:
never executed: case QImage::Format_RGB555:
0
4397 bpc = 15;-
4398 break;
never executed: break;
0
4399 case QImage::Format_ARGB8555_Premultiplied:
never executed: case QImage::Format_ARGB8555_Premultiplied:
0
4400 bpc = 23;-
4401 break;
never executed: break;
0
4402 case QImage::Format_RGB444:
never executed: case QImage::Format_RGB444:
0
4403 bpc = 12;-
4404 break;
never executed: break;
0
4405 default:
never executed: default:
0
4406 bpc = qt_depthForFormat(d->format);-
4407 break;
never executed: break;
0
4408 }-
4409 return bpc;
never executed: return bpc;
0
4410}-
4411-
4412/*!-
4413 Returns a smoothly scaled copy of the image. The returned image has a size-
4414 of width \a w by height \a h pixels.-
4415*/-
4416QImage QImage::smoothScaled(int w, int h) const {-
4417 QImage src = *this;-
4418 switch (src.format()) {-
4419 case QImage::Format_RGB32:
never executed: case QImage::Format_RGB32:
0
4420 case QImage::Format_ARGB32_Premultiplied:
never executed: case QImage::Format_ARGB32_Premultiplied:
0
4421#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN-
4422 case QImage::Format_RGBX8888:
never executed: case QImage::Format_RGBX8888:
0
4423#endif-
4424 case QImage::Format_RGBA8888_Premultiplied:
never executed: case QImage::Format_RGBA8888_Premultiplied:
0
4425 break;
never executed: break;
0
4426 default:
never executed: default:
0
4427 if (src.hasAlphaChannel())
src.hasAlphaChannel()Description
TRUEnever evaluated
FALSEnever evaluated
0
4428 src = src.convertToFormat(QImage::Format_ARGB32_Premultiplied);
never executed: src = src.convertToFormat(QImage::Format_ARGB32_Premultiplied);
0
4429 else-
4430 src = src.convertToFormat(QImage::Format_RGB32);
never executed: src = src.convertToFormat(QImage::Format_RGB32);
0
4431 }-
4432 src = qSmoothScaleImage(src, w, h);-
4433 if (!src.isNull())
!src.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
4434 copyMetadata(src.d, d);
never executed: copyMetadata(src.d, d);
0
4435 return src;
never executed: return src;
0
4436}-
4437-
4438static QImage rotated90(const QImage &image) {-
4439 QImage out(image.height(), image.width(), image.format());-
4440 out.setDotsPerMeterX(image.dotsPerMeterY());-
4441 out.setDotsPerMeterY(image.dotsPerMeterX());-
4442 if (image.colorCount() > 0)
image.colorCount() > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
4443 out.setColorTable(image.colorTable());
never executed: out.setColorTable(image.colorTable());
0
4444 int w = image.width();-
4445 int h = image.height();-
4446 switch (image.format()) {-
4447 case QImage::Format_RGB32:
never executed: case QImage::Format_RGB32:
0
4448 case QImage::Format_ARGB32:
never executed: case QImage::Format_ARGB32:
0
4449 case QImage::Format_ARGB32_Premultiplied:
never executed: case QImage::Format_ARGB32_Premultiplied:
0
4450 case QImage::Format_RGBX8888:
never executed: case QImage::Format_RGBX8888:
0
4451 case QImage::Format_RGBA8888:
never executed: case QImage::Format_RGBA8888:
0
4452 case QImage::Format_RGBA8888_Premultiplied:
never executed: case QImage::Format_RGBA8888_Premultiplied:
0
4453 case QImage::Format_BGR30:
never executed: case QImage::Format_BGR30:
0
4454 case QImage::Format_A2BGR30_Premultiplied:
never executed: case QImage::Format_A2BGR30_Premultiplied:
0
4455 case QImage::Format_RGB30:
never executed: case QImage::Format_RGB30:
0
4456 case QImage::Format_A2RGB30_Premultiplied:
never executed: case QImage::Format_A2RGB30_Premultiplied:
0
4457 qt_memrotate270(reinterpret_cast<const quint32*>(image.bits()),-
4458 w, h, image.bytesPerLine(),-
4459 reinterpret_cast<quint32*>(out.bits()),-
4460 out.bytesPerLine());-
4461 break;
never executed: break;
0
4462 case QImage::Format_RGB666:
never executed: case QImage::Format_RGB666:
0
4463 case QImage::Format_ARGB6666_Premultiplied:
never executed: case QImage::Format_ARGB6666_Premultiplied:
0
4464 case QImage::Format_ARGB8565_Premultiplied:
never executed: case QImage::Format_ARGB8565_Premultiplied:
0
4465 case QImage::Format_ARGB8555_Premultiplied:
never executed: case QImage::Format_ARGB8555_Premultiplied:
0
4466 case QImage::Format_RGB888:
never executed: case QImage::Format_RGB888:
0
4467 qt_memrotate270(reinterpret_cast<const quint24*>(image.bits()),-
4468 w, h, image.bytesPerLine(),-
4469 reinterpret_cast<quint24*>(out.bits()),-
4470 out.bytesPerLine());-
4471 break;
never executed: break;
0
4472 case QImage::Format_RGB555:
never executed: case QImage::Format_RGB555:
0
4473 case QImage::Format_RGB16:
never executed: case QImage::Format_RGB16:
0
4474 case QImage::Format_ARGB4444_Premultiplied:
never executed: case QImage::Format_ARGB4444_Premultiplied:
0
4475 qt_memrotate270(reinterpret_cast<const quint16*>(image.bits()),-
4476 w, h, image.bytesPerLine(),-
4477 reinterpret_cast<quint16*>(out.bits()),-
4478 out.bytesPerLine());-
4479 break;
never executed: break;
0
4480 case QImage::Format_Alpha8:
never executed: case QImage::Format_Alpha8:
0
4481 case QImage::Format_Grayscale8:
never executed: case QImage::Format_Grayscale8:
0
4482 case QImage::Format_Indexed8:
never executed: case QImage::Format_Indexed8:
0
4483 qt_memrotate270(reinterpret_cast<const quint8*>(image.bits()),-
4484 w, h, image.bytesPerLine(),-
4485 reinterpret_cast<quint8*>(out.bits()),-
4486 out.bytesPerLine());-
4487 break;
never executed: break;
0
4488 default:
never executed: default:
0
4489 for (int y=0; y<h; ++y) {
y<hDescription
TRUEnever evaluated
FALSEnever evaluated
0
4490 if (image.colorCount())
image.colorCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
4491 for (int x=0; x<w; ++x)
x<wDescription
TRUEnever evaluated
FALSEnever evaluated
0
4492 out.setPixel(h-y-1, x, image.pixelIndex(x, y));
never executed: out.setPixel(h-y-1, x, image.pixelIndex(x, y));
0
4493 else-
4494 for (int x=0; x<w; ++x)
x<wDescription
TRUEnever evaluated
FALSEnever evaluated
0
4495 out.setPixel(h-y-1, x, image.pixel(x, y));
never executed: out.setPixel(h-y-1, x, image.pixel(x, y));
0
4496 }
never executed: end of block
0
4497 break;
never executed: break;
0
4498 }-
4499 return out;
never executed: return out;
0
4500}-
4501-
4502-
4503static QImage rotated180(const QImage &image) {-
4504 return image.mirrored(true, true);
never executed: return image.mirrored(true, true);
0
4505}-
4506-
4507-
4508static QImage rotated270(const QImage &image) {-
4509 QImage out(image.height(), image.width(), image.format());-
4510 out.setDotsPerMeterX(image.dotsPerMeterY());-
4511 out.setDotsPerMeterY(image.dotsPerMeterX());-
4512 if (image.colorCount() > 0)
image.colorCount() > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
4513 out.setColorTable(image.colorTable());
never executed: out.setColorTable(image.colorTable());
0
4514 int w = image.width();-
4515 int h = image.height();-
4516 switch (image.format()) {-
4517 case QImage::Format_RGB32:
never executed: case QImage::Format_RGB32:
0
4518 case QImage::Format_ARGB32:
never executed: case QImage::Format_ARGB32:
0
4519 case QImage::Format_ARGB32_Premultiplied:
never executed: case QImage::Format_ARGB32_Premultiplied:
0
4520 case QImage::Format_RGBX8888:
never executed: case QImage::Format_RGBX8888:
0
4521 case QImage::Format_RGBA8888:
never executed: case QImage::Format_RGBA8888:
0
4522 case QImage::Format_RGBA8888_Premultiplied:
never executed: case QImage::Format_RGBA8888_Premultiplied:
0
4523 case QImage::Format_BGR30:
never executed: case QImage::Format_BGR30:
0
4524 case QImage::Format_A2BGR30_Premultiplied:
never executed: case QImage::Format_A2BGR30_Premultiplied:
0
4525 case QImage::Format_RGB30:
never executed: case QImage::Format_RGB30:
0
4526 case QImage::Format_A2RGB30_Premultiplied:
never executed: case QImage::Format_A2RGB30_Premultiplied:
0
4527 qt_memrotate90(reinterpret_cast<const quint32*>(image.bits()),-
4528 w, h, image.bytesPerLine(),-
4529 reinterpret_cast<quint32*>(out.bits()),-
4530 out.bytesPerLine());-
4531 break;
never executed: break;
0
4532 case QImage::Format_RGB666:
never executed: case QImage::Format_RGB666:
0
4533 case QImage::Format_ARGB6666_Premultiplied:
never executed: case QImage::Format_ARGB6666_Premultiplied:
0
4534 case QImage::Format_ARGB8565_Premultiplied:
never executed: case QImage::Format_ARGB8565_Premultiplied:
0
4535 case QImage::Format_ARGB8555_Premultiplied:
never executed: case QImage::Format_ARGB8555_Premultiplied:
0
4536 case QImage::Format_RGB888:
never executed: case QImage::Format_RGB888:
0
4537 qt_memrotate90(reinterpret_cast<const quint24*>(image.bits()),-
4538 w, h, image.bytesPerLine(),-
4539 reinterpret_cast<quint24*>(out.bits()),-
4540 out.bytesPerLine());-
4541 break;
never executed: break;
0
4542 case QImage::Format_RGB555:
never executed: case QImage::Format_RGB555:
0
4543 case QImage::Format_RGB16:
never executed: case QImage::Format_RGB16:
0
4544 case QImage::Format_ARGB4444_Premultiplied:
never executed: case QImage::Format_ARGB4444_Premultiplied:
0
4545 qt_memrotate90(reinterpret_cast<const quint16*>(image.bits()),-
4546 w, h, image.bytesPerLine(),-
4547 reinterpret_cast<quint16*>(out.bits()),-
4548 out.bytesPerLine());-
4549 break;
never executed: break;
0
4550 case QImage::Format_Alpha8:
never executed: case QImage::Format_Alpha8:
0
4551 case QImage::Format_Grayscale8:
never executed: case QImage::Format_Grayscale8:
0
4552 case QImage::Format_Indexed8:
never executed: case QImage::Format_Indexed8:
0
4553 qt_memrotate90(reinterpret_cast<const quint8*>(image.bits()),-
4554 w, h, image.bytesPerLine(),-
4555 reinterpret_cast<quint8*>(out.bits()),-
4556 out.bytesPerLine());-
4557 break;
never executed: break;
0
4558 default:
never executed: default:
0
4559 for (int y=0; y<h; ++y) {
y<hDescription
TRUEnever evaluated
FALSEnever evaluated
0
4560 if (image.colorCount())
image.colorCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
4561 for (int x=0; x<w; ++x)
x<wDescription
TRUEnever evaluated
FALSEnever evaluated
0
4562 out.setPixel(y, w-x-1, image.pixelIndex(x, y));
never executed: out.setPixel(y, w-x-1, image.pixelIndex(x, y));
0
4563 else-
4564 for (int x=0; x<w; ++x)
x<wDescription
TRUEnever evaluated
FALSEnever evaluated
0
4565 out.setPixel(y, w-x-1, image.pixel(x, y));
never executed: out.setPixel(y, w-x-1, image.pixel(x, y));
0
4566 }
never executed: end of block
0
4567 break;
never executed: break;
0
4568 }-
4569 return out;
never executed: return out;
0
4570}-
4571-
4572/*!-
4573 Returns a copy of the image that is transformed using the given-
4574 transformation \a matrix and transformation \a mode.-
4575-
4576 The transformation \a matrix is internally adjusted to compensate-
4577 for unwanted translation; i.e. the image produced is the smallest-
4578 image that contains all the transformed points of the original-
4579 image. Use the trueMatrix() function to retrieve the actual matrix-
4580 used for transforming an image.-
4581-
4582 Unlike the other overload, this function can be used to perform perspective-
4583 transformations on images.-
4584-
4585 \sa trueMatrix(), {QImage#Image Transformations}{Image-
4586 Transformations}-
4587*/-
4588-
4589QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode ) const-
4590{-
4591 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
4592 return QImage();
never executed: return QImage();
0
4593-
4594 // source image data-
4595 int ws = width();-
4596 int hs = height();-
4597-
4598 // target image data-
4599 int wd;-
4600 int hd;-
4601-
4602 // compute size of target image-
4603 QTransform mat = trueMatrix(matrix, ws, hs);-
4604 bool complex_xform = false;-
4605 bool scale_xform = false;-
4606 if (mat.type() <= QTransform::TxScale) {
mat.type() <= ...sform::TxScaleDescription
TRUEnever evaluated
FALSEnever evaluated
0
4607 if (mat.type() == QTransform::TxNone) // identity matrix
mat.type() == ...nsform::TxNoneDescription
TRUEnever evaluated
FALSEnever evaluated
0
4608 return *this;
never executed: return *this;
0
4609 else if (mat.m11() == -1. && mat.m22() == -1.)
mat.m11() == -1.Description
TRUEnever evaluated
FALSEnever evaluated
mat.m22() == -1.Description
TRUEnever evaluated
FALSEnever evaluated
0
4610 return rotated180(*this);
never executed: return rotated180(*this);
0
4611-
4612 if (mode == Qt::FastTransformation) {
mode == Qt::FastTransformationDescription
TRUEnever evaluated
FALSEnever evaluated
0
4613 hd = qRound(qAbs(mat.m22()) * hs);-
4614 wd = qRound(qAbs(mat.m11()) * ws);-
4615 } else {
never executed: end of block
0
4616 hd = int(qAbs(mat.m22()) * hs + 0.9999);-
4617 wd = int(qAbs(mat.m11()) * ws + 0.9999);-
4618 }
never executed: end of block
0
4619 scale_xform = true;-
4620 } else {
never executed: end of block
0
4621 if (mat.type() <= QTransform::TxRotate && mat.m11() == 0 && mat.m22() == 0) {
mat.type() <= ...form::TxRotateDescription
TRUEnever evaluated
FALSEnever evaluated
mat.m11() == 0Description
TRUEnever evaluated
FALSEnever evaluated
mat.m22() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
4622 if (mat.m12() == 1. && mat.m21() == -1.)
mat.m12() == 1.Description
TRUEnever evaluated
FALSEnever evaluated
mat.m21() == -1.Description
TRUEnever evaluated
FALSEnever evaluated
0
4623 return rotated90(*this);
never executed: return rotated90(*this);
0
4624 else if (mat.m12() == -1. && mat.m21() == 1.)
mat.m12() == -1.Description
TRUEnever evaluated
FALSEnever evaluated
mat.m21() == 1.Description
TRUEnever evaluated
FALSEnever evaluated
0
4625 return rotated270(*this);
never executed: return rotated270(*this);
0
4626 }
never executed: end of block
0
4627-
4628 QPolygonF a(QRectF(0, 0, ws, hs));-
4629 a = mat.map(a);-
4630 QRect r = a.boundingRect().toAlignedRect();-
4631 wd = r.width();-
4632 hd = r.height();-
4633 complex_xform = true;-
4634 }
never executed: end of block
0
4635-
4636 if (wd == 0 || hd == 0)
wd == 0Description
TRUEnever evaluated
FALSEnever evaluated
hd == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
4637 return QImage();
never executed: return QImage();
0
4638-
4639 // Make use of the optimized algorithm when we're scaling-
4640 if (scale_xform && mode == Qt::SmoothTransformation) {
scale_xformDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::Sm...TransformationDescription
TRUEnever evaluated
FALSEnever evaluated
0
4641 if (mat.m11() < 0.0F && mat.m22() < 0.0F) { // horizontal/vertical flip
mat.m11() < 0.0FDescription
TRUEnever evaluated
FALSEnever evaluated
mat.m22() < 0.0FDescription
TRUEnever evaluated
FALSEnever evaluated
0
4642 return smoothScaled(wd, hd).mirrored(true, true);
never executed: return smoothScaled(wd, hd).mirrored(true, true);
0
4643 } else if (mat.m11() < 0.0F) { // horizontal flip
mat.m11() < 0.0FDescription
TRUEnever evaluated
FALSEnever evaluated
0
4644 return smoothScaled(wd, hd).mirrored(true, false);
never executed: return smoothScaled(wd, hd).mirrored(true, false);
0
4645 } else if (mat.m22() < 0.0F) { // vertical flip
mat.m22() < 0.0FDescription
TRUEnever evaluated
FALSEnever evaluated
0
4646 return smoothScaled(wd, hd).mirrored(false, true);
never executed: return smoothScaled(wd, hd).mirrored(false, true);
0
4647 } else { // no flipping-
4648 return smoothScaled(wd, hd);
never executed: return smoothScaled(wd, hd);
0
4649 }-
4650 }-
4651-
4652 int bpp = depth();-
4653-
4654 int sbpl = bytesPerLine();-
4655 const uchar *sptr = bits();-
4656-
4657 QImage::Format target_format = d->format;-
4658-
4659 if (complex_xform || mode == Qt::SmoothTransformation) {
complex_xformDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::Sm...TransformationDescription
TRUEnever evaluated
FALSEnever evaluated
0
4660 if (d->format < QImage::Format_RGB32 || !hasAlphaChannel()) {
d->format < QI...::Format_RGB32Description
TRUEnever evaluated
FALSEnever evaluated
!hasAlphaChannel()Description
TRUEnever evaluated
FALSEnever evaluated
0
4661 target_format = qt_alphaVersion(d->format);-
4662 }
never executed: end of block
0
4663 }
never executed: end of block
0
4664-
4665 QImage dImage(wd, hd, target_format);-
4666 QIMAGE_SANITYCHECK_MEMORY(dImage);
never executed: return QImage();
(dImage).isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
4667-
4668 if (target_format == QImage::Format_MonoLSB
target_format ...Format_MonoLSBDescription
TRUEnever evaluated
FALSEnever evaluated
0
4669 || target_format == QImage::Format_Mono
target_format ...e::Format_MonoDescription
TRUEnever evaluated
FALSEnever evaluated
0
4670 || target_format == QImage::Format_Indexed8) {
target_format ...ormat_Indexed8Description
TRUEnever evaluated
FALSEnever evaluated
0
4671 dImage.d->colortable = d->colortable;-
4672 dImage.d->has_alpha_clut = d->has_alpha_clut | complex_xform;-
4673 }
never executed: end of block
0
4674-
4675 // initizialize the data-
4676 if (d->format == QImage::Format_Indexed8) {
d->format == Q...ormat_Indexed8Description
TRUEnever evaluated
FALSEnever evaluated
0
4677 if (dImage.d->colortable.size() < 256) {
dImage.d->colo...e.size() < 256Description
TRUEnever evaluated
FALSEnever evaluated
0
4678 // colors are left in the color table, so pick that one as transparent-
4679 dImage.d->colortable.append(0x0);-
4680 memset(dImage.bits(), dImage.d->colortable.size() - 1, dImage.byteCount());-
4681 } else {
never executed: end of block
0
4682 memset(dImage.bits(), 0, dImage.byteCount());-
4683 }
never executed: end of block
0
4684 } else-
4685 memset(dImage.bits(), 0x00, dImage.byteCount());
never executed: memset(dImage.bits(), 0x00, dImage.byteCount());
0
4686-
4687 if (target_format >= QImage::Format_RGB32) {
target_format ...::Format_RGB32Description
TRUEnever evaluated
FALSEnever evaluated
0
4688 // Prevent QPainter from applying devicePixelRatio corrections-
4689 const QImage sImage = (devicePixelRatio() != 1) ? QImage(constBits(), width(), height(), format()) : *this;
(devicePixelRatio() != 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
4690-
4691 Q_ASSERT(sImage.devicePixelRatio() == 1);-
4692 Q_ASSERT(sImage.devicePixelRatio() == dImage.devicePixelRatio());-
4693-
4694 QPainter p(&dImage);-
4695 if (mode == Qt::SmoothTransformation) {
mode == Qt::Sm...TransformationDescription
TRUEnever evaluated
FALSEnever evaluated
0
4696 p.setRenderHint(QPainter::Antialiasing);-
4697 p.setRenderHint(QPainter::SmoothPixmapTransform);-
4698 }
never executed: end of block
0
4699 p.setTransform(mat);-
4700 p.drawImage(QPoint(0, 0), sImage);-
4701 } else {
never executed: end of block
0
4702 bool invertible;-
4703 mat = mat.inverted(&invertible); // invert matrix-
4704 if (!invertible) // error, return null image
!invertibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
4705 return QImage();
never executed: return QImage();
0
4706-
4707 // create target image (some of the code is from QImage::copy())-
4708 int type = format() == Format_Mono ? QT_XFORM_TYPE_MSBFIRST : QT_XFORM_TYPE_LSBFIRST;
format() == Format_MonoDescription
TRUEnever evaluated
FALSEnever evaluated
0
4709 int dbpl = dImage.bytesPerLine();-
4710 qt_xForm_helper(mat, 0, type, bpp, dImage.bits(), dbpl, 0, hd, sptr, sbpl, ws, hs);-
4711 }
never executed: end of block
0
4712 copyMetadata(dImage.d, d);-
4713-
4714 return dImage;
never executed: return dImage;
0
4715}-
4716-
4717/*!-
4718 \fn QTransform QImage::trueMatrix(const QTransform &matrix, int width, int height)-
4719-
4720 Returns the actual matrix used for transforming an image with the-
4721 given \a width, \a height and \a matrix.-
4722-
4723 When transforming an image using the transformed() function, the-
4724 transformation matrix is internally adjusted to compensate for-
4725 unwanted translation, i.e. transformed() returns the smallest-
4726 image containing all transformed points of the original image.-
4727 This function returns the modified matrix, which maps points-
4728 correctly from the original image into the new image.-
4729-
4730 Unlike the other overload, this function creates transformation-
4731 matrices that can be used to perform perspective-
4732 transformations on images.-
4733-
4734 \sa transformed(), {QImage#Image Transformations}{Image-
4735 Transformations}-
4736*/-
4737-
4738QTransform QImage::trueMatrix(const QTransform &matrix, int w, int h)-
4739{-
4740 const QRectF rect(0, 0, w, h);-
4741 const QRect mapped = matrix.mapRect(rect).toAlignedRect();-
4742 const QPoint delta = mapped.topLeft();-
4743 return matrix * QTransform().translate(-delta.x(), -delta.y());
never executed: return matrix * QTransform().translate(-delta.x(), -delta.y());
0
4744}-
4745-
4746bool QImageData::convertInPlace(QImage::Format newFormat, Qt::ImageConversionFlags flags)-
4747{-
4748 if (format == newFormat)
format == newFormatDescription
TRUEnever evaluated
FALSEnever evaluated
0
4749 return true;
never executed: return true;
0
4750-
4751 // No in-place conversion if we have to detach-
4752 if (ref.load() > 1 || !own_data)
ref.load() > 1Description
TRUEnever evaluated
FALSEnever evaluated
!own_dataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4753 return false;
never executed: return false;
0
4754-
4755 InPlace_Image_Converter converter = qimage_inplace_converter_map[format][newFormat];-
4756 if (converter)
converterDescription
TRUEnever evaluated
FALSEnever evaluated
0
4757 return converter(this, flags);
never executed: return converter(this, flags);
0
4758 else if (format > QImage::Format_Indexed8 && newFormat > QImage::Format_Indexed8 && !qimage_converter_map[format][newFormat])
format > QImag...ormat_Indexed8Description
TRUEnever evaluated
FALSEnever evaluated
newFormat > QI...ormat_Indexed8Description
TRUEnever evaluated
FALSEnever evaluated
!qimage_conver...at][newFormat]Description
TRUEnever evaluated
FALSEnever evaluated
0
4759 // Convert inplace generic, but only if there are no direct converters,-
4760 // any direct ones are probably better even if not inplace.-
4761 return convert_generic_inplace(this, newFormat, flags);
never executed: return convert_generic_inplace(this, newFormat, flags);
0
4762 else-
4763 return false;
never executed: return false;
0
4764}-
4765-
4766/*!-
4767 \typedef QImage::DataPtr-
4768 \internal-
4769*/-
4770-
4771/*!-
4772 \fn DataPtr & QImage::data_ptr()-
4773 \internal-
4774*/-
4775-
4776#ifndef QT_NO_DEBUG_STREAM-
4777QDebug operator<<(QDebug dbg, const QImage &i)-
4778{-
4779 QDebugStateSaver saver(dbg);-
4780 dbg.resetFormat();-
4781 dbg.nospace();-
4782 dbg << "QImage(";-
4783 if (i.isNull()) {
i.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
4784 dbg << "null";-
4785 } else {
never executed: end of block
0
4786 dbg << i.size() << ",format=" << i.format() << ",depth=" << i.depth();-
4787 if (i.colorCount())
i.colorCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
4788 dbg << ",colorCount=" << i.colorCount();
never executed: dbg << ",colorCount=" << i.colorCount();
0
4789 dbg << ",devicePixelRatio=" << i.devicePixelRatio()-
4790 << ",bytesPerLine=" << i.bytesPerLine() << ",byteCount=" << i.byteCount();-
4791 }
never executed: end of block
0
4792 dbg << ')';-
4793 return dbg;
never executed: return dbg;
0
4794}-
4795#endif-
4796-
4797/*!-
4798 \fn void QImage::setNumColors(int n)-
4799 \obsolete-
4800-
4801 Resizes the color table to contain \a n entries.-
4802-
4803 \sa setColorCount()-
4804 */-
4805-
4806/*!-
4807 \fn int QImage::numBytes() const-
4808 \obsolete-
4809-
4810 Returns the number of bytes occupied by the image data.-
4811-
4812 \sa byteCount()-
4813 */-
4814-
4815/*!-
4816 \fn QStringList QImage::textLanguages() const-
4817 \obsolete-
4818-
4819 Returns the language identifiers for which some texts are recorded.-
4820 Note that if you want to iterate over the list, you should iterate over a copy.-
4821-
4822 The language the text is recorded in is no longer relevant since the text is-
4823 always set using QString and UTF-8 representation.-
4824-
4825 \sa textKeys()-
4826 */-
4827-
4828/*!-
4829 \fn QList<QImageTextKeyLang> QImage::textList() const-
4830 \obsolete-
4831-
4832 Returns a list of QImageTextKeyLang objects that enumerate all the texts-
4833 key/language pairs set for this image.-
4834-
4835 The language the text is recorded in is no longer relevant since the text-
4836 is always set using QString and UTF-8 representation.-
4837-
4838 \sa textKeys()-
4839 */-
4840-
4841static Q_CONSTEXPR QPixelFormat pixelformats[] = {-
4842 //QImage::Format_Invalid:-
4843 QPixelFormat(),-
4844 //QImage::Format_Mono:-
4845 QPixelFormat(QPixelFormat::Indexed,-
4846 /*RED*/ 1,-
4847 /*GREEN*/ 0,-
4848 /*BLUE*/ 0,-
4849 /*FOURTH*/ 0,-
4850 /*FIFTH*/ 0,-
4851 /*ALPHA*/ 0,-
4852 /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha,-
4853 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
4854 /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,-
4855 /*INTERPRETATION*/ QPixelFormat::UnsignedByte,-
4856 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
4857 //QImage::Format_MonoLSB:-
4858 QPixelFormat(QPixelFormat::Indexed,-
4859 /*RED*/ 1,-
4860 /*GREEN*/ 0,-
4861 /*BLUE*/ 0,-
4862 /*FOURTH*/ 0,-
4863 /*FIFTH*/ 0,-
4864 /*ALPHA*/ 0,-
4865 /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha,-
4866 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
4867 /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,-
4868 /*INTERPRETATION*/ QPixelFormat::UnsignedByte,-
4869 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
4870 //QImage::Format_Indexed8:-
4871 QPixelFormat(QPixelFormat::Indexed,-
4872 /*RED*/ 8,-
4873 /*GREEN*/ 0,-
4874 /*BLUE*/ 0,-
4875 /*FOURTH*/ 0,-
4876 /*FIFTH*/ 0,-
4877 /*ALPHA*/ 0,-
4878 /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha,-
4879 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
4880 /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,-
4881 /*INTERPRETATION*/ QPixelFormat::UnsignedByte,-
4882 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
4883 //QImage::Format_RGB32:-
4884 QPixelFormat(QPixelFormat::RGB,-
4885 /*RED*/ 8,-
4886 /*GREEN*/ 8,-
4887 /*BLUE*/ 8,-
4888 /*FOURTH*/ 0,-
4889 /*FIFTH*/ 0,-
4890 /*ALPHA*/ 8,-
4891 /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha,-
4892 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
4893 /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,-
4894 /*INTERPRETATION*/ QPixelFormat::UnsignedInteger,-
4895 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
4896 //QImage::Format_ARGB32:-
4897 QPixelFormat(QPixelFormat::RGB,-
4898 /*RED*/ 8,-
4899 /*GREEN*/ 8,-
4900 /*BLUE*/ 8,-
4901 /*FOURTH*/ 0,-
4902 /*FIFTH*/ 0,-
4903 /*ALPHA*/ 8,-
4904 /*ALPHA USAGE*/ QPixelFormat::UsesAlpha,-
4905 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
4906 /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,-
4907 /*INTERPRETATION*/ QPixelFormat::UnsignedInteger,-
4908 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
4909 //QImage::Format_ARGB32_Premultiplied:-
4910 QPixelFormat(QPixelFormat::RGB,-
4911 /*RED*/ 8,-
4912 /*GREEN*/ 8,-
4913 /*BLUE*/ 8,-
4914 /*FOURTH*/ 0,-
4915 /*FIFTH*/ 0,-
4916 /*ALPHA*/ 8,-
4917 /*ALPHA USAGE*/ QPixelFormat::UsesAlpha,-
4918 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
4919 /*PREMULTIPLIED*/ QPixelFormat::Premultiplied,-
4920 /*INTERPRETATION*/ QPixelFormat::UnsignedInteger,-
4921 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
4922 //QImage::Format_RGB16:-
4923 QPixelFormat(QPixelFormat::RGB,-
4924 /*RED*/ 5,-
4925 /*GREEN*/ 6,-
4926 /*BLUE*/ 5,-
4927 /*FOURTH*/ 0,-
4928 /*FIFTH*/ 0,-
4929 /*ALPHA*/ 0,-
4930 /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha,-
4931 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
4932 /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,-
4933 /*INTERPRETATION*/ QPixelFormat::UnsignedShort,-
4934 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
4935 //QImage::Format_ARGB8565_Premultiplied:-
4936 QPixelFormat(QPixelFormat::RGB,-
4937 /*RED*/ 5,-
4938 /*GREEN*/ 6,-
4939 /*BLUE*/ 5,-
4940 /*FOURTH*/ 0,-
4941 /*FIFTH*/ 0,-
4942 /*ALPHA*/ 8,-
4943 /*ALPHA USAGE*/ QPixelFormat::UsesAlpha,-
4944 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
4945 /*PREMULTIPLIED*/ QPixelFormat::Premultiplied,-
4946 /*INTERPRETATION*/ QPixelFormat::UnsignedInteger,-
4947 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
4948 //QImage::Format_RGB666:-
4949 QPixelFormat(QPixelFormat::RGB,-
4950 /*RED*/ 6,-
4951 /*GREEN*/ 6,-
4952 /*BLUE*/ 6,-
4953 /*FOURTH*/ 0,-
4954 /*FIFTH*/ 0,-
4955 /*ALPHA*/ 0,-
4956 /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha,-
4957 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
4958 /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,-
4959 /*INTERPRETATION*/ QPixelFormat::UnsignedInteger,-
4960 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
4961 //QImage::Format_ARGB6666_Premultiplied:-
4962 QPixelFormat(QPixelFormat::RGB,-
4963 /*RED*/ 6,-
4964 /*GREEN*/ 6,-
4965 /*BLUE*/ 6,-
4966 /*FOURTH*/ 0,-
4967 /*FIFTH*/ 0,-
4968 /*ALPHA*/ 6,-
4969 /*ALPHA USAGE*/ QPixelFormat::UsesAlpha,-
4970 /*ALPHA POSITION*/ QPixelFormat::AtEnd,-
4971 /*PREMULTIPLIED*/ QPixelFormat::Premultiplied,-
4972 /*INTERPRETATION*/ QPixelFormat::UnsignedInteger,-
4973 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
4974 //QImage::Format_RGB555:-
4975 QPixelFormat(QPixelFormat::RGB,-
4976 /*RED*/ 5,-
4977 /*GREEN*/ 5,-
4978 /*BLUE*/ 5,-
4979 /*FOURTH*/ 0,-
4980 /*FIFTH*/ 0,-
4981 /*ALPHA*/ 0,-
4982 /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha,-
4983 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
4984 /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,-
4985 /*INTERPRETATION*/ QPixelFormat::UnsignedShort,-
4986 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
4987 //QImage::Format_ARGB8555_Premultiplied:-
4988 QPixelFormat(QPixelFormat::RGB,-
4989 /*RED*/ 5,-
4990 /*GREEN*/ 5,-
4991 /*BLUE*/ 5,-
4992 /*FOURTH*/ 0,-
4993 /*FIFTH*/ 0,-
4994 /*ALPHA*/ 8,-
4995 /*ALPHA USAGE*/ QPixelFormat::UsesAlpha,-
4996 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
4997 /*PREMULTIPLIED*/ QPixelFormat::Premultiplied,-
4998 /*INTERPRETATION*/ QPixelFormat::UnsignedInteger,-
4999 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
5000 //QImage::Format_RGB888:-
5001 QPixelFormat(QPixelFormat::RGB,-
5002 /*RED*/ 8,-
5003 /*GREEN*/ 8,-
5004 /*BLUE*/ 8,-
5005 /*FOURTH*/ 0,-
5006 /*FIFTH*/ 0,-
5007 /*ALPHA*/ 0,-
5008 /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha,-
5009 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
5010 /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,-
5011 /*INTERPRETATION*/ QPixelFormat::UnsignedByte,-
5012 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
5013 //QImage::Format_RGB444:-
5014 QPixelFormat(QPixelFormat::RGB,-
5015 /*RED*/ 4,-
5016 /*GREEN*/ 4,-
5017 /*BLUE*/ 4,-
5018 /*FOURTH*/ 0,-
5019 /*FIFTH*/ 0,-
5020 /*ALPHA*/ 0,-
5021 /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha,-
5022 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
5023 /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,-
5024 /*INTERPRETATION*/ QPixelFormat::UnsignedShort,-
5025 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
5026 //QImage::Format_ARGB4444_Premultiplied:-
5027 QPixelFormat(QPixelFormat::RGB,-
5028 /*RED*/ 4,-
5029 /*GREEN*/ 4,-
5030 /*BLUE*/ 4,-
5031 /*FOURTH*/ 0,-
5032 /*FIFTH*/ 0,-
5033 /*ALPHA*/ 4,-
5034 /*ALPHA USAGE*/ QPixelFormat::UsesAlpha,-
5035 /*ALPHA POSITION*/ QPixelFormat::AtEnd,-
5036 /*PREMULTIPLIED*/ QPixelFormat::Premultiplied,-
5037 /*INTERPRETATION*/ QPixelFormat::UnsignedShort,-
5038 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
5039 //QImage::Format_RGBX8888:-
5040 QPixelFormat(QPixelFormat::RGB,-
5041 /*RED*/ 8,-
5042 /*GREEN*/ 8,-
5043 /*BLUE*/ 8,-
5044 /*FOURTH*/ 0,-
5045 /*FIFTH*/ 0,-
5046 /*ALPHA*/ 8,-
5047 /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha,-
5048 /*ALPHA POSITION*/ QPixelFormat::AtEnd,-
5049 /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,-
5050 /*INTERPRETATION*/ QPixelFormat::UnsignedByte,-
5051 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
5052 //QImage::Format_RGBA8888:-
5053 QPixelFormat(QPixelFormat::RGB,-
5054 /*RED*/ 8,-
5055 /*GREEN*/ 8,-
5056 /*BLUE*/ 8,-
5057 /*FOURTH*/ 0,-
5058 /*FIFTH*/ 0,-
5059 /*ALPHA*/ 8,-
5060 /*ALPHA USAGE*/ QPixelFormat::UsesAlpha,-
5061 /*ALPHA POSITION*/ QPixelFormat::AtEnd,-
5062 /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,-
5063 /*INTERPRETATION*/ QPixelFormat::UnsignedByte,-
5064 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
5065 //QImage::Format_RGBA8888_Premultiplied:-
5066 QPixelFormat(QPixelFormat::RGB,-
5067 /*RED*/ 8,-
5068 /*GREEN*/ 8,-
5069 /*BLUE*/ 8,-
5070 /*FOURTH*/ 0,-
5071 /*FIFTH*/ 0,-
5072 /*ALPHA*/ 8,-
5073 /*ALPHA USAGE*/ QPixelFormat::UsesAlpha,-
5074 /*ALPHA POSITION*/ QPixelFormat::AtEnd,-
5075 /*PREMULTIPLIED*/ QPixelFormat::Premultiplied,-
5076 /*INTERPRETATION*/ QPixelFormat::UnsignedByte,-
5077 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
5078 //QImage::Format_BGR30:-
5079 QPixelFormat(QPixelFormat::BGR,-
5080 /*RED*/ 10,-
5081 /*GREEN*/ 10,-
5082 /*BLUE*/ 10,-
5083 /*FOURTH*/ 0,-
5084 /*FIFTH*/ 0,-
5085 /*ALPHA*/ 2,-
5086 /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha,-
5087 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
5088 /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,-
5089 /*INTERPRETATION*/ QPixelFormat::UnsignedInteger,-
5090 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
5091 //QImage::Format_A2BGR30_Premultiplied:-
5092 QPixelFormat(QPixelFormat::BGR,-
5093 /*RED*/ 10,-
5094 /*GREEN*/ 10,-
5095 /*BLUE*/ 10,-
5096 /*FOURTH*/ 0,-
5097 /*FIFTH*/ 0,-
5098 /*ALPHA*/ 2,-
5099 /*ALPHA USAGE*/ QPixelFormat::UsesAlpha,-
5100 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
5101 /*PREMULTIPLIED*/ QPixelFormat::Premultiplied,-
5102 /*INTERPRETATION*/ QPixelFormat::UnsignedInteger,-
5103 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
5104 //QImage::Format_RGB30:-
5105 QPixelFormat(QPixelFormat::RGB,-
5106 /*RED*/ 10,-
5107 /*GREEN*/ 10,-
5108 /*BLUE*/ 10,-
5109 /*FOURTH*/ 0,-
5110 /*FIFTH*/ 0,-
5111 /*ALPHA*/ 2,-
5112 /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha,-
5113 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
5114 /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,-
5115 /*INTERPRETATION*/ QPixelFormat::UnsignedInteger,-
5116 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
5117 //QImage::Format_A2RGB30_Premultiplied:-
5118 QPixelFormat(QPixelFormat::RGB,-
5119 /*RED*/ 10,-
5120 /*GREEN*/ 10,-
5121 /*BLUE*/ 10,-
5122 /*FOURTH*/ 0,-
5123 /*FIFTH*/ 0,-
5124 /*ALPHA*/ 2,-
5125 /*ALPHA USAGE*/ QPixelFormat::UsesAlpha,-
5126 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
5127 /*PREMULTIPLIED*/ QPixelFormat::Premultiplied,-
5128 /*INTERPRETATION*/ QPixelFormat::UnsignedInteger,-
5129 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
5130 //QImage::Format_Alpha8:-
5131 QPixelFormat(QPixelFormat::Alpha,-
5132 /*First*/ 0,-
5133 /*SECOND*/ 0,-
5134 /*THIRD*/ 0,-
5135 /*FOURTH*/ 0,-
5136 /*FIFTH*/ 0,-
5137 /*ALPHA*/ 8,-
5138 /*ALPHA USAGE*/ QPixelFormat::UsesAlpha,-
5139 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
5140 /*PREMULTIPLIED*/ QPixelFormat::Premultiplied,-
5141 /*INTERPRETATION*/ QPixelFormat::UnsignedByte,-
5142 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
5143 //QImage::Format_Grayscale8:-
5144 QPixelFormat(QPixelFormat::Grayscale,-
5145 /*GRAY*/ 8,-
5146 /*SECOND*/ 0,-
5147 /*THIRD*/ 0,-
5148 /*FOURTH*/ 0,-
5149 /*FIFTH*/ 0,-
5150 /*ALPHA*/ 0,-
5151 /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha,-
5152 /*ALPHA POSITION*/ QPixelFormat::AtBeginning,-
5153 /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,-
5154 /*INTERPRETATION*/ QPixelFormat::UnsignedByte,-
5155 /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),-
5156};-
5157Q_STATIC_ASSERT(sizeof(pixelformats) / sizeof(*pixelformats) == QImage::NImageFormats);-
5158-
5159/*!-
5160 Returns the QImage::Format as a QPixelFormat-
5161*/-
5162QPixelFormat QImage::pixelFormat() const Q_DECL_NOTHROW-
5163{-
5164 return toPixelFormat(format());
never executed: return toPixelFormat(format());
0
5165}-
5166-
5167/*!-
5168 Converts \a format into a QPixelFormat-
5169*/-
5170QPixelFormat QImage::toPixelFormat(QImage::Format format) Q_DECL_NOTHROW-
5171{-
5172 Q_ASSERT(static_cast<int>(format) < NImageFormats);-
5173 return pixelformats[format];
never executed: return pixelformats[format];
0
5174}-
5175-
5176/*!-
5177 Converts \a format into a QImage::Format-
5178*/-
5179QImage::Format QImage::toImageFormat(QPixelFormat format) Q_DECL_NOTHROW-
5180{-
5181 for (int i = 0; i < NImageFormats; i++) {
i < NImageFormatsDescription
TRUEnever evaluated
FALSEnever evaluated
0
5182 if (format == pixelformats[i])
format == pixelformats[i]Description
TRUEnever evaluated
FALSEnever evaluated
0
5183 return Format(i);
never executed: return Format(i);
0
5184 }
never executed: end of block
0
5185 return Format_Invalid;
never executed: return Format_Invalid;
0
5186}-
5187-
5188Q_GUI_EXPORT void qt_imageTransform(QImage &src, QImageIOHandler::Transformations orient)-
5189{-
5190 if (orient == QImageIOHandler::TransformationNone)
orient == QIma...sformationNoneDescription
TRUEnever evaluated
FALSEnever evaluated
0
5191 return;
never executed: return;
0
5192 if (orient == QImageIOHandler::TransformationRotate270) {
orient == QIma...ationRotate270Description
TRUEnever evaluated
FALSEnever evaluated
0
5193 src = rotated270(src);-
5194 } else {
never executed: end of block
0
5195 src = qMove(src).mirrored(orient & QImageIOHandler::TransformationMirror,-
5196 orient & QImageIOHandler::TransformationFlip);-
5197 if (orient & QImageIOHandler::TransformationRotate90)
orient & QImag...mationRotate90Description
TRUEnever evaluated
FALSEnever evaluated
0
5198 src = rotated90(src);
never executed: src = rotated90(src);
0
5199 }
never executed: end of block
0
5200}-
5201-
5202QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9