Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include <qglobal.h> | - |
43 | | - |
44 | #include "qpixmap.h" | - |
45 | #include <qpa/qplatformpixmap.h> | - |
46 | #include "qimagepixmapcleanuphooks_p.h" | - |
47 | | - |
48 | #include "qbitmap.h" | - |
49 | #include "qimage.h" | - |
50 | #include "qpainter.h" | - |
51 | #include "qdatastream.h" | - |
52 | #include "qbuffer.h" | - |
53 | #include <private/qguiapplication_p.h> | - |
54 | #include "qevent.h" | - |
55 | #include "qfile.h" | - |
56 | #include "qfileinfo.h" | - |
57 | #include "qpixmapcache.h" | - |
58 | #include "qdatetime.h" | - |
59 | #include "qimagereader.h" | - |
60 | #include "qimagewriter.h" | - |
61 | #include "qpaintengine.h" | - |
62 | #include "qscreen.h" | - |
63 | #include "qthread.h" | - |
64 | #include "qdebug.h" | - |
65 | | - |
66 | #include <qpa/qplatformintegration.h> | - |
67 | | - |
68 | #include "qpixmap_raster_p.h" | - |
69 | #include "private/qhexstring_p.h" | - |
70 | | - |
71 | QT_BEGIN_NAMESPACE | - |
72 | | - |
73 | static bool qt_pixmap_thread_test() | - |
74 | { | - |
75 | if (!QCoreApplication::instance()) { partially evaluated: !QCoreApplication::instance() no Evaluation Count:0 | yes Evaluation Count:139993 |
| 0-139993 |
76 | qFatal("QPixmap: Must construct a QApplication before a QPaintDevice"); never executed (the execution status of this line is deduced): QMessageLogger("image/qpixmap.cpp", 76, __PRETTY_FUNCTION__).fatal("QPixmap: Must construct a QApplication before a QPaintDevice"); | - |
77 | return false; never executed: return false; | 0 |
78 | } | - |
79 | | - |
80 | if (qApp->thread() != QThread::currentThread()) { partially evaluated: (static_cast<QGuiApplication *>(QCoreApplication::instance()))->thread() != QThread::currentThread() no Evaluation Count:0 | yes Evaluation Count:139993 |
| 0-139993 |
81 | bool fail = false; never executed (the execution status of this line is deduced): bool fail = false; | - |
82 | if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps)) { never evaluated: !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps) | 0 |
83 | printf("Lighthouse plugin does not support threaded pixmaps!\n"); never executed (the execution status of this line is deduced): printf("Lighthouse plugin does not support threaded pixmaps!\n"); | - |
84 | fail = true; never executed (the execution status of this line is deduced): fail = true; | - |
85 | } | 0 |
86 | if (fail) { | 0 |
87 | qWarning("QPixmap: It is not safe to use pixmaps outside the GUI thread"); never executed (the execution status of this line is deduced): QMessageLogger("image/qpixmap.cpp", 87, __PRETTY_FUNCTION__).warning("QPixmap: It is not safe to use pixmaps outside the GUI thread"); | - |
88 | return false; never executed: return false; | 0 |
89 | } | - |
90 | } | 0 |
91 | return true; executed: return true; Execution Count:139993 | 139993 |
92 | } | - |
93 | | - |
94 | void QPixmap::doInit(int w, int h, int type) | - |
95 | { | - |
96 | if ((w > 0 && h > 0) || type == QPlatformPixmap::BitmapType) evaluated: w > 0 yes Evaluation Count:683 | yes Evaluation Count:107934 |
evaluated: h > 0 yes Evaluation Count:682 | yes Evaluation Count:1 |
evaluated: type == QPlatformPixmap::BitmapType yes Evaluation Count:113 | yes Evaluation Count:107822 |
| 1-107934 |
97 | data = QPlatformPixmap::create(w, h, (QPlatformPixmap::PixelType) type); executed: data = QPlatformPixmap::create(w, h, (QPlatformPixmap::PixelType) type); Execution Count:795 | 795 |
98 | else | - |
99 | data = 0; executed: data = 0; Execution Count:107822 | 107822 |
100 | } | - |
101 | | - |
102 | /*! | - |
103 | Constructs a null pixmap. | - |
104 | | - |
105 | \sa isNull() | - |
106 | */ | - |
107 | | - |
108 | QPixmap::QPixmap() | - |
109 | : QPaintDevice() | - |
110 | { | - |
111 | (void) qt_pixmap_thread_test(); executed (the execution status of this line is deduced): (void) qt_pixmap_thread_test(); | - |
112 | doInit(0, 0, QPlatformPixmap::PixmapType); executed (the execution status of this line is deduced): doInit(0, 0, QPlatformPixmap::PixmapType); | - |
113 | } executed: } Execution Count:104007 | 104007 |
114 | | - |
115 | /*! | - |
116 | \fn QPixmap::QPixmap(int width, int height) | - |
117 | | - |
118 | Constructs a pixmap with the given \a width and \a height. If | - |
119 | either \a width or \a height is zero, a null pixmap is | - |
120 | constructed. | - |
121 | | - |
122 | \warning This will create a QPixmap with uninitialized data. Call | - |
123 | fill() to fill the pixmap with an appropriate color before drawing | - |
124 | onto it with QPainter. | - |
125 | | - |
126 | \sa isNull() | - |
127 | */ | - |
128 | | - |
129 | QPixmap::QPixmap(int w, int h) | - |
130 | : QPaintDevice() | - |
131 | { | - |
132 | if (!qt_pixmap_thread_test()) partially evaluated: !qt_pixmap_thread_test() no Evaluation Count:0 | yes Evaluation Count:355 |
| 0-355 |
133 | doInit(0, 0, QPlatformPixmap::PixmapType); never executed: doInit(0, 0, QPlatformPixmap::PixmapType); | 0 |
134 | else | - |
135 | doInit(w, h, QPlatformPixmap::PixmapType); executed: doInit(w, h, QPlatformPixmap::PixmapType); Execution Count:355 | 355 |
136 | } | - |
137 | | - |
138 | /*! | - |
139 | \overload | - |
140 | | - |
141 | Constructs a pixmap of the given \a size. | - |
142 | | - |
143 | \warning This will create a QPixmap with uninitialized data. Call | - |
144 | fill() to fill the pixmap with an appropriate color before drawing | - |
145 | onto it with QPainter. | - |
146 | */ | - |
147 | | - |
148 | QPixmap::QPixmap(const QSize &size) | - |
149 | : QPaintDevice() | - |
150 | { | - |
151 | if (!qt_pixmap_thread_test()) partially evaluated: !qt_pixmap_thread_test() no Evaluation Count:0 | yes Evaluation Count:315 |
| 0-315 |
152 | doInit(0, 0, QPlatformPixmap::PixmapType); never executed: doInit(0, 0, QPlatformPixmap::PixmapType); | 0 |
153 | else | - |
154 | doInit(size.width(), size.height(), QPlatformPixmap::PixmapType); executed: doInit(size.width(), size.height(), QPlatformPixmap::PixmapType); Execution Count:315 | 315 |
155 | } | - |
156 | | - |
157 | /*! | - |
158 | \internal | - |
159 | */ | - |
160 | QPixmap::QPixmap(const QSize &s, int type) | - |
161 | { | - |
162 | if (!qt_pixmap_thread_test()) partially evaluated: !qt_pixmap_thread_test() no Evaluation Count:0 | yes Evaluation Count:130 |
| 0-130 |
163 | doInit(0, 0, static_cast<QPlatformPixmap::PixelType>(type)); never executed: doInit(0, 0, static_cast<QPlatformPixmap::PixelType>(type)); | 0 |
164 | else | - |
165 | doInit(s.width(), s.height(), static_cast<QPlatformPixmap::PixelType>(type)); executed: doInit(s.width(), s.height(), static_cast<QPlatformPixmap::PixelType>(type)); Execution Count:130 | 130 |
166 | } | - |
167 | | - |
168 | /*! | - |
169 | \internal | - |
170 | */ | - |
171 | QPixmap::QPixmap(QPlatformPixmap *d) | - |
172 | : QPaintDevice(), data(d) | - |
173 | { | - |
174 | } executed: } Execution Count:4069 | 4069 |
175 | | - |
176 | /*! | - |
177 | Constructs a pixmap from the file with the given \a fileName. If the | - |
178 | file does not exist or is of an unknown format, the pixmap becomes a | - |
179 | null pixmap. | - |
180 | | - |
181 | The loader attempts to read the pixmap using the specified \a | - |
182 | format. If the \a format is not specified (which is the default), | - |
183 | the loader probes the file for a header to guess the file format. | - |
184 | | - |
185 | The file name can either refer to an actual file on disk or to | - |
186 | one of the application's embedded resources. See the | - |
187 | \l{resources.html}{Resource System} overview for details on how | - |
188 | to embed images and other resource files in the application's | - |
189 | executable. | - |
190 | | - |
191 | If the image needs to be modified to fit in a lower-resolution | - |
192 | result (e.g. converting from 32-bit to 8-bit), use the \a | - |
193 | flags to control the conversion. | - |
194 | | - |
195 | The \a fileName, \a format and \a flags parameters are | - |
196 | passed on to load(). This means that the data in \a fileName is | - |
197 | not compiled into the binary. If \a fileName contains a relative | - |
198 | path (e.g. the filename only) the relevant file must be found | - |
199 | relative to the runtime working directory. | - |
200 | | - |
201 | \sa {QPixmap#Reading and Writing Image Files}{Reading and Writing | - |
202 | Image Files} | - |
203 | */ | - |
204 | | - |
205 | QPixmap::QPixmap(const QString& fileName, const char *format, Qt::ImageConversionFlags flags) | - |
206 | : QPaintDevice() | - |
207 | { | - |
208 | doInit(0, 0, QPlatformPixmap::PixmapType); executed (the execution status of this line is deduced): doInit(0, 0, QPlatformPixmap::PixmapType); | - |
209 | if (!qt_pixmap_thread_test()) partially evaluated: !qt_pixmap_thread_test() no Evaluation Count:0 | yes Evaluation Count:1753 |
| 0-1753 |
210 | return; | 0 |
211 | | - |
212 | load(fileName, format, flags); executed (the execution status of this line is deduced): load(fileName, format, flags); | - |
213 | } executed: } Execution Count:1753 | 1753 |
214 | | - |
215 | /*! | - |
216 | Constructs a pixmap that is a copy of the given \a pixmap. | - |
217 | | - |
218 | \sa copy() | - |
219 | */ | - |
220 | | - |
221 | QPixmap::QPixmap(const QPixmap &pixmap) | - |
222 | : QPaintDevice() | - |
223 | { | - |
224 | if (!qt_pixmap_thread_test()) { partially evaluated: !qt_pixmap_thread_test() no Evaluation Count:0 | yes Evaluation Count:33433 |
| 0-33433 |
225 | doInit(0, 0, QPlatformPixmap::PixmapType); never executed (the execution status of this line is deduced): doInit(0, 0, QPlatformPixmap::PixmapType); | - |
226 | return; | 0 |
227 | } | - |
228 | if (pixmap.paintingActive()) { // make a deep copy partially evaluated: pixmap.paintingActive() no Evaluation Count:0 | yes Evaluation Count:33433 |
| 0-33433 |
229 | pixmap.copy().swap(*this); never executed (the execution status of this line is deduced): pixmap.copy().swap(*this); | - |
230 | } else { | 0 |
231 | data = pixmap.data; executed (the execution status of this line is deduced): data = pixmap.data; | - |
232 | } executed: } Execution Count:33433 | 33433 |
233 | } | - |
234 | | - |
235 | /*! | - |
236 | Constructs a pixmap from the given \a xpm data, which must be a | - |
237 | valid XPM image. | - |
238 | | - |
239 | Errors are silently ignored. | - |
240 | | - |
241 | Note that it's possible to squeeze the XPM variable a little bit | - |
242 | by using an unusual declaration: | - |
243 | | - |
244 | \snippet code/src_gui_image_qpixmap.cpp 0 | - |
245 | | - |
246 | The extra \c const makes the entire definition read-only, which is | - |
247 | slightly more efficient (for example, when the code is in a shared | - |
248 | library) and ROMable when the application is to be stored in ROM. | - |
249 | */ | - |
250 | #ifndef QT_NO_IMAGEFORMAT_XPM | - |
251 | QPixmap::QPixmap(const char * const xpm[]) | - |
252 | : QPaintDevice() | - |
253 | { | - |
254 | doInit(0, 0, QPlatformPixmap::PixmapType); executed (the execution status of this line is deduced): doInit(0, 0, QPlatformPixmap::PixmapType); | - |
255 | if (!xpm) partially evaluated: !xpm no Evaluation Count:0 | yes Evaluation Count:2057 |
| 0-2057 |
256 | return; | 0 |
257 | | - |
258 | QImage image(xpm); executed (the execution status of this line is deduced): QImage image(xpm); | - |
259 | if (!image.isNull()) { partially evaluated: !image.isNull() yes Evaluation Count:2057 | no Evaluation Count:0 |
| 0-2057 |
260 | if (data && data->pixelType() == QPlatformPixmap::BitmapType) partially evaluated: data no Evaluation Count:0 | yes Evaluation Count:2057 |
never evaluated: data->pixelType() == QPlatformPixmap::BitmapType | 0-2057 |
261 | *this = QBitmap::fromImage(image); never executed: *this = QBitmap::fromImage(image); | 0 |
262 | else | - |
263 | *this = fromImage(image); executed: *this = fromImage(image); Execution Count:2057 | 2057 |
264 | } | - |
265 | } executed: } Execution Count:2057 | 2057 |
266 | #endif | - |
267 | | - |
268 | | - |
269 | /*! | - |
270 | Destroys the pixmap. | - |
271 | */ | - |
272 | | - |
273 | QPixmap::~QPixmap() | - |
274 | { | - |
275 | Q_ASSERT(!data || data->ref.load() >= 1); // Catch if ref-counting changes again executed (the execution status of this line is deduced): qt_noop(); | - |
276 | } executed: } Execution Count:145810 | 145810 |
277 | | - |
278 | /*! | - |
279 | \internal | - |
280 | */ | - |
281 | int QPixmap::devType() const | - |
282 | { | - |
283 | return QInternal::Pixmap; executed: return QInternal::Pixmap; Execution Count:4039 | 4039 |
284 | } | - |
285 | | - |
286 | /*! | - |
287 | \fn QPixmap QPixmap::copy(int x, int y, int width, int height) const | - |
288 | \overload | - |
289 | | - |
290 | Returns a deep copy of the subset of the pixmap that is specified | - |
291 | by the rectangle QRect( \a x, \a y, \a width, \a height). | - |
292 | */ | - |
293 | | - |
294 | /*! | - |
295 | \fn QPixmap QPixmap::copy(const QRect &rectangle) const | - |
296 | | - |
297 | Returns a deep copy of the subset of the pixmap that is specified | - |
298 | by the given \a rectangle. For more information on deep copies, | - |
299 | see the \l {Implicit Data Sharing} documentation. | - |
300 | | - |
301 | If the given \a rectangle is empty, the whole image is copied. | - |
302 | | - |
303 | \sa operator=(), QPixmap(), {QPixmap#Pixmap | - |
304 | Transformations}{Pixmap Transformations} | - |
305 | */ | - |
306 | QPixmap QPixmap::copy(const QRect &rect) const | - |
307 | { | - |
308 | if (isNull()) evaluated: isNull() yes Evaluation Count:1 | yes Evaluation Count:55 |
| 1-55 |
309 | return QPixmap(); executed: return QPixmap(); Execution Count:1 | 1 |
310 | | - |
311 | QRect r(0, 0, width(), height()); executed (the execution status of this line is deduced): QRect r(0, 0, width(), height()); | - |
312 | if (!rect.isEmpty()) evaluated: !rect.isEmpty() yes Evaluation Count:4 | yes Evaluation Count:51 |
| 4-51 |
313 | r = r.intersected(rect); executed: r = r.intersected(rect); Execution Count:4 | 4 |
314 | | - |
315 | QPlatformPixmap *d = data->createCompatiblePlatformPixmap(); executed (the execution status of this line is deduced): QPlatformPixmap *d = data->createCompatiblePlatformPixmap(); | - |
316 | d->copy(data.data(), r); executed (the execution status of this line is deduced): d->copy(data.data(), r); | - |
317 | return QPixmap(d); executed: return QPixmap(d); Execution Count:55 | 55 |
318 | } | - |
319 | | - |
320 | /*! | - |
321 | \fn QPixmap::scroll(int dx, int dy, int x, int y, int width, int height, QRegion *exposed) | - |
322 | \since 4.6 | - |
323 | | - |
324 | This convenience function is equivalent to calling QPixmap::scroll(\a dx, | - |
325 | \a dy, QRect(\a x, \a y, \a width, \a height), \a exposed). | - |
326 | | - |
327 | \sa QWidget::scroll(), QGraphicsItem::scroll() | - |
328 | */ | - |
329 | | - |
330 | /*! | - |
331 | \since 4.6 | - |
332 | | - |
333 | Scrolls the area \a rect of this pixmap by (\a dx, \a dy). The exposed | - |
334 | region is left unchanged. You can optionally pass a pointer to an empty | - |
335 | QRegion to get the region that is \a exposed by the scroll operation. | - |
336 | | - |
337 | \snippet code/src_gui_image_qpixmap.cpp 2 | - |
338 | | - |
339 | You cannot scroll while there is an active painter on the pixmap. | - |
340 | | - |
341 | \sa QWidget::scroll(), QGraphicsItem::scroll() | - |
342 | */ | - |
343 | void QPixmap::scroll(int dx, int dy, const QRect &rect, QRegion *exposed) | - |
344 | { | - |
345 | if (isNull() || (dx == 0 && dy == 0)) evaluated: isNull() yes Evaluation Count:1 | yes Evaluation Count:24 |
evaluated: dx == 0 yes Evaluation Count:10 | yes Evaluation Count:14 |
evaluated: dy == 0 yes Evaluation Count:3 | yes Evaluation Count:7 |
| 1-24 |
346 | return; executed: return; Execution Count:4 | 4 |
347 | QRect dest = rect & this->rect(); executed (the execution status of this line is deduced): QRect dest = rect & this->rect(); | - |
348 | QRect src = dest.translated(-dx, -dy) & dest; executed (the execution status of this line is deduced): QRect src = dest.translated(-dx, -dy) & dest; | - |
349 | if (src.isEmpty()) { evaluated: src.isEmpty() yes Evaluation Count:9 | yes Evaluation Count:12 |
| 9-12 |
350 | if (exposed) partially evaluated: exposed yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-9 |
351 | *exposed += dest; executed: *exposed += dest; Execution Count:9 | 9 |
352 | return; executed: return; Execution Count:9 | 9 |
353 | } | - |
354 | | - |
355 | detach(); executed (the execution status of this line is deduced): detach(); | - |
356 | | - |
357 | if (!data->scroll(dx, dy, src)) { partially evaluated: !data->scroll(dx, dy, src) no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
358 | // Fallback | - |
359 | QPixmap pix = *this; never executed (the execution status of this line is deduced): QPixmap pix = *this; | - |
360 | QPainter painter(&pix); never executed (the execution status of this line is deduced): QPainter painter(&pix); | - |
361 | painter.setCompositionMode(QPainter::CompositionMode_Source); never executed (the execution status of this line is deduced): painter.setCompositionMode(QPainter::CompositionMode_Source); | - |
362 | painter.drawPixmap(src.translated(dx, dy), *this, src); never executed (the execution status of this line is deduced): painter.drawPixmap(src.translated(dx, dy), *this, src); | - |
363 | painter.end(); never executed (the execution status of this line is deduced): painter.end(); | - |
364 | *this = pix; never executed (the execution status of this line is deduced): *this = pix; | - |
365 | } | 0 |
366 | | - |
367 | if (exposed) { partially evaluated: exposed yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
368 | *exposed += dest; executed (the execution status of this line is deduced): *exposed += dest; | - |
369 | *exposed -= src.translated(dx, dy); executed (the execution status of this line is deduced): *exposed -= src.translated(dx, dy); | - |
370 | } executed: } Execution Count:12 | 12 |
371 | } executed: } Execution Count:12 | 12 |
372 | | - |
373 | /*! | - |
374 | Assigns the given \a pixmap to this pixmap and returns a reference | - |
375 | to this pixmap. | - |
376 | | - |
377 | \sa copy(), QPixmap() | - |
378 | */ | - |
379 | | - |
380 | QPixmap &QPixmap::operator=(const QPixmap &pixmap) | - |
381 | { | - |
382 | if (paintingActive()) { partially evaluated: paintingActive() no Evaluation Count:0 | yes Evaluation Count:22606 |
| 0-22606 |
383 | qWarning("QPixmap::operator=: Cannot assign to pixmap during painting"); never executed (the execution status of this line is deduced): QMessageLogger("image/qpixmap.cpp", 383, __PRETTY_FUNCTION__).warning("QPixmap::operator=: Cannot assign to pixmap during painting"); | - |
384 | return *this; never executed: return *this; | 0 |
385 | } | - |
386 | if (pixmap.paintingActive()) { // make a deep copy partially evaluated: pixmap.paintingActive() no Evaluation Count:0 | yes Evaluation Count:22606 |
| 0-22606 |
387 | pixmap.copy().swap(*this); never executed (the execution status of this line is deduced): pixmap.copy().swap(*this); | - |
388 | } else { | 0 |
389 | data = pixmap.data; executed (the execution status of this line is deduced): data = pixmap.data; | - |
390 | } executed: } Execution Count:22606 | 22606 |
391 | return *this; executed: return *this; Execution Count:22606 | 22606 |
392 | } | - |
393 | | - |
394 | /*! | - |
395 | \fn void QPixmap::swap(QPixmap &other) | - |
396 | \since 4.8 | - |
397 | | - |
398 | Swaps pixmap \a other with this pixmap. This operation is very | - |
399 | fast and never fails. | - |
400 | */ | - |
401 | | - |
402 | /*! | - |
403 | Returns the pixmap as a QVariant. | - |
404 | */ | - |
405 | QPixmap::operator QVariant() const | - |
406 | { | - |
407 | return QVariant(QVariant::Pixmap, this); executed: return QVariant(QVariant::Pixmap, this); Execution Count:15 | 15 |
408 | } | - |
409 | | - |
410 | /*! | - |
411 | \fn bool QPixmap::operator!() const | - |
412 | | - |
413 | Returns true if this is a null pixmap; otherwise returns false. | - |
414 | | - |
415 | \sa isNull() | - |
416 | */ | - |
417 | | - |
418 | /*! | - |
419 | Converts the pixmap to a QImage. Returns a null image if the | - |
420 | conversion fails. | - |
421 | | - |
422 | If the pixmap has 1-bit depth, the returned image will also be 1 | - |
423 | bit deep. Images with more bits will be returned in a format | - |
424 | closely represents the underlying system. Usually this will be | - |
425 | QImage::Format_ARGB32_Premultiplied for pixmaps with an alpha and | - |
426 | QImage::Format_RGB32 or QImage::Format_RGB16 for pixmaps without | - |
427 | alpha. | - |
428 | | - |
429 | Note that for the moment, alpha masks on monochrome images are | - |
430 | ignored. | - |
431 | | - |
432 | \sa fromImage(), {QImage#Image Formats}{Image Formats} | - |
433 | */ | - |
434 | QImage QPixmap::toImage() const | - |
435 | { | - |
436 | if (isNull()) evaluated: isNull() yes Evaluation Count:16 | yes Evaluation Count:2024 |
| 16-2024 |
437 | return QImage(); executed: return QImage(); Execution Count:16 | 16 |
438 | | - |
439 | return data->toImage(); executed: return data->toImage(); Execution Count:2024 | 2024 |
440 | } | - |
441 | | - |
442 | /*! | - |
443 | \fn QMatrix QPixmap::trueMatrix(const QTransform &matrix, int width, int height) | - |
444 | | - |
445 | Returns the actual matrix used for transforming a pixmap with the | - |
446 | given \a width, \a height and \a matrix. | - |
447 | | - |
448 | When transforming a pixmap using the transformed() function, the | - |
449 | transformation matrix is internally adjusted to compensate for | - |
450 | unwanted translation, i.e. transformed() returns the smallest | - |
451 | pixmap containing all transformed points of the original | - |
452 | pixmap. This function returns the modified matrix, which maps | - |
453 | points correctly from the original pixmap into the new pixmap. | - |
454 | | - |
455 | \sa transformed(), {QPixmap#Pixmap Transformations}{Pixmap | - |
456 | Transformations} | - |
457 | */ | - |
458 | QTransform QPixmap::trueMatrix(const QTransform &m, int w, int h) | - |
459 | { | - |
460 | return QImage::trueMatrix(m, w, h); never executed: return QImage::trueMatrix(m, w, h); | 0 |
461 | } | - |
462 | | - |
463 | /*! | - |
464 | \overload | - |
465 | | - |
466 | This convenience function loads the matrix \a m into a | - |
467 | QTransform and calls the overloaded function with the | - |
468 | QTransform and the width \a w and the height \a h. | - |
469 | */ | - |
470 | QMatrix QPixmap::trueMatrix(const QMatrix &m, int w, int h) | - |
471 | { | - |
472 | return trueMatrix(QTransform(m), w, h).toAffine(); never executed: return trueMatrix(QTransform(m), w, h).toAffine(); | 0 |
473 | } | - |
474 | | - |
475 | | - |
476 | /*! | - |
477 | \fn bool QPixmap::isQBitmap() const | - |
478 | | - |
479 | Returns true if this is a QBitmap; otherwise returns false. | - |
480 | */ | - |
481 | | - |
482 | bool QPixmap::isQBitmap() const | - |
483 | { | - |
484 | return data->type == QPlatformPixmap::BitmapType; executed: return data->type == QPlatformPixmap::BitmapType; Execution Count:7 | 7 |
485 | } | - |
486 | | - |
487 | /*! | - |
488 | \fn bool QPixmap::isNull() const | - |
489 | | - |
490 | Returns true if this is a null pixmap; otherwise returns false. | - |
491 | | - |
492 | A null pixmap has zero width, zero height and no contents. You | - |
493 | cannot draw in a null pixmap. | - |
494 | */ | - |
495 | bool QPixmap::isNull() const | - |
496 | { | - |
497 | return !data || data->isNull(); executed: return !data || data->isNull(); Execution Count:76698 | 76698 |
498 | } | - |
499 | | - |
500 | /*! | - |
501 | \fn int QPixmap::width() const | - |
502 | | - |
503 | Returns the width of the pixmap. | - |
504 | | - |
505 | \sa size(), {QPixmap#Pixmap Information}{Pixmap Information} | - |
506 | */ | - |
507 | int QPixmap::width() const | - |
508 | { | - |
509 | return data ? data->width() : 0; executed: return data ? data->width() : 0; Execution Count:9778 | 9778 |
510 | } | - |
511 | | - |
512 | /*! | - |
513 | \fn int QPixmap::height() const | - |
514 | | - |
515 | Returns the height of the pixmap. | - |
516 | | - |
517 | \sa size(), {QPixmap#Pixmap Information}{Pixmap Information} | - |
518 | */ | - |
519 | int QPixmap::height() const | - |
520 | { | - |
521 | return data ? data->height() : 0; executed: return data ? data->height() : 0; Execution Count:9870 | 9870 |
522 | } | - |
523 | | - |
524 | /*! | - |
525 | \fn QSize QPixmap::size() const | - |
526 | | - |
527 | Returns the size of the pixmap. | - |
528 | | - |
529 | \sa width(), height(), {QPixmap#Pixmap Information}{Pixmap | - |
530 | Information} | - |
531 | */ | - |
532 | QSize QPixmap::size() const | - |
533 | { | - |
534 | return data ? QSize(data->width(), data->height()) : QSize(0, 0); executed: return data ? QSize(data->width(), data->height()) : QSize(0, 0); Execution Count:14817 | 14817 |
535 | } | - |
536 | | - |
537 | /*! | - |
538 | \fn QRect QPixmap::rect() const | - |
539 | | - |
540 | Returns the pixmap's enclosing rectangle. | - |
541 | | - |
542 | \sa {QPixmap#Pixmap Information}{Pixmap Information} | - |
543 | */ | - |
544 | QRect QPixmap::rect() const | - |
545 | { | - |
546 | return data ? QRect(0, 0, data->width(), data->height()) : QRect(); executed: return data ? QRect(0, 0, data->width(), data->height()) : QRect(); Execution Count:287 | 287 |
547 | } | - |
548 | | - |
549 | /*! | - |
550 | \fn int QPixmap::depth() const | - |
551 | | - |
552 | Returns the depth of the pixmap. | - |
553 | | - |
554 | The pixmap depth is also called bits per pixel (bpp) or bit planes | - |
555 | of a pixmap. A null pixmap has depth 0. | - |
556 | | - |
557 | \sa defaultDepth(), {QPixmap#Pixmap Information}{Pixmap | - |
558 | Information} | - |
559 | */ | - |
560 | int QPixmap::depth() const | - |
561 | { | - |
562 | return data ? data->depth() : 0; executed: return data ? data->depth() : 0; Execution Count:2848 | 2848 |
563 | } | - |
564 | | - |
565 | /*! | - |
566 | Sets a mask bitmap. | - |
567 | | - |
568 | This function merges the \a mask with the pixmap's alpha channel. A pixel | - |
569 | value of 1 on the mask means the pixmap's pixel is unchanged; a value of 0 | - |
570 | means the pixel is transparent. The mask must have the same size as this | - |
571 | pixmap. | - |
572 | | - |
573 | Setting a null mask resets the mask, leaving the previously transparent | - |
574 | pixels black. The effect of this function is undefined when the pixmap is | - |
575 | being painted on. | - |
576 | | - |
577 | \warning This is potentially an expensive operation. | - |
578 | | - |
579 | \sa mask(), {QPixmap#Pixmap Transformations}{Pixmap Transformations}, | - |
580 | QBitmap | - |
581 | */ | - |
582 | void QPixmap::setMask(const QBitmap &mask) | - |
583 | { | - |
584 | if (paintingActive()) { partially evaluated: paintingActive() no Evaluation Count:0 | yes Evaluation Count:64 |
| 0-64 |
585 | qWarning("QPixmap::setMask: Cannot set mask while pixmap is being painted on"); never executed (the execution status of this line is deduced): QMessageLogger("image/qpixmap.cpp", 585, __PRETTY_FUNCTION__).warning("QPixmap::setMask: Cannot set mask while pixmap is being painted on"); | - |
586 | return; | 0 |
587 | } | - |
588 | | - |
589 | if (!mask.isNull() && mask.size() != size()) { evaluated: !mask.isNull() yes Evaluation Count:5 | yes Evaluation Count:59 |
partially evaluated: mask.size() != size() no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-59 |
590 | qWarning("QPixmap::setMask() mask size differs from pixmap size"); never executed (the execution status of this line is deduced): QMessageLogger("image/qpixmap.cpp", 590, __PRETTY_FUNCTION__).warning("QPixmap::setMask() mask size differs from pixmap size"); | - |
591 | return; | 0 |
592 | } | - |
593 | | - |
594 | if (isNull()) evaluated: isNull() yes Evaluation Count:2 | yes Evaluation Count:62 |
| 2-62 |
595 | return; executed: return; Execution Count:2 | 2 |
596 | | - |
597 | if (static_cast<const QPixmap &>(mask).data == data) // trying to selfmask partially evaluated: static_cast<const QPixmap &>(mask).data == data no Evaluation Count:0 | yes Evaluation Count:62 |
| 0-62 |
598 | return; | 0 |
599 | | - |
600 | detach(); executed (the execution status of this line is deduced): detach(); | - |
601 | | - |
602 | QImage image = data->toImage(); executed (the execution status of this line is deduced): QImage image = data->toImage(); | - |
603 | if (mask.size().isEmpty()) { evaluated: mask.size().isEmpty() yes Evaluation Count:57 | yes Evaluation Count:5 |
| 5-57 |
604 | if (image.depth() != 1) { // hw: ???? evaluated: image.depth() != 1 yes Evaluation Count:3 | yes Evaluation Count:54 |
| 3-54 |
605 | image = image.convertToFormat(QImage::Format_RGB32); executed (the execution status of this line is deduced): image = image.convertToFormat(QImage::Format_RGB32); | - |
606 | } executed: } Execution Count:3 | 3 |
607 | } else { executed: } Execution Count:57 | 57 |
608 | const int w = image.width(); executed (the execution status of this line is deduced): const int w = image.width(); | - |
609 | const int h = image.height(); executed (the execution status of this line is deduced): const int h = image.height(); | - |
610 | | - |
611 | switch (image.depth()) { | - |
612 | case 1: { | - |
613 | const QImage imageMask = mask.toImage().convertToFormat(image.format()); executed (the execution status of this line is deduced): const QImage imageMask = mask.toImage().convertToFormat(image.format()); | - |
614 | for (int y = 0; y < h; ++y) { evaluated: y < h yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
615 | const uchar *mscan = imageMask.scanLine(y); executed (the execution status of this line is deduced): const uchar *mscan = imageMask.scanLine(y); | - |
616 | uchar *tscan = image.scanLine(y); executed (the execution status of this line is deduced): uchar *tscan = image.scanLine(y); | - |
617 | int bytesPerLine = image.bytesPerLine(); executed (the execution status of this line is deduced): int bytesPerLine = image.bytesPerLine(); | - |
618 | for (int i = 0; i < bytesPerLine; ++i) evaluated: i < bytesPerLine yes Evaluation Count:12 | yes Evaluation Count:3 |
| 3-12 |
619 | tscan[i] &= mscan[i]; executed: tscan[i] &= mscan[i]; Execution Count:12 | 12 |
620 | } executed: } Execution Count:3 | 3 |
621 | break; executed: break; Execution Count:1 | 1 |
622 | } | - |
623 | default: { | - |
624 | const QImage imageMask = mask.toImage().convertToFormat(QImage::Format_MonoLSB); executed (the execution status of this line is deduced): const QImage imageMask = mask.toImage().convertToFormat(QImage::Format_MonoLSB); | - |
625 | image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); executed (the execution status of this line is deduced): image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); | - |
626 | for (int y = 0; y < h; ++y) { evaluated: y < h yes Evaluation Count:220 | yes Evaluation Count:4 |
| 4-220 |
627 | const uchar *mscan = imageMask.scanLine(y); executed (the execution status of this line is deduced): const uchar *mscan = imageMask.scanLine(y); | - |
628 | QRgb *tscan = (QRgb *)image.scanLine(y); executed (the execution status of this line is deduced): QRgb *tscan = (QRgb *)image.scanLine(y); | - |
629 | for (int x = 0; x < w; ++x) { evaluated: x < w yes Evaluation Count:20200 | yes Evaluation Count:220 |
| 220-20200 |
630 | if (!(mscan[x>>3] & (1 << (x&7)))) evaluated: !(mscan[x>>3] & (1 << (x&7))) yes Evaluation Count:20175 | yes Evaluation Count:25 |
| 25-20175 |
631 | tscan[x] = 0; executed: tscan[x] = 0; Execution Count:20175 | 20175 |
632 | } executed: } Execution Count:20200 | 20200 |
633 | } executed: } Execution Count:220 | 220 |
634 | break; executed: break; Execution Count:4 | 4 |
635 | } | - |
636 | } | - |
637 | } executed: } Execution Count:5 | 5 |
638 | data->fromImage(image, Qt::AutoColor); executed (the execution status of this line is deduced): data->fromImage(image, Qt::AutoColor); | - |
639 | } executed: } Execution Count:62 | 62 |
640 | | - |
641 | /*! | - |
642 | Returns the device pixel ratio for the pixmap. This is the | - |
643 | ratio between pixmap pixels and device-independent pixels. | - |
644 | | - |
645 | Use this function when calculating layout geometry based on | - |
646 | the pixmap size: QSize layoutSize = image.size() / image.devicePixelRatio() | - |
647 | | - |
648 | The default value is 1.0. | - |
649 | | - |
650 | \sa setDevicePixelRatio() | - |
651 | */ | - |
652 | qreal QPixmap::devicePixelRatio() const | - |
653 | { | - |
654 | if (!data) evaluated: !data yes Evaluation Count:10 | yes Evaluation Count:5502 |
| 10-5502 |
655 | return qreal(1.0); executed: return qreal(1.0); Execution Count:10 | 10 |
656 | return data->devicePixelRatio(); executed: return data->devicePixelRatio(); Execution Count:5502 | 5502 |
657 | } | - |
658 | | - |
659 | /*! | - |
660 | Sets the the device pixel ratio for the pixmap. This is the | - |
661 | ratio between image pixels and device-independent pixels. | - |
662 | | - |
663 | The default value is 1.0. Setting it to something else has | - |
664 | two effects: | - |
665 | | - |
666 | QPainters that are opened on the pixmap will be scaled. For | - |
667 | example, painting on a 200x200 image if with a ratio of 2.0 | - |
668 | will result in effective (device-independent) painting bounds | - |
669 | of 100x100. | - |
670 | | - |
671 | Code paths in Qt that calculate layout geometry based on the | - |
672 | pixmap size will take the ratio into account: | - |
673 | QSize layoutSize = pixmap.size() / pixmap.devicePixelRatio() | - |
674 | The net effect of this is that the pixmap is displayed as | - |
675 | high-dpi pixmap rather than a large pixmap. | - |
676 | | - |
677 | \sa devicePixelRatio() | - |
678 | */ | - |
679 | void QPixmap::setDevicePixelRatio(qreal scaleFactor) | - |
680 | { | - |
681 | detach(); executed (the execution status of this line is deduced): detach(); | - |
682 | data->setDevicePixelRatio(scaleFactor); executed (the execution status of this line is deduced): data->setDevicePixelRatio(scaleFactor); | - |
683 | } executed: } Execution Count:8 | 8 |
684 | | - |
685 | #ifndef QT_NO_IMAGE_HEURISTIC_MASK | - |
686 | /*! | - |
687 | Creates and returns a heuristic mask for this pixmap. | - |
688 | | - |
689 | The function works by selecting a color from one of the corners | - |
690 | and then chipping away pixels of that color, starting at all the | - |
691 | edges. If \a clipTight is true (the default) the mask is just | - |
692 | large enough to cover the pixels; otherwise, the mask is larger | - |
693 | than the data pixels. | - |
694 | | - |
695 | The mask may not be perfect but it should be reasonable, so you | - |
696 | can do things such as the following: | - |
697 | | - |
698 | \snippet code/src_gui_image_qpixmap.cpp 1 | - |
699 | | - |
700 | This function is slow because it involves converting to/from a | - |
701 | QImage, and non-trivial computations. | - |
702 | | - |
703 | \sa QImage::createHeuristicMask(), createMaskFromColor() | - |
704 | */ | - |
705 | QBitmap QPixmap::createHeuristicMask(bool clipTight) const | - |
706 | { | - |
707 | QBitmap m = QBitmap::fromImage(toImage().createHeuristicMask(clipTight)); never executed (the execution status of this line is deduced): QBitmap m = QBitmap::fromImage(toImage().createHeuristicMask(clipTight)); | - |
708 | return m; never executed: return m; | 0 |
709 | } | - |
710 | #endif | - |
711 | | - |
712 | /*! | - |
713 | Creates and returns a mask for this pixmap based on the given \a | - |
714 | maskColor. If the \a mode is Qt::MaskInColor, all pixels matching the | - |
715 | maskColor will be transparent. If \a mode is Qt::MaskOutColor, all pixels | - |
716 | matching the maskColor will be opaque. | - |
717 | | - |
718 | This function is slow because it involves converting to/from a | - |
719 | QImage. | - |
720 | | - |
721 | \sa createHeuristicMask(), QImage::createMaskFromColor() | - |
722 | */ | - |
723 | QBitmap QPixmap::createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode) const | - |
724 | { | - |
725 | QImage image = toImage().convertToFormat(QImage::Format_ARGB32); executed (the execution status of this line is deduced): QImage image = toImage().convertToFormat(QImage::Format_ARGB32); | - |
726 | return QBitmap::fromImage(image.createMaskFromColor(maskColor.rgba(), mode)); executed: return QBitmap::fromImage(image.createMaskFromColor(maskColor.rgba(), mode)); Execution Count:2 | 2 |
727 | } | - |
728 | | - |
729 | /*! | - |
730 | Loads a pixmap from the file with the given \a fileName. Returns | - |
731 | true if the pixmap was successfully loaded; otherwise invalidates | - |
732 | the pixmap and returns false. | - |
733 | | - |
734 | The loader attempts to read the pixmap using the specified \a | - |
735 | format. If the \a format is not specified (which is the default), | - |
736 | the loader probes the file for a header to guess the file format. | - |
737 | | - |
738 | The file name can either refer to an actual file on disk or to one | - |
739 | of the application's embedded resources. See the | - |
740 | \l{resources.html}{Resource System} overview for details on how to | - |
741 | embed pixmaps and other resource files in the application's | - |
742 | executable. | - |
743 | | - |
744 | If the data needs to be modified to fit in a lower-resolution | - |
745 | result (e.g. converting from 32-bit to 8-bit), use the \a flags to | - |
746 | control the conversion. | - |
747 | | - |
748 | Note that QPixmaps are automatically added to the QPixmapCache | - |
749 | when loaded from a file; the key used is internal and can not | - |
750 | be acquired. | - |
751 | | - |
752 | \sa loadFromData(), {QPixmap#Reading and Writing Image | - |
753 | Files}{Reading and Writing Image Files} | - |
754 | */ | - |
755 | | - |
756 | bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConversionFlags flags) | - |
757 | { | - |
758 | if (fileName.isEmpty()) { evaluated: fileName.isEmpty() yes Evaluation Count:54 | yes Evaluation Count:1711 |
| 54-1711 |
759 | data.reset(); executed (the execution status of this line is deduced): data.reset(); | - |
760 | return false; executed: return false; Execution Count:54 | 54 |
761 | } | - |
762 | | - |
763 | detach(); executed (the execution status of this line is deduced): detach(); | - |
764 | | - |
765 | QFileInfo info(fileName); executed (the execution status of this line is deduced): QFileInfo info(fileName); | - |
766 | QString key = QLatin1String("qt_pixmap") executed (the execution status of this line is deduced): QString key = QLatin1String("qt_pixmap") | - |
767 | % info.absoluteFilePath() executed (the execution status of this line is deduced): % info.absoluteFilePath() | - |
768 | % HexString<uint>(info.lastModified().toTime_t()) executed (the execution status of this line is deduced): % HexString<uint>(info.lastModified().toTime_t()) | - |
769 | % HexString<quint64>(info.size()) executed (the execution status of this line is deduced): % HexString<quint64>(info.size()) | - |
770 | % HexString<uint>(data ? data->pixelType() : QPlatformPixmap::PixmapType); executed (the execution status of this line is deduced): % HexString<uint>(data ? data->pixelType() : QPlatformPixmap::PixmapType); | - |
771 | | - |
772 | // Note: If no extension is provided, we try to match the | - |
773 | // file against known plugin extensions | - |
774 | if (!info.completeSuffix().isEmpty() && !info.exists()) { evaluated: !info.completeSuffix().isEmpty() yes Evaluation Count:1706 | yes Evaluation Count:5 |
evaluated: !info.exists() yes Evaluation Count:9 | yes Evaluation Count:1697 |
| 5-1706 |
775 | data.reset(); executed (the execution status of this line is deduced): data.reset(); | - |
776 | return false; executed: return false; Execution Count:9 | 9 |
777 | } | - |
778 | | - |
779 | if (QPixmapCache::find(key, this)) evaluated: QPixmapCache::find(key, this) yes Evaluation Count:1575 | yes Evaluation Count:127 |
| 127-1575 |
780 | return true; executed: return true; Execution Count:1575 | 1575 |
781 | | - |
782 | if (!data) evaluated: !data yes Evaluation Count:125 | yes Evaluation Count:2 |
| 2-125 |
783 | data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType); executed: data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType); Execution Count:125 | 125 |
784 | | - |
785 | if (data->fromFile(fileName, format, flags)) { evaluated: data->fromFile(fileName, format, flags) yes Evaluation Count:122 | yes Evaluation Count:5 |
| 5-122 |
786 | QPixmapCache::insert(key, *this); executed (the execution status of this line is deduced): QPixmapCache::insert(key, *this); | - |
787 | return true; executed: return true; Execution Count:122 | 122 |
788 | } | - |
789 | | - |
790 | data.reset(); executed (the execution status of this line is deduced): data.reset(); | - |
791 | return false; executed: return false; Execution Count:5 | 5 |
792 | } | - |
793 | | - |
794 | /*! | - |
795 | \fn bool QPixmap::loadFromData(const uchar *data, uint len, const char *format, Qt::ImageConversionFlags flags) | - |
796 | | - |
797 | Loads a pixmap from the \a len first bytes of the given binary \a | - |
798 | data. Returns true if the pixmap was loaded successfully; | - |
799 | otherwise invalidates the pixmap and returns false. | - |
800 | | - |
801 | The loader attempts to read the pixmap using the specified \a | - |
802 | format. If the \a format is not specified (which is the default), | - |
803 | the loader probes the file for a header to guess the file format. | - |
804 | | - |
805 | If the data needs to be modified to fit in a lower-resolution | - |
806 | result (e.g. converting from 32-bit to 8-bit), use the \a flags to | - |
807 | control the conversion. | - |
808 | | - |
809 | \sa load(), {QPixmap#Reading and Writing Image Files}{Reading and | - |
810 | Writing Image Files} | - |
811 | */ | - |
812 | | - |
813 | bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags) | - |
814 | { | - |
815 | if (len == 0 || buf == 0) { evaluated: len == 0 yes Evaluation Count:3 | yes Evaluation Count:19 |
evaluated: buf == 0 yes Evaluation Count:1 | yes Evaluation Count:18 |
| 1-19 |
816 | data.reset(); executed (the execution status of this line is deduced): data.reset(); | - |
817 | return false; executed: return false; Execution Count:4 | 4 |
818 | } | - |
819 | | - |
820 | if (!data) partially evaluated: !data yes Evaluation Count:18 | no Evaluation Count:0 |
| 0-18 |
821 | data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType); executed: data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType); Execution Count:18 | 18 |
822 | | - |
823 | if (data->fromData(buf, len, format, flags)) partially evaluated: data->fromData(buf, len, format, flags) yes Evaluation Count:18 | no Evaluation Count:0 |
| 0-18 |
824 | return true; executed: return true; Execution Count:18 | 18 |
825 | | - |
826 | data.reset(); never executed (the execution status of this line is deduced): data.reset(); | - |
827 | return false; never executed: return false; | 0 |
828 | } | - |
829 | | - |
830 | /*! | - |
831 | \fn bool QPixmap::loadFromData(const QByteArray &data, const char *format, Qt::ImageConversionFlags flags) | - |
832 | | - |
833 | \overload | - |
834 | | - |
835 | Loads a pixmap from the binary \a data using the specified \a | - |
836 | format and conversion \a flags. | - |
837 | */ | - |
838 | | - |
839 | | - |
840 | /*! | - |
841 | Saves the pixmap to the file with the given \a fileName using the | - |
842 | specified image file \a format and \a quality factor. Returns true | - |
843 | if successful; otherwise returns false. | - |
844 | | - |
845 | The \a quality factor must be in the range [0,100] or -1. Specify | - |
846 | 0 to obtain small compressed files, 100 for large uncompressed | - |
847 | files, and -1 to use the default settings. | - |
848 | | - |
849 | If \a format is 0, an image format will be chosen from \a fileName's | - |
850 | suffix. | - |
851 | | - |
852 | \sa {QPixmap#Reading and Writing Image Files}{Reading and Writing | - |
853 | Image Files} | - |
854 | */ | - |
855 | | - |
856 | bool QPixmap::save(const QString &fileName, const char *format, int quality) const | - |
857 | { | - |
858 | if (isNull()) never evaluated: isNull() | 0 |
859 | return false; // nothing to save never executed: return false; | 0 |
860 | QImageWriter writer(fileName, format); never executed (the execution status of this line is deduced): QImageWriter writer(fileName, format); | - |
861 | return doImageIO(&writer, quality); never executed: return doImageIO(&writer, quality); | 0 |
862 | } | - |
863 | | - |
864 | /*! | - |
865 | \overload | - |
866 | | - |
867 | This function writes a QPixmap to the given \a device using the | - |
868 | specified image file \a format and \a quality factor. This can be | - |
869 | used, for example, to save a pixmap directly into a QByteArray: | - |
870 | | - |
871 | \snippet image/image.cpp 1 | - |
872 | */ | - |
873 | | - |
874 | bool QPixmap::save(QIODevice* device, const char* format, int quality) const | - |
875 | { | - |
876 | if (isNull()) partially evaluated: isNull() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
877 | return false; // nothing to save never executed: return false; | 0 |
878 | QImageWriter writer(device, format); executed (the execution status of this line is deduced): QImageWriter writer(device, format); | - |
879 | return doImageIO(&writer, quality); executed: return doImageIO(&writer, quality); Execution Count:1 | 1 |
880 | } | - |
881 | | - |
882 | /*! \internal | - |
883 | */ | - |
884 | bool QPixmap::doImageIO(QImageWriter *writer, int quality) const | - |
885 | { | - |
886 | if (quality > 100 || quality < -1) partially evaluated: quality > 100 no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: quality < -1 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
887 | qWarning("QPixmap::save: quality out of range [-1,100]"); never executed: QMessageLogger("image/qpixmap.cpp", 887, __PRETTY_FUNCTION__).warning("QPixmap::save: quality out of range [-1,100]"); | 0 |
888 | if (quality >= 0) partially evaluated: quality >= 0 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
889 | writer->setQuality(qMin(quality,100)); never executed: writer->setQuality(qMin(quality,100)); | 0 |
890 | return writer->write(toImage()); executed: return writer->write(toImage()); Execution Count:1 | 1 |
891 | } | - |
892 | | - |
893 | | - |
894 | /*! | - |
895 | \obsolete | - |
896 | | - |
897 | Use QPainter or the fill(QColor) overload instead. | - |
898 | */ | - |
899 | | - |
900 | void QPixmap::fill(const QPaintDevice *device, const QPoint &p) | - |
901 | { | - |
902 | Q_UNUSED(device) never executed (the execution status of this line is deduced): (void)device; | - |
903 | Q_UNUSED(p) never executed (the execution status of this line is deduced): (void)p; | - |
904 | qWarning("%s is deprecated, ignored", Q_FUNC_INFO); never executed (the execution status of this line is deduced): QMessageLogger("image/qpixmap.cpp", 904, __PRETTY_FUNCTION__).warning("%s is deprecated, ignored", __PRETTY_FUNCTION__); | - |
905 | } | 0 |
906 | | - |
907 | | - |
908 | /*! | - |
909 | \fn void QPixmap::fill(const QPaintDevice *device, int x, int y) | - |
910 | \obsolete | - |
911 | | - |
912 | Use QPainter or the fill(QColor) overload instead. | - |
913 | */ | - |
914 | | - |
915 | | - |
916 | /*! | - |
917 | Fills the pixmap with the given \a color. | - |
918 | | - |
919 | The effect of this function is undefined when the pixmap is | - |
920 | being painted on. | - |
921 | | - |
922 | \sa {QPixmap#Pixmap Transformations}{Pixmap Transformations} | - |
923 | */ | - |
924 | | - |
925 | void QPixmap::fill(const QColor &color) | - |
926 | { | - |
927 | if (isNull()) evaluated: isNull() yes Evaluation Count:4 | yes Evaluation Count:423 |
| 4-423 |
928 | return; executed: return; Execution Count:4 | 4 |
929 | | - |
930 | // Some people are probably already calling fill while a painter is active, so to not break | - |
931 | // their programs, only print a warning and return when the fill operation could cause a crash. | - |
932 | if (paintingActive() && (color.alpha() != 255) && !hasAlphaChannel()) { partially evaluated: paintingActive() no Evaluation Count:0 | yes Evaluation Count:423 |
never evaluated: (color.alpha() != 255) never evaluated: !hasAlphaChannel() | 0-423 |
933 | qWarning("QPixmap::fill: Cannot fill while pixmap is being painted on"); never executed (the execution status of this line is deduced): QMessageLogger("image/qpixmap.cpp", 933, __PRETTY_FUNCTION__).warning("QPixmap::fill: Cannot fill while pixmap is being painted on"); | - |
934 | return; | 0 |
935 | } | - |
936 | | - |
937 | if (data->ref.load() == 1) { evaluated: data->ref.load() == 1 yes Evaluation Count:413 | yes Evaluation Count:10 |
| 10-413 |
938 | // detach() will also remove this pixmap from caches, so | - |
939 | // it has to be called even when ref == 1. | - |
940 | detach(); executed (the execution status of this line is deduced): detach(); | - |
941 | } else { executed: } Execution Count:413 | 413 |
942 | // Don't bother to make a copy of the data object, since | - |
943 | // it will be filled with new pixel data anyway. | - |
944 | QPlatformPixmap *d = data->createCompatiblePlatformPixmap(); executed (the execution status of this line is deduced): QPlatformPixmap *d = data->createCompatiblePlatformPixmap(); | - |
945 | d->resize(data->width(), data->height()); executed (the execution status of this line is deduced): d->resize(data->width(), data->height()); | - |
946 | data = d; executed (the execution status of this line is deduced): data = d; | - |
947 | } executed: } Execution Count:10 | 10 |
948 | data->fill(color); executed (the execution status of this line is deduced): data->fill(color); | - |
949 | } executed: } Execution Count:423 | 423 |
950 | | - |
951 | /*! \fn int QPixmap::serialNumber() const | - |
952 | \obsolete | - |
953 | Returns a number that identifies the contents of this QPixmap | - |
954 | object. Distinct QPixmap objects can only have the same serial | - |
955 | number if they refer to the same contents (but they don't have | - |
956 | to). | - |
957 | | - |
958 | Use cacheKey() instead. | - |
959 | | - |
960 | \warning The serial number doesn't necessarily change when | - |
961 | the pixmap is altered. This means that it may be dangerous to use | - |
962 | it as a cache key. For caching pixmaps, we recommend using the | - |
963 | QPixmapCache class whenever possible. | - |
964 | */ | - |
965 | | - |
966 | /*! | - |
967 | Returns a number that identifies this QPixmap. Distinct QPixmap | - |
968 | objects can only have the same cache key if they refer to the same | - |
969 | contents. | - |
970 | | - |
971 | The cacheKey() will change when the pixmap is altered. | - |
972 | */ | - |
973 | qint64 QPixmap::cacheKey() const | - |
974 | { | - |
975 | if (isNull()) evaluated: isNull() yes Evaluation Count:23 | yes Evaluation Count:4416 |
| 23-4416 |
976 | return 0; executed: return 0; Execution Count:23 | 23 |
977 | | - |
978 | Q_ASSERT(data); executed (the execution status of this line is deduced): qt_noop(); | - |
979 | return data->cacheKey(); executed: return data->cacheKey(); Execution Count:4416 | 4416 |
980 | } | - |
981 | | - |
982 | #if 0 | - |
983 | static void sendResizeEvents(QWidget *target) | - |
984 | { | - |
985 | QResizeEvent e(target->size(), QSize()); | - |
986 | QApplication::sendEvent(target, &e); | - |
987 | | - |
988 | const QObjectList children = target->children(); | - |
989 | for (int i = 0; i < children.size(); ++i) { | - |
990 | QWidget *child = static_cast<QWidget*>(children.at(i)); | - |
991 | if (child->isWidgetType() && !child->isWindow() && child->testAttribute(Qt::WA_PendingResizeEvent)) | - |
992 | sendResizeEvents(child); | - |
993 | } | - |
994 | } | - |
995 | #endif | - |
996 | | - |
997 | /*! | - |
998 | \obsolete | - |
999 | | - |
1000 | Use QWidget::grab() instead. | - |
1001 | */ | - |
1002 | QPixmap QPixmap::grabWidget(QObject *widget, const QRect &rectangle) | - |
1003 | { | - |
1004 | QPixmap pixmap; never executed (the execution status of this line is deduced): QPixmap pixmap; | - |
1005 | qWarning("QPixmap::grabWidget is deprecated, use QWidget::grab() instead"); never executed (the execution status of this line is deduced): QMessageLogger("image/qpixmap.cpp", 1005, __PRETTY_FUNCTION__).warning("QPixmap::grabWidget is deprecated, use QWidget::grab() instead"); | - |
1006 | if (!widget) | 0 |
1007 | return pixmap; never executed: return pixmap; | 0 |
1008 | QMetaObject::invokeMethod(widget, "grab", Qt::DirectConnection, never executed (the execution status of this line is deduced): QMetaObject::invokeMethod(widget, "grab", Qt::DirectConnection, | - |
1009 | Q_RETURN_ARG(QPixmap, pixmap), never executed (the execution status of this line is deduced): QReturnArgument<QPixmap >("QPixmap", pixmap), | - |
1010 | Q_ARG(QRect, rectangle)); never executed (the execution status of this line is deduced): QArgument<QRect >("QRect", rectangle)); | - |
1011 | return pixmap; never executed: return pixmap; | 0 |
1012 | } | - |
1013 | | - |
1014 | /*! | - |
1015 | \fn QPixmap QPixmap::grabWidget(QObject *widget, int x, int y, int w, int h) | - |
1016 | \obsolete | - |
1017 | | - |
1018 | Use QWidget::grab() instead. | - |
1019 | */ | - |
1020 | | - |
1021 | /***************************************************************************** | - |
1022 | QPixmap stream functions | - |
1023 | *****************************************************************************/ | - |
1024 | #if !defined(QT_NO_DATASTREAM) | - |
1025 | /*! | - |
1026 | \relates QPixmap | - |
1027 | | - |
1028 | Writes the given \a pixmap to the given \a stream as a PNG | - |
1029 | image. Note that writing the stream to a file will not produce a | - |
1030 | valid image file. | - |
1031 | | - |
1032 | \sa QPixmap::save(), {Serializing Qt Data Types} | - |
1033 | */ | - |
1034 | | - |
1035 | QDataStream &operator<<(QDataStream &stream, const QPixmap &pixmap) | - |
1036 | { | - |
1037 | return stream << pixmap.toImage(); executed: return stream << pixmap.toImage(); Execution Count:59 | 59 |
1038 | } | - |
1039 | | - |
1040 | /*! | - |
1041 | \relates QPixmap | - |
1042 | | - |
1043 | Reads an image from the given \a stream into the given \a pixmap. | - |
1044 | | - |
1045 | \sa QPixmap::load(), {Serializing Qt Data Types} | - |
1046 | */ | - |
1047 | | - |
1048 | QDataStream &operator>>(QDataStream &stream, QPixmap &pixmap) | - |
1049 | { | - |
1050 | QImage image; executed (the execution status of this line is deduced): QImage image; | - |
1051 | stream >> image; executed (the execution status of this line is deduced): stream >> image; | - |
1052 | | - |
1053 | if (image.isNull()) { evaluated: image.isNull() yes Evaluation Count:3 | yes Evaluation Count:55 |
| 3-55 |
1054 | pixmap = QPixmap(); executed (the execution status of this line is deduced): pixmap = QPixmap(); | - |
1055 | } else if (image.depth() == 1) { executed: } Execution Count:3 evaluated: image.depth() == 1 yes Evaluation Count:13 | yes Evaluation Count:42 |
| 3-42 |
1056 | pixmap = QBitmap::fromImage(image); executed (the execution status of this line is deduced): pixmap = QBitmap::fromImage(image); | - |
1057 | } else { executed: } Execution Count:13 | 13 |
1058 | pixmap = QPixmap::fromImage(image); executed (the execution status of this line is deduced): pixmap = QPixmap::fromImage(image); | - |
1059 | } executed: } Execution Count:42 | 42 |
1060 | return stream; executed: return stream; Execution Count:58 | 58 |
1061 | } | - |
1062 | | - |
1063 | #endif // QT_NO_DATASTREAM | - |
1064 | | - |
1065 | /*! | - |
1066 | \internal | - |
1067 | */ | - |
1068 | | - |
1069 | bool QPixmap::isDetached() const | - |
1070 | { | - |
1071 | return data && data->ref.load() == 1; executed: return data && data->ref.load() == 1; Execution Count:4 | 4 |
1072 | } | - |
1073 | | - |
1074 | /*! | - |
1075 | Replaces this pixmap's data with the given \a image using the | - |
1076 | specified \a flags to control the conversion. The \a flags | - |
1077 | argument is a bitwise-OR of the \l{Qt::ImageConversionFlags}. | - |
1078 | Passing 0 for \a flags sets all the default options. Returns true | - |
1079 | if the result is that this pixmap is not null. | - |
1080 | | - |
1081 | Note: this function was part of Qt 3 support in Qt 4.6 and earlier. | - |
1082 | It has been promoted to official API status in 4.7 to support updating | - |
1083 | the pixmap's image without creating a new QPixmap as fromImage() would. | - |
1084 | | - |
1085 | \sa fromImage() | - |
1086 | \since 4.7 | - |
1087 | */ | - |
1088 | bool QPixmap::convertFromImage(const QImage &image, Qt::ImageConversionFlags flags) | - |
1089 | { | - |
1090 | if (image.isNull() || !data) never evaluated: image.isNull() never evaluated: !data | 0 |
1091 | *this = QPixmap::fromImage(image, flags); never executed: *this = QPixmap::fromImage(image, flags); | 0 |
1092 | else | - |
1093 | data->fromImage(image, flags); never executed: data->fromImage(image, flags); | 0 |
1094 | return !isNull(); never executed: return !isNull(); | 0 |
1095 | } | - |
1096 | | - |
1097 | /*! | - |
1098 | \fn QPixmap QPixmap::scaled(int width, int height, | - |
1099 | Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode | - |
1100 | transformMode) const | - |
1101 | | - |
1102 | \overload | - |
1103 | | - |
1104 | Returns a copy of the pixmap scaled to a rectangle with the given | - |
1105 | \a width and \a height according to the given \a aspectRatioMode and | - |
1106 | \a transformMode. | - |
1107 | | - |
1108 | If either the \a width or the \a height is zero or negative, this | - |
1109 | function returns a null pixmap. | - |
1110 | */ | - |
1111 | | - |
1112 | /*! | - |
1113 | \fn QPixmap QPixmap::scaled(const QSize &size, Qt::AspectRatioMode | - |
1114 | aspectRatioMode, Qt::TransformationMode transformMode) const | - |
1115 | | - |
1116 | Scales the pixmap to the given \a size, using the aspect ratio and | - |
1117 | transformation modes specified by \a aspectRatioMode and \a | - |
1118 | transformMode. | - |
1119 | | - |
1120 | \image qimage-scaling.png | - |
1121 | | - |
1122 | \list | - |
1123 | \li If \a aspectRatioMode is Qt::IgnoreAspectRatio, the pixmap | - |
1124 | is scaled to \a size. | - |
1125 | \li If \a aspectRatioMode is Qt::KeepAspectRatio, the pixmap is | - |
1126 | scaled to a rectangle as large as possible inside \a size, preserving the aspect ratio. | - |
1127 | \li If \a aspectRatioMode is Qt::KeepAspectRatioByExpanding, | - |
1128 | the pixmap is scaled to a rectangle as small as possible | - |
1129 | outside \a size, preserving the aspect ratio. | - |
1130 | \endlist | - |
1131 | | - |
1132 | If the given \a size is empty, this function returns a null | - |
1133 | pixmap. | - |
1134 | | - |
1135 | | - |
1136 | In some cases it can be more beneficial to draw the pixmap to a | - |
1137 | painter with a scale set rather than scaling the pixmap. This is | - |
1138 | the case when the painter is for instance based on OpenGL or when | - |
1139 | the scale factor changes rapidly. | - |
1140 | | - |
1141 | \sa isNull(), {QPixmap#Pixmap Transformations}{Pixmap | - |
1142 | Transformations} | - |
1143 | | - |
1144 | */ | - |
1145 | QPixmap QPixmap::scaled(const QSize& s, Qt::AspectRatioMode aspectMode, Qt::TransformationMode mode) const | - |
1146 | { | - |
1147 | if (isNull()) { partially evaluated: isNull() no Evaluation Count:0 | yes Evaluation Count:99 |
| 0-99 |
1148 | qWarning("QPixmap::scaled: Pixmap is a null pixmap"); never executed (the execution status of this line is deduced): QMessageLogger("image/qpixmap.cpp", 1148, __PRETTY_FUNCTION__).warning("QPixmap::scaled: Pixmap is a null pixmap"); | - |
1149 | return QPixmap(); never executed: return QPixmap(); | 0 |
1150 | } | - |
1151 | if (s.isEmpty()) partially evaluated: s.isEmpty() no Evaluation Count:0 | yes Evaluation Count:99 |
| 0-99 |
1152 | return QPixmap(); never executed: return QPixmap(); | 0 |
1153 | | - |
1154 | QSize newSize = size(); executed (the execution status of this line is deduced): QSize newSize = size(); | - |
1155 | newSize.scale(s, aspectMode); executed (the execution status of this line is deduced): newSize.scale(s, aspectMode); | - |
1156 | newSize.rwidth() = qMax(newSize.width(), 1); executed (the execution status of this line is deduced): newSize.rwidth() = qMax(newSize.width(), 1); | - |
1157 | newSize.rheight() = qMax(newSize.height(), 1); executed (the execution status of this line is deduced): newSize.rheight() = qMax(newSize.height(), 1); | - |
1158 | if (newSize == size()) partially evaluated: newSize == size() no Evaluation Count:0 | yes Evaluation Count:99 |
| 0-99 |
1159 | return *this; never executed: return *this; | 0 |
1160 | | - |
1161 | QTransform wm = QTransform::fromScale((qreal)newSize.width() / width(), executed (the execution status of this line is deduced): QTransform wm = QTransform::fromScale((qreal)newSize.width() / width(), | - |
1162 | (qreal)newSize.height() / height()); executed (the execution status of this line is deduced): (qreal)newSize.height() / height()); | - |
1163 | QPixmap pix = transformed(wm, mode); executed (the execution status of this line is deduced): QPixmap pix = transformed(wm, mode); | - |
1164 | return pix; executed: return pix; Execution Count:99 | 99 |
1165 | } | - |
1166 | | - |
1167 | /*! | - |
1168 | \fn QPixmap QPixmap::scaledToWidth(int width, Qt::TransformationMode | - |
1169 | mode) const | - |
1170 | | - |
1171 | Returns a scaled copy of the image. The returned image is scaled | - |
1172 | to the given \a width using the specified transformation \a mode. | - |
1173 | The height of the pixmap is automatically calculated so that the | - |
1174 | aspect ratio of the pixmap is preserved. | - |
1175 | | - |
1176 | If \a width is 0 or negative, a null pixmap is returned. | - |
1177 | | - |
1178 | \sa isNull(), {QPixmap#Pixmap Transformations}{Pixmap | - |
1179 | Transformations} | - |
1180 | */ | - |
1181 | QPixmap QPixmap::scaledToWidth(int w, Qt::TransformationMode mode) const | - |
1182 | { | - |
1183 | if (isNull()) { never evaluated: isNull() | 0 |
1184 | qWarning("QPixmap::scaleWidth: Pixmap is a null pixmap"); never executed (the execution status of this line is deduced): QMessageLogger("image/qpixmap.cpp", 1184, __PRETTY_FUNCTION__).warning("QPixmap::scaleWidth: Pixmap is a null pixmap"); | - |
1185 | return copy(); never executed: return copy(); | 0 |
1186 | } | - |
1187 | if (w <= 0) | 0 |
1188 | return QPixmap(); never executed: return QPixmap(); | 0 |
1189 | | - |
1190 | qreal factor = (qreal) w / width(); never executed (the execution status of this line is deduced): qreal factor = (qreal) w / width(); | - |
1191 | QTransform wm = QTransform::fromScale(factor, factor); never executed (the execution status of this line is deduced): QTransform wm = QTransform::fromScale(factor, factor); | - |
1192 | return transformed(wm, mode); never executed: return transformed(wm, mode); | 0 |
1193 | } | - |
1194 | | - |
1195 | /*! | - |
1196 | \fn QPixmap QPixmap::scaledToHeight(int height, | - |
1197 | Qt::TransformationMode mode) const | - |
1198 | | - |
1199 | Returns a scaled copy of the image. The returned image is scaled | - |
1200 | to the given \a height using the specified transformation \a mode. | - |
1201 | The width of the pixmap is automatically calculated so that the | - |
1202 | aspect ratio of the pixmap is preserved. | - |
1203 | | - |
1204 | If \a height is 0 or negative, a null pixmap is returned. | - |
1205 | | - |
1206 | \sa isNull(), {QPixmap#Pixmap Transformations}{Pixmap | - |
1207 | Transformations} | - |
1208 | */ | - |
1209 | QPixmap QPixmap::scaledToHeight(int h, Qt::TransformationMode mode) const | - |
1210 | { | - |
1211 | if (isNull()) { never evaluated: isNull() | 0 |
1212 | qWarning("QPixmap::scaleHeight: Pixmap is a null pixmap"); never executed (the execution status of this line is deduced): QMessageLogger("image/qpixmap.cpp", 1212, __PRETTY_FUNCTION__).warning("QPixmap::scaleHeight: Pixmap is a null pixmap"); | - |
1213 | return copy(); never executed: return copy(); | 0 |
1214 | } | - |
1215 | if (h <= 0) | 0 |
1216 | return QPixmap(); never executed: return QPixmap(); | 0 |
1217 | | - |
1218 | qreal factor = (qreal) h / height(); never executed (the execution status of this line is deduced): qreal factor = (qreal) h / height(); | - |
1219 | QTransform wm = QTransform::fromScale(factor, factor); never executed (the execution status of this line is deduced): QTransform wm = QTransform::fromScale(factor, factor); | - |
1220 | return transformed(wm, mode); never executed: return transformed(wm, mode); | 0 |
1221 | } | - |
1222 | | - |
1223 | /*! | - |
1224 | Returns a copy of the pixmap that is transformed using the given | - |
1225 | transformation \a transform and transformation \a mode. The original | - |
1226 | pixmap is not changed. | - |
1227 | | - |
1228 | The transformation \a transform is internally adjusted to compensate | - |
1229 | for unwanted translation; i.e. the pixmap produced is the smallest | - |
1230 | pixmap that contains all the transformed points of the original | - |
1231 | pixmap. Use the trueMatrix() function to retrieve the actual | - |
1232 | matrix used for transforming the pixmap. | - |
1233 | | - |
1234 | This function is slow because it involves transformation to a | - |
1235 | QImage, non-trivial computations and a transformation back to a | - |
1236 | QPixmap. | - |
1237 | | - |
1238 | \sa trueMatrix(), {QPixmap#Pixmap Transformations}{Pixmap | - |
1239 | Transformations} | - |
1240 | */ | - |
1241 | QPixmap QPixmap::transformed(const QTransform &transform, | - |
1242 | Qt::TransformationMode mode) const | - |
1243 | { | - |
1244 | if (isNull() || transform.type() <= QTransform::TxTranslate) partially evaluated: isNull() no Evaluation Count:0 | yes Evaluation Count:103 |
partially evaluated: transform.type() <= QTransform::TxTranslate no Evaluation Count:0 | yes Evaluation Count:103 |
| 0-103 |
1245 | return *this; never executed: return *this; | 0 |
1246 | | - |
1247 | return data->transformed(transform, mode); executed: return data->transformed(transform, mode); Execution Count:103 | 103 |
1248 | } | - |
1249 | | - |
1250 | /*! | - |
1251 | \overload | - |
1252 | | - |
1253 | This convenience function loads the \a matrix into a | - |
1254 | QTransform and calls the overloaded function. | - |
1255 | */ | - |
1256 | QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) const | - |
1257 | { | - |
1258 | return transformed(QTransform(matrix), mode); never executed: return transformed(QTransform(matrix), mode); | 0 |
1259 | } | - |
1260 | | - |
1261 | | - |
1262 | | - |
1263 | | - |
1264 | | - |
1265 | | - |
1266 | | - |
1267 | | - |
1268 | /*! | - |
1269 | \class QPixmap | - |
1270 | \inmodule QtGui | - |
1271 | | - |
1272 | \brief The QPixmap class is an off-screen image representation | - |
1273 | that can be used as a paint device. | - |
1274 | | - |
1275 | \ingroup painting | - |
1276 | \ingroup shared | - |
1277 | | - |
1278 | | - |
1279 | Qt provides four classes for handling image data: QImage, QPixmap, | - |
1280 | QBitmap and QPicture. QImage is designed and optimized for I/O, | - |
1281 | and for direct pixel access and manipulation, while QPixmap is | - |
1282 | designed and optimized for showing images on screen. QBitmap is | - |
1283 | only a convenience class that inherits QPixmap, ensuring a depth | - |
1284 | of 1. The isQBitmap() function returns true if a QPixmap object is | - |
1285 | really a bitmap, otherwise returns false. Finally, the QPicture class | - |
1286 | is a paint device that records and replays QPainter commands. | - |
1287 | | - |
1288 | A QPixmap can easily be displayed on the screen using QLabel or | - |
1289 | one of QAbstractButton's subclasses (such as QPushButton and | - |
1290 | QToolButton). QLabel has a pixmap property, whereas | - |
1291 | QAbstractButton has an icon property. | - |
1292 | | - |
1293 | QPixmap objects can be passed around by value since the QPixmap | - |
1294 | class uses implicit data sharing. For more information, see the \l | - |
1295 | {Implicit Data Sharing} documentation. QPixmap objects can also be | - |
1296 | streamed. | - |
1297 | | - |
1298 | Note that the pixel data in a pixmap is internal and is managed by | - |
1299 | the underlying window system. Because QPixmap is a QPaintDevice | - |
1300 | subclass, QPainter can be used to draw directly onto pixmaps. | - |
1301 | Pixels can only be accessed through QPainter functions or by | - |
1302 | converting the QPixmap to a QImage. However, the fill() function | - |
1303 | is available for initializing the entire pixmap with a given color. | - |
1304 | | - |
1305 | There are functions to convert between QImage and | - |
1306 | QPixmap. Typically, the QImage class is used to load an image | - |
1307 | file, optionally manipulating the image data, before the QImage | - |
1308 | object is converted into a QPixmap to be shown on | - |
1309 | screen. Alternatively, if no manipulation is desired, the image | - |
1310 | file can be loaded directly into a QPixmap. On Windows, the | - |
1311 | QPixmap class also supports conversion between \c HBITMAP and | - |
1312 | QPixmap. | - |
1313 | | - |
1314 | QPixmap provides a collection of functions that can be used to | - |
1315 | obtain a variety of information about the pixmap. In addition, | - |
1316 | there are several functions that enables transformation of the | - |
1317 | pixmap. | - |
1318 | | - |
1319 | \tableofcontents | - |
1320 | | - |
1321 | \section1 Reading and Writing Image Files | - |
1322 | | - |
1323 | QPixmap provides several ways of reading an image file: The file | - |
1324 | can be loaded when constructing the QPixmap object, or by using | - |
1325 | the load() or loadFromData() functions later on. When loading an | - |
1326 | image, the file name can either refer to an actual file on disk or | - |
1327 | to one of the application's embedded resources. See \l{The Qt | - |
1328 | Resource System} overview for details on how to embed images and | - |
1329 | other resource files in the application's executable. | - |
1330 | | - |
1331 | Simply call the save() function to save a QPixmap object. | - |
1332 | | - |
1333 | The complete list of supported file formats are available through | - |
1334 | the QImageReader::supportedImageFormats() and | - |
1335 | QImageWriter::supportedImageFormats() functions. New file formats | - |
1336 | can be added as plugins. By default, Qt supports the following | - |
1337 | formats: | - |
1338 | | - |
1339 | \table | - |
1340 | \header \li Format \li Description \li Qt's support | - |
1341 | \row \li BMP \li Windows Bitmap \li Read/write | - |
1342 | \row \li GIF \li Graphic Interchange Format (optional) \li Read | - |
1343 | \row \li JPG \li Joint Photographic Experts Group \li Read/write | - |
1344 | \row \li JPEG \li Joint Photographic Experts Group \li Read/write | - |
1345 | \row \li PNG \li Portable Network Graphics \li Read/write | - |
1346 | \row \li PBM \li Portable Bitmap \li Read | - |
1347 | \row \li PGM \li Portable Graymap \li Read | - |
1348 | \row \li PPM \li Portable Pixmap \li Read/write | - |
1349 | \row \li XBM \li X11 Bitmap \li Read/write | - |
1350 | \row \li XPM \li X11 Pixmap \li Read/write | - |
1351 | \endtable | - |
1352 | | - |
1353 | \section1 Pixmap Information | - |
1354 | | - |
1355 | QPixmap provides a collection of functions that can be used to | - |
1356 | obtain a variety of information about the pixmap: | - |
1357 | | - |
1358 | \table | - |
1359 | \header | - |
1360 | \li \li Available Functions | - |
1361 | \row | - |
1362 | \li Geometry | - |
1363 | \li | - |
1364 | The size(), width() and height() functions provide information | - |
1365 | about the pixmap's size. The rect() function returns the image's | - |
1366 | enclosing rectangle. | - |
1367 | | - |
1368 | \row | - |
1369 | \li Alpha component | - |
1370 | \li | - |
1371 | | - |
1372 | The hasAlphaChannel() returns true if the pixmap has a format that | - |
1373 | respects the alpha channel, otherwise returns false. The hasAlpha(), | - |
1374 | setMask() and mask() functions are legacy and should not be used. | - |
1375 | They are potentially very slow. | - |
1376 | | - |
1377 | The createHeuristicMask() function creates and returns a 1-bpp | - |
1378 | heuristic mask (i.e. a QBitmap) for this pixmap. It works by | - |
1379 | selecting a color from one of the corners and then chipping away | - |
1380 | pixels of that color, starting at all the edges. The | - |
1381 | createMaskFromColor() function creates and returns a mask (i.e. a | - |
1382 | QBitmap) for the pixmap based on a given color. | - |
1383 | | - |
1384 | \row | - |
1385 | \li Low-level information | - |
1386 | \li | - |
1387 | | - |
1388 | The depth() function returns the depth of the pixmap. The | - |
1389 | defaultDepth() function returns the default depth, i.e. the depth | - |
1390 | used by the application on the given screen. | - |
1391 | | - |
1392 | The cacheKey() function returns a number that uniquely | - |
1393 | identifies the contents of the QPixmap object. | - |
1394 | | - |
1395 | The x11Info() function returns information about the configuration | - |
1396 | of the X display used by the screen to which the pixmap currently | - |
1397 | belongs. The x11PictureHandle() function returns the X11 Picture | - |
1398 | handle of the pixmap for XRender support. Note that the two latter | - |
1399 | functions are only available on x11. | - |
1400 | | - |
1401 | \endtable | - |
1402 | | - |
1403 | \section1 Pixmap Conversion | - |
1404 | | - |
1405 | A QPixmap object can be converted into a QImage using the | - |
1406 | toImage() function. Likewise, a QImage can be converted into a | - |
1407 | QPixmap using the fromImage(). If this is too expensive an | - |
1408 | operation, you can use QBitmap::fromImage() instead. | - |
1409 | | - |
1410 | In addition, on Windows, the QPixmap class supports conversion to | - |
1411 | and from HBITMAP: the toWinHBITMAP() function creates a HBITMAP | - |
1412 | equivalent to the QPixmap, based on the given HBitmapFormat, and | - |
1413 | returns the HBITMAP handle. The fromWinHBITMAP() function returns | - |
1414 | a QPixmap that is equivalent to the given bitmap which has the | - |
1415 | specified format. The QPixmap class also supports conversion to | - |
1416 | and from HICON: the toWinHICON() function creates a HICON equivalent | - |
1417 | to the QPixmap, and returns the HICON handle. The fromWinHICON() | - |
1418 | function returns a QPixmap that is equivalent to the given icon. | - |
1419 | | - |
1420 | \section1 Pixmap Transformations | - |
1421 | | - |
1422 | QPixmap supports a number of functions for creating a new pixmap | - |
1423 | that is a transformed version of the original: | - |
1424 | | - |
1425 | The scaled(), scaledToWidth() and scaledToHeight() functions | - |
1426 | return scaled copies of the pixmap, while the copy() function | - |
1427 | creates a QPixmap that is a plain copy of the original one. | - |
1428 | | - |
1429 | The transformed() function returns a copy of the pixmap that is | - |
1430 | transformed with the given transformation matrix and | - |
1431 | transformation mode: Internally, the transformation matrix is | - |
1432 | adjusted to compensate for unwanted translation, | - |
1433 | i.e. transformed() returns the smallest pixmap containing all | - |
1434 | transformed points of the original pixmap. The static trueMatrix() | - |
1435 | function returns the actual matrix used for transforming the | - |
1436 | pixmap. | - |
1437 | | - |
1438 | \note When using the native X11 graphics system, the pixmap | - |
1439 | becomes invalid when the QApplication instance is destroyed. | - |
1440 | | - |
1441 | \sa QBitmap, QImage, QImageReader, QImageWriter | - |
1442 | */ | - |
1443 | | - |
1444 | | - |
1445 | /*! | - |
1446 | \typedef QPixmap::DataPtr | - |
1447 | \internal | - |
1448 | */ | - |
1449 | | - |
1450 | /*! | - |
1451 | \fn DataPtr &QPixmap::data_ptr() | - |
1452 | \internal | - |
1453 | */ | - |
1454 | | - |
1455 | /*! | - |
1456 | Returns true if this pixmap has an alpha channel, \e or has a | - |
1457 | mask, otherwise returns false. | - |
1458 | | - |
1459 | \sa hasAlphaChannel(), mask() | - |
1460 | */ | - |
1461 | bool QPixmap::hasAlpha() const | - |
1462 | { | - |
1463 | return data && data->hasAlphaChannel(); executed: return data && data->hasAlphaChannel(); Execution Count:1 | 1 |
1464 | } | - |
1465 | | - |
1466 | /*! | - |
1467 | Returns true if the pixmap has a format that respects the alpha | - |
1468 | channel, otherwise returns false. | - |
1469 | | - |
1470 | \sa hasAlpha() | - |
1471 | */ | - |
1472 | bool QPixmap::hasAlphaChannel() const | - |
1473 | { | - |
1474 | return data && data->hasAlphaChannel(); executed: return data && data->hasAlphaChannel(); Execution Count:88 | 88 |
1475 | } | - |
1476 | | - |
1477 | /*! | - |
1478 | \internal | - |
1479 | */ | - |
1480 | int QPixmap::metric(PaintDeviceMetric metric) const | - |
1481 | { | - |
1482 | return data ? data->metric(metric) : 0; executed: return data ? data->metric(metric) : 0; Execution Count:1963 | 1963 |
1483 | } | - |
1484 | | - |
1485 | /*! | - |
1486 | \internal | - |
1487 | */ | - |
1488 | QPaintEngine *QPixmap::paintEngine() const | - |
1489 | { | - |
1490 | return data ? data->paintEngine() : 0; executed: return data ? data->paintEngine() : 0; Execution Count:2156 | 2156 |
1491 | } | - |
1492 | | - |
1493 | /*! | - |
1494 | \fn QBitmap QPixmap::mask() const | - |
1495 | | - |
1496 | Extracts a bitmap mask from the pixmap's alpha channel. | - |
1497 | | - |
1498 | \warning This is potentially an expensive operation. The mask of | - |
1499 | the pixmap is extracted dynamically from the pixeldata. | - |
1500 | | - |
1501 | \sa setMask(), {QPixmap#Pixmap Information}{Pixmap Information} | - |
1502 | */ | - |
1503 | QBitmap QPixmap::mask() const | - |
1504 | { | - |
1505 | if (!data || !hasAlphaChannel()) evaluated: !data yes Evaluation Count:7 | yes Evaluation Count:85 |
evaluated: !hasAlphaChannel() yes Evaluation Count:15 | yes Evaluation Count:70 |
| 7-85 |
1506 | return QBitmap(); executed: return QBitmap(); Execution Count:22 | 22 |
1507 | | - |
1508 | const QImage img = toImage(); executed (the execution status of this line is deduced): const QImage img = toImage(); | - |
1509 | const QImage image = (img.depth() < 32 ? img.convertToFormat(QImage::Format_ARGB32_Premultiplied) : img); partially evaluated: img.depth() < 32 no Evaluation Count:0 | yes Evaluation Count:70 |
| 0-70 |
1510 | const int w = image.width(); executed (the execution status of this line is deduced): const int w = image.width(); | - |
1511 | const int h = image.height(); executed (the execution status of this line is deduced): const int h = image.height(); | - |
1512 | | - |
1513 | QImage mask(w, h, QImage::Format_MonoLSB); executed (the execution status of this line is deduced): QImage mask(w, h, QImage::Format_MonoLSB); | - |
1514 | if (mask.isNull()) // allocation failed partially evaluated: mask.isNull() no Evaluation Count:0 | yes Evaluation Count:70 |
| 0-70 |
1515 | return QBitmap(); never executed: return QBitmap(); | 0 |
1516 | | - |
1517 | mask.setColorCount(2); executed (the execution status of this line is deduced): mask.setColorCount(2); | - |
1518 | mask.setColor(0, QColor(Qt::color0).rgba()); executed (the execution status of this line is deduced): mask.setColor(0, QColor(Qt::color0).rgba()); | - |
1519 | mask.setColor(1, QColor(Qt::color1).rgba()); executed (the execution status of this line is deduced): mask.setColor(1, QColor(Qt::color1).rgba()); | - |
1520 | | - |
1521 | const int bpl = mask.bytesPerLine(); executed (the execution status of this line is deduced): const int bpl = mask.bytesPerLine(); | - |
1522 | | - |
1523 | for (int y = 0; y < h; ++y) { evaluated: y < h yes Evaluation Count:1078 | yes Evaluation Count:70 |
| 70-1078 |
1524 | const QRgb *src = reinterpret_cast<const QRgb*>(image.scanLine(y)); executed (the execution status of this line is deduced): const QRgb *src = reinterpret_cast<const QRgb*>(image.scanLine(y)); | - |
1525 | uchar *dest = mask.scanLine(y); executed (the execution status of this line is deduced): uchar *dest = mask.scanLine(y); | - |
1526 | memset(dest, 0, bpl); executed (the execution status of this line is deduced): memset(dest, 0, bpl); | - |
1527 | for (int x = 0; x < w; ++x) { evaluated: x < w yes Evaluation Count:33928 | yes Evaluation Count:1078 |
| 1078-33928 |
1528 | if (qAlpha(*src) > 0) evaluated: qAlpha(*src) > 0 yes Evaluation Count:11575 | yes Evaluation Count:22353 |
| 11575-22353 |
1529 | dest[x >> 3] |= (1 << (x & 7)); executed: dest[x >> 3] |= (1 << (x & 7)); Execution Count:11575 | 11575 |
1530 | ++src; executed (the execution status of this line is deduced): ++src; | - |
1531 | } executed: } Execution Count:33928 | 33928 |
1532 | } executed: } Execution Count:1078 | 1078 |
1533 | | - |
1534 | return QBitmap::fromImage(mask); executed: return QBitmap::fromImage(mask); Execution Count:70 | 70 |
1535 | } | - |
1536 | | - |
1537 | /*! | - |
1538 | Returns the default pixmap depth used by the application. | - |
1539 | | - |
1540 | On all platforms the depth of the primary screen will be returned. | - |
1541 | | - |
1542 | \sa depth(), QColormap::depth(), {QPixmap#Pixmap Information}{Pixmap Information} | - |
1543 | | - |
1544 | */ | - |
1545 | int QPixmap::defaultDepth() | - |
1546 | { | - |
1547 | return QGuiApplication::primaryScreen()->depth(); executed: return QGuiApplication::primaryScreen()->depth(); Execution Count:39 | 39 |
1548 | } | - |
1549 | | - |
1550 | /*! | - |
1551 | Detaches the pixmap from shared pixmap data. | - |
1552 | | - |
1553 | A pixmap is automatically detached by Qt whenever its contents are | - |
1554 | about to change. This is done in almost all QPixmap member | - |
1555 | functions that modify the pixmap (fill(), fromImage(), | - |
1556 | load(), etc.), and in QPainter::begin() on a pixmap. | - |
1557 | | - |
1558 | There are two exceptions in which detach() must be called | - |
1559 | explicitly, that is when calling the handle() or the | - |
1560 | x11PictureHandle() function (only available on X11). Otherwise, | - |
1561 | any modifications done using system calls, will be performed on | - |
1562 | the shared data. | - |
1563 | | - |
1564 | The detach() function returns immediately if there is just a | - |
1565 | single reference or if the pixmap has not been initialized yet. | - |
1566 | */ | - |
1567 | void QPixmap::detach() | - |
1568 | { | - |
1569 | if (!data) evaluated: !data yes Evaluation Count:1708 | yes Evaluation Count:1376 |
| 1376-1708 |
1570 | return; executed: return; Execution Count:1708 | 1708 |
1571 | | - |
1572 | // QPixmap.data member may be QRuntimePlatformPixmap so use handle() function to get | - |
1573 | // the actual underlaying runtime pixmap data. | - |
1574 | QPlatformPixmap *pd = handle(); executed (the execution status of this line is deduced): QPlatformPixmap *pd = handle(); | - |
1575 | QPlatformPixmap::ClassId id = pd->classId(); executed (the execution status of this line is deduced): QPlatformPixmap::ClassId id = pd->classId(); | - |
1576 | if (id == QPlatformPixmap::RasterClass) { partially evaluated: id == QPlatformPixmap::RasterClass yes Evaluation Count:1376 | no Evaluation Count:0 |
| 0-1376 |
1577 | QRasterPlatformPixmap *rasterData = static_cast<QRasterPlatformPixmap*>(pd); executed (the execution status of this line is deduced): QRasterPlatformPixmap *rasterData = static_cast<QRasterPlatformPixmap*>(pd); | - |
1578 | rasterData->image.detach(); executed (the execution status of this line is deduced): rasterData->image.detach(); | - |
1579 | } executed: } Execution Count:1376 | 1376 |
1580 | | - |
1581 | if (data->is_cached && data->ref.load() == 1) partially evaluated: data->is_cached no Evaluation Count:0 | yes Evaluation Count:1376 |
never evaluated: data->ref.load() == 1 | 0-1376 |
1582 | QImagePixmapCleanupHooks::executePlatformPixmapModificationHooks(data.data()); never executed: QImagePixmapCleanupHooks::executePlatformPixmapModificationHooks(data.data()); | 0 |
1583 | | - |
1584 | if (data->ref.load() != 1) { evaluated: data->ref.load() != 1 yes Evaluation Count:51 | yes Evaluation Count:1325 |
| 51-1325 |
1585 | *this = copy(); executed (the execution status of this line is deduced): *this = copy(); | - |
1586 | } executed: } Execution Count:51 | 51 |
1587 | ++data->detach_no; executed (the execution status of this line is deduced): ++data->detach_no; | - |
1588 | } executed: } Execution Count:1376 | 1376 |
1589 | | - |
1590 | /*! | - |
1591 | \fn QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) | - |
1592 | | - |
1593 | Converts the given \a image to a pixmap using the specified \a | - |
1594 | flags to control the conversion. The \a flags argument is a | - |
1595 | bitwise-OR of the \l{Qt::ImageConversionFlags}. Passing 0 for \a | - |
1596 | flags sets all the default options. | - |
1597 | | - |
1598 | In case of monochrome and 8-bit images, the image is first | - |
1599 | converted to a 32-bit pixmap and then filled with the colors in | - |
1600 | the color table. If this is too expensive an operation, you can | - |
1601 | use QBitmap::fromImage() instead. | - |
1602 | | - |
1603 | \sa fromImageReader(), toImage(), {QPixmap#Pixmap Conversion}{Pixmap Conversion} | - |
1604 | */ | - |
1605 | QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) | - |
1606 | { | - |
1607 | if (image.isNull()) evaluated: image.isNull() yes Evaluation Count:1 | yes Evaluation Count:3844 |
| 1-3844 |
1608 | return QPixmap(); executed: return QPixmap(); Execution Count:1 | 1 |
1609 | | - |
1610 | QScopedPointer<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); executed (the execution status of this line is deduced): QScopedPointer<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); | - |
1611 | data->fromImage(image, flags); executed (the execution status of this line is deduced): data->fromImage(image, flags); | - |
1612 | return QPixmap(data.take()); executed: return QPixmap(data.take()); Execution Count:3844 | 3844 |
1613 | } | - |
1614 | | - |
1615 | /*! | - |
1616 | \fn QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags) | - |
1617 | | - |
1618 | Create a QPixmap from an image read directly from an \a imageReader. | - |
1619 | The \a flags argument is a bitwise-OR of the \l{Qt::ImageConversionFlags}. | - |
1620 | Passing 0 for \a flags sets all the default options. | - |
1621 | | - |
1622 | On some systems, reading an image directly to QPixmap can use less memory than | - |
1623 | reading a QImage to convert it to QPixmap. | - |
1624 | | - |
1625 | \sa fromImage(), toImage(), {QPixmap#Pixmap Conversion}{Pixmap Conversion} | - |
1626 | */ | - |
1627 | QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags) | - |
1628 | { | - |
1629 | QScopedPointer<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); executed (the execution status of this line is deduced): QScopedPointer<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); | - |
1630 | data->fromImageReader(imageReader, flags); executed (the execution status of this line is deduced): data->fromImageReader(imageReader, flags); | - |
1631 | return QPixmap(data.take()); executed: return QPixmap(data.take()); Execution Count:15 | 15 |
1632 | } | - |
1633 | | - |
1634 | /*! | - |
1635 | \fn QPixmap QPixmap::grabWindow(WId window, int x, int y, int | - |
1636 | width, int height) | - |
1637 | | - |
1638 | Creates and returns a pixmap constructed by grabbing the contents | - |
1639 | of the given \a window restricted by QRect(\a x, \a y, \a width, | - |
1640 | \a height). | - |
1641 | | - |
1642 | The arguments (\a{x}, \a{y}) specify the offset in the window, | - |
1643 | whereas (\a{width}, \a{height}) specify the area to be copied. If | - |
1644 | \a width is negative, the function copies everything to the right | - |
1645 | border of the window. If \a height is negative, the function | - |
1646 | copies everything to the bottom of the window. | - |
1647 | | - |
1648 | The window system identifier (\c WId) can be retrieved using the | - |
1649 | QWidget::winId() function. The rationale for using a window | - |
1650 | identifier and not a QWidget, is to enable grabbing of windows | - |
1651 | that are not part of the application, window system frames, and so | - |
1652 | on. | - |
1653 | | - |
1654 | The grabWindow() function grabs pixels from the screen, not from | - |
1655 | the window, i.e. if there is another window partially or entirely | - |
1656 | over the one you grab, you get pixels from the overlying window, | - |
1657 | too. The mouse cursor is generally not grabbed. | - |
1658 | | - |
1659 | Note on X11 that if the given \a window doesn't have the same depth | - |
1660 | as the root window, and another window partially or entirely | - |
1661 | obscures the one you grab, you will \e not get pixels from the | - |
1662 | overlying window. The contents of the obscured areas in the | - |
1663 | pixmap will be undefined and uninitialized. | - |
1664 | | - |
1665 | On Windows Vista and above grabbing a layered window, which is | - |
1666 | created by setting the Qt::WA_TranslucentBackground attribute, will | - |
1667 | not work. Instead grabbing the desktop widget should work. | - |
1668 | | - |
1669 | \warning In general, grabbing an area outside the screen is not | - |
1670 | safe. This depends on the underlying window system. | - |
1671 | | - |
1672 | \warning The function is deprecated in Qt 5.0 since there might be | - |
1673 | platform plugins in which window system identifiers (\c WId) | - |
1674 | are local to a screen. Use QScreen::grabWindow() instead. | - |
1675 | | - |
1676 | \sa grabWidget(), {Screenshot Example} | - |
1677 | \sa QScreen | - |
1678 | \deprecated | - |
1679 | */ | - |
1680 | | - |
1681 | QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) | - |
1682 | { | - |
1683 | qWarning("%s is deprecated, use QScreen::grabWindow() instead." never executed (the execution status of this line is deduced): QMessageLogger("image/qpixmap.cpp", 1683, __PRETTY_FUNCTION__).warning("%s is deprecated, use QScreen::grabWindow() instead." | - |
1684 | " Defaulting to primary screen.", Q_FUNC_INFO); never executed (the execution status of this line is deduced): " Defaulting to primary screen.", __PRETTY_FUNCTION__); | - |
1685 | return QGuiApplication::primaryScreen()->grabWindow(window, x, y, w, h); never executed: return QGuiApplication::primaryScreen()->grabWindow(window, x, y, w, h); | 0 |
1686 | } | - |
1687 | | - |
1688 | /*! | - |
1689 | \internal | - |
1690 | */ | - |
1691 | QPlatformPixmap* QPixmap::handle() const | - |
1692 | { | - |
1693 | return data.data(); executed: return data.data(); Execution Count:14189 | 14189 |
1694 | } | - |
1695 | | - |
1696 | #ifndef QT_NO_DEBUG_STREAM | - |
1697 | QDebug operator<<(QDebug dbg, const QPixmap &r) | - |
1698 | { | - |
1699 | dbg.nospace() << "QPixmap(" << r.size() << ')'; executed (the execution status of this line is deduced): dbg.nospace() << "QPixmap(" << r.size() << ')'; | - |
1700 | return dbg.space(); executed: return dbg.space(); Execution Count:2 | 2 |
1701 | } | - |
1702 | #endif | - |
1703 | | - |
1704 | /*! | - |
1705 | \fn QPixmap QPixmap::alphaChannel() const | - |
1706 | | - |
1707 | Most use cases for this can be achieved using a QPainter and QPainter::CompositionMode instead. | - |
1708 | */ | - |
1709 | | - |
1710 | /*! | - |
1711 | \fn void QPixmap::setAlphaChannel(const QPixmap &p) | - |
1712 | | - |
1713 | Most use cases for this can be achieved using \a p with QPainter and QPainter::CompositionMode instead. | - |
1714 | */ | - |
1715 | | - |
1716 | QT_END_NAMESPACE | - |
1717 | | - |
| | |