[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
[561] | 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at qt-info@nokia.com.
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #include <qglobal.h>
|
---|
| 43 |
|
---|
| 44 | #include "qpixmap.h"
|
---|
| 45 | #include "qpixmapdata_p.h"
|
---|
[561] | 46 | #include "qimagepixmapcleanuphooks_p.h"
|
---|
[2] | 47 |
|
---|
| 48 | #include "qbitmap.h"
|
---|
| 49 | #include "qcolormap.h"
|
---|
| 50 | #include "qimage.h"
|
---|
| 51 | #include "qwidget.h"
|
---|
| 52 | #include "qpainter.h"
|
---|
| 53 | #include "qdatastream.h"
|
---|
| 54 | #include "qbuffer.h"
|
---|
| 55 | #include "qapplication.h"
|
---|
| 56 | #include <private/qapplication_p.h>
|
---|
| 57 | #include <private/qgraphicssystem_p.h>
|
---|
| 58 | #include <private/qwidget_p.h>
|
---|
| 59 | #include "qevent.h"
|
---|
| 60 | #include "qfile.h"
|
---|
| 61 | #include "qfileinfo.h"
|
---|
| 62 | #include "qpixmapcache.h"
|
---|
| 63 | #include "qdatetime.h"
|
---|
| 64 | #include "qimagereader.h"
|
---|
| 65 | #include "qimagewriter.h"
|
---|
| 66 | #include "qpaintengine.h"
|
---|
| 67 | #include "qthread.h"
|
---|
| 68 |
|
---|
| 69 | #ifdef Q_WS_MAC
|
---|
| 70 | # include "private/qt_mac_p.h"
|
---|
| 71 | # include "private/qpixmap_mac_p.h"
|
---|
| 72 | #endif
|
---|
| 73 |
|
---|
| 74 | #if defined(Q_WS_X11)
|
---|
| 75 | # include "qx11info_x11.h"
|
---|
| 76 | # include <private/qt_x11_p.h>
|
---|
| 77 | # include <private/qpixmap_x11_p.h>
|
---|
| 78 | #endif
|
---|
| 79 |
|
---|
[561] | 80 | #if defined(Q_OS_SYMBIAN)
|
---|
| 81 | # include <private/qt_s60_p.h>
|
---|
| 82 | #endif
|
---|
| 83 |
|
---|
[2] | 84 | #include "qpixmap_raster_p.h"
|
---|
[846] | 85 | #include "private/qstylehelper_p.h"
|
---|
[2] | 86 |
|
---|
| 87 | QT_BEGIN_NAMESPACE
|
---|
| 88 |
|
---|
| 89 | // ### Qt 5: remove
|
---|
| 90 | Q_GUI_EXPORT qint64 qt_pixmap_id(const QPixmap &pixmap)
|
---|
| 91 | {
|
---|
| 92 | return pixmap.cacheKey();
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | static bool qt_pixmap_thread_test()
|
---|
| 96 | {
|
---|
| 97 | if (!qApp) {
|
---|
| 98 | qFatal("QPixmap: Must construct a QApplication before a QPaintDevice");
|
---|
| 99 | return false;
|
---|
| 100 | }
|
---|
| 101 | #ifndef Q_WS_WIN
|
---|
| 102 | if (qApp->thread() != QThread::currentThread()) {
|
---|
| 103 | qWarning("QPixmap: It is not safe to use pixmaps outside the GUI thread");
|
---|
| 104 | return false;
|
---|
| 105 | }
|
---|
| 106 | #endif
|
---|
| 107 | return true;
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | void QPixmap::init(int w, int h, Type type)
|
---|
| 111 | {
|
---|
| 112 | init(w, h, int(type));
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | void QPixmap::init(int w, int h, int type)
|
---|
| 116 | {
|
---|
[561] | 117 | if ((w > 0 && h > 0) || type == QPixmapData::BitmapType)
|
---|
| 118 | data = QPixmapData::create(w, h, (QPixmapData::PixelType) type);
|
---|
[2] | 119 | else
|
---|
[561] | 120 | data = 0;
|
---|
[2] | 121 | }
|
---|
| 122 |
|
---|
| 123 | /*!
|
---|
| 124 | \enum QPixmap::ColorMode
|
---|
| 125 |
|
---|
| 126 | \compat
|
---|
| 127 |
|
---|
| 128 | This enum type defines the color modes that exist for converting
|
---|
| 129 | QImage objects to QPixmap. It is provided here for compatibility
|
---|
| 130 | with earlier versions of Qt.
|
---|
| 131 |
|
---|
| 132 | Use Qt::ImageConversionFlags instead.
|
---|
| 133 |
|
---|
| 134 | \value Auto Select \c Color or \c Mono on a case-by-case basis.
|
---|
| 135 | \value Color Always create colored pixmaps.
|
---|
| 136 | \value Mono Always create bitmaps.
|
---|
| 137 | */
|
---|
| 138 |
|
---|
| 139 | /*!
|
---|
| 140 | Constructs a null pixmap.
|
---|
| 141 |
|
---|
| 142 | \sa isNull()
|
---|
| 143 | */
|
---|
| 144 |
|
---|
| 145 | QPixmap::QPixmap()
|
---|
| 146 | : QPaintDevice()
|
---|
| 147 | {
|
---|
| 148 | (void) qt_pixmap_thread_test();
|
---|
| 149 | init(0, 0, QPixmapData::PixmapType);
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | /*!
|
---|
| 153 | \fn QPixmap::QPixmap(int width, int height)
|
---|
| 154 |
|
---|
| 155 | Constructs a pixmap with the given \a width and \a height. If
|
---|
| 156 | either \a width or \a height is zero, a null pixmap is
|
---|
| 157 | constructed.
|
---|
| 158 |
|
---|
| 159 | \warning This will create a QPixmap with uninitialized data. Call
|
---|
| 160 | fill() to fill the pixmap with an appropriate color before drawing
|
---|
| 161 | onto it with QPainter.
|
---|
| 162 |
|
---|
| 163 | \sa isNull()
|
---|
| 164 | */
|
---|
| 165 |
|
---|
| 166 | QPixmap::QPixmap(int w, int h)
|
---|
| 167 | : QPaintDevice()
|
---|
| 168 | {
|
---|
| 169 | if (!qt_pixmap_thread_test())
|
---|
| 170 | init(0, 0, QPixmapData::PixmapType);
|
---|
| 171 | else
|
---|
| 172 | init(w, h, QPixmapData::PixmapType);
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | /*!
|
---|
| 176 | \overload
|
---|
| 177 |
|
---|
| 178 | Constructs a pixmap of the given \a size.
|
---|
| 179 |
|
---|
| 180 | \warning This will create a QPixmap with uninitialized data. Call
|
---|
| 181 | fill() to fill the pixmap with an appropriate color before drawing
|
---|
| 182 | onto it with QPainter.
|
---|
| 183 | */
|
---|
| 184 |
|
---|
| 185 | QPixmap::QPixmap(const QSize &size)
|
---|
| 186 | : QPaintDevice()
|
---|
| 187 | {
|
---|
| 188 | if (!qt_pixmap_thread_test())
|
---|
| 189 | init(0, 0, QPixmapData::PixmapType);
|
---|
| 190 | else
|
---|
| 191 | init(size.width(), size.height(), QPixmapData::PixmapType);
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 | /*!
|
---|
| 195 | \internal
|
---|
| 196 | */
|
---|
| 197 | QPixmap::QPixmap(const QSize &s, Type type)
|
---|
| 198 | {
|
---|
| 199 | if (!qt_pixmap_thread_test())
|
---|
| 200 | init(0, 0, type);
|
---|
| 201 | else
|
---|
| 202 | init(s.width(), s.height(), type);
|
---|
| 203 | }
|
---|
| 204 |
|
---|
| 205 | /*!
|
---|
| 206 | \internal
|
---|
| 207 | */
|
---|
| 208 | QPixmap::QPixmap(const QSize &s, int type)
|
---|
| 209 | {
|
---|
| 210 | if (!qt_pixmap_thread_test())
|
---|
| 211 | init(0, 0, static_cast<QPixmapData::PixelType>(type));
|
---|
| 212 | else
|
---|
| 213 | init(s.width(), s.height(), static_cast<QPixmapData::PixelType>(type));
|
---|
| 214 | }
|
---|
| 215 |
|
---|
| 216 | /*!
|
---|
| 217 | \internal
|
---|
| 218 | */
|
---|
| 219 | QPixmap::QPixmap(QPixmapData *d)
|
---|
| 220 | : QPaintDevice(), data(d)
|
---|
| 221 | {
|
---|
| 222 | }
|
---|
| 223 |
|
---|
| 224 | /*!
|
---|
| 225 | Constructs a pixmap from the file with the given \a fileName. If the
|
---|
| 226 | file does not exist or is of an unknown format, the pixmap becomes a
|
---|
| 227 | null pixmap.
|
---|
| 228 |
|
---|
| 229 | The loader attempts to read the pixmap using the specified \a
|
---|
| 230 | format. If the \a format is not specified (which is the default),
|
---|
| 231 | the loader probes the file for a header to guess the file format.
|
---|
| 232 |
|
---|
| 233 | The file name can either refer to an actual file on disk or to
|
---|
| 234 | one of the application's embedded resources. See the
|
---|
| 235 | \l{resources.html}{Resource System} overview for details on how
|
---|
| 236 | to embed images and other resource files in the application's
|
---|
| 237 | executable.
|
---|
| 238 |
|
---|
| 239 | If the image needs to be modified to fit in a lower-resolution
|
---|
| 240 | result (e.g. converting from 32-bit to 8-bit), use the \a
|
---|
| 241 | flags to control the conversion.
|
---|
| 242 |
|
---|
| 243 | The \a fileName, \a format and \a flags parameters are
|
---|
| 244 | passed on to load(). This means that the data in \a fileName is
|
---|
| 245 | not compiled into the binary. If \a fileName contains a relative
|
---|
| 246 | path (e.g. the filename only) the relevant file must be found
|
---|
| 247 | relative to the runtime working directory.
|
---|
| 248 |
|
---|
| 249 | \sa {QPixmap#Reading and Writing Image Files}{Reading and Writing
|
---|
| 250 | Image Files}
|
---|
| 251 | */
|
---|
| 252 |
|
---|
| 253 | QPixmap::QPixmap(const QString& fileName, const char *format, Qt::ImageConversionFlags flags)
|
---|
| 254 | : QPaintDevice()
|
---|
| 255 | {
|
---|
| 256 | init(0, 0, QPixmapData::PixmapType);
|
---|
| 257 | if (!qt_pixmap_thread_test())
|
---|
| 258 | return;
|
---|
| 259 |
|
---|
| 260 | load(fileName, format, flags);
|
---|
| 261 | }
|
---|
| 262 |
|
---|
| 263 | /*!
|
---|
| 264 | Constructs a pixmap that is a copy of the given \a pixmap.
|
---|
| 265 |
|
---|
| 266 | \sa copy()
|
---|
| 267 | */
|
---|
| 268 |
|
---|
| 269 | QPixmap::QPixmap(const QPixmap &pixmap)
|
---|
| 270 | : QPaintDevice()
|
---|
| 271 | {
|
---|
| 272 | if (!qt_pixmap_thread_test()) {
|
---|
| 273 | init(0, 0, QPixmapData::PixmapType);
|
---|
| 274 | return;
|
---|
| 275 | }
|
---|
| 276 | if (pixmap.paintingActive()) { // make a deep copy
|
---|
| 277 | operator=(pixmap.copy());
|
---|
| 278 | } else {
|
---|
| 279 | data = pixmap.data;
|
---|
| 280 | }
|
---|
| 281 | }
|
---|
| 282 |
|
---|
| 283 | /*!
|
---|
| 284 | Constructs a pixmap from the given \a xpm data, which must be a
|
---|
| 285 | valid XPM image.
|
---|
| 286 |
|
---|
| 287 | Errors are silently ignored.
|
---|
| 288 |
|
---|
| 289 | Note that it's possible to squeeze the XPM variable a little bit
|
---|
| 290 | by using an unusual declaration:
|
---|
| 291 |
|
---|
| 292 | \snippet doc/src/snippets/code/src_gui_image_qpixmap.cpp 0
|
---|
| 293 |
|
---|
| 294 | The extra \c const makes the entire definition read-only, which is
|
---|
| 295 | slightly more efficient (for example, when the code is in a shared
|
---|
| 296 | library) and ROMable when the application is to be stored in ROM.
|
---|
| 297 | */
|
---|
| 298 | #ifndef QT_NO_IMAGEFORMAT_XPM
|
---|
| 299 | QPixmap::QPixmap(const char * const xpm[])
|
---|
| 300 | : QPaintDevice()
|
---|
| 301 | {
|
---|
| 302 | init(0, 0, QPixmapData::PixmapType);
|
---|
| 303 | if (!xpm)
|
---|
| 304 | return;
|
---|
| 305 |
|
---|
| 306 | QImage image(xpm);
|
---|
| 307 | if (!image.isNull()) {
|
---|
[561] | 308 | if (data && data->pixelType() == QPixmapData::BitmapType)
|
---|
[2] | 309 | *this = QBitmap::fromImage(image);
|
---|
| 310 | else
|
---|
| 311 | *this = fromImage(image);
|
---|
| 312 | }
|
---|
| 313 | }
|
---|
| 314 | #endif
|
---|
| 315 |
|
---|
| 316 |
|
---|
| 317 | /*!
|
---|
| 318 | Destroys the pixmap.
|
---|
| 319 | */
|
---|
| 320 |
|
---|
| 321 | QPixmap::~QPixmap()
|
---|
| 322 | {
|
---|
[561] | 323 | Q_ASSERT(!data || data->ref >= 1); // Catch if ref-counting changes again
|
---|
[2] | 324 | }
|
---|
| 325 |
|
---|
| 326 | /*!
|
---|
| 327 | \internal
|
---|
| 328 | */
|
---|
| 329 | int QPixmap::devType() const
|
---|
| 330 | {
|
---|
| 331 | return QInternal::Pixmap;
|
---|
| 332 | }
|
---|
| 333 |
|
---|
| 334 | /*!
|
---|
| 335 | \fn QPixmap QPixmap::copy(int x, int y, int width, int height) const
|
---|
| 336 | \overload
|
---|
| 337 |
|
---|
| 338 | Returns a deep copy of the subset of the pixmap that is specified
|
---|
| 339 | by the rectangle QRect( \a x, \a y, \a width, \a height).
|
---|
| 340 | */
|
---|
| 341 |
|
---|
| 342 | /*!
|
---|
| 343 | \fn QPixmap QPixmap::copy(const QRect &rectangle) const
|
---|
| 344 |
|
---|
| 345 | Returns a deep copy of the subset of the pixmap that is specified
|
---|
| 346 | by the given \a rectangle. For more information on deep copies,
|
---|
| 347 | see the \l {Implicit Data Sharing} documentation.
|
---|
| 348 |
|
---|
| 349 | If the given \a rectangle is empty, the whole image is copied.
|
---|
| 350 |
|
---|
| 351 | \sa operator=(), QPixmap(), {QPixmap#Pixmap
|
---|
| 352 | Transformations}{Pixmap Transformations}
|
---|
| 353 | */
|
---|
| 354 | QPixmap QPixmap::copy(const QRect &rect) const
|
---|
| 355 | {
|
---|
| 356 | if (isNull())
|
---|
| 357 | return QPixmap();
|
---|
| 358 |
|
---|
[561] | 359 | QRect r(0, 0, width(), height());
|
---|
| 360 | if (!rect.isEmpty())
|
---|
| 361 | r = r.intersected(rect);
|
---|
[2] | 362 |
|
---|
[561] | 363 | QPixmapData *d = data->createCompatiblePixmapData();
|
---|
| 364 | d->copy(data.data(), r);
|
---|
[2] | 365 | return QPixmap(d);
|
---|
| 366 | }
|
---|
| 367 |
|
---|
| 368 | /*!
|
---|
[561] | 369 | \fn QPixmap::scroll(int dx, int dy, int x, int y, int width, int height, QRegion *exposed)
|
---|
| 370 | \since 4.6
|
---|
| 371 |
|
---|
| 372 | This convenience function is equivalent to calling QPixmap::scroll(\a dx,
|
---|
| 373 | \a dy, QRect(\a x, \a y, \a width, \a height), \a exposed).
|
---|
| 374 |
|
---|
| 375 | \sa QWidget::scroll(), QGraphicsItem::scroll()
|
---|
| 376 | */
|
---|
| 377 |
|
---|
| 378 | /*!
|
---|
| 379 | \since 4.6
|
---|
| 380 |
|
---|
| 381 | Scrolls the area \a rect of this pixmap by (\a dx, \a dy). The exposed
|
---|
| 382 | region is left unchanged. You can optionally pass a pointer to an empty
|
---|
| 383 | QRegion to get the region that is \a exposed by the scroll operation.
|
---|
| 384 |
|
---|
| 385 | \snippet doc/src/snippets/code/src_gui_image_qpixmap.cpp 2
|
---|
| 386 |
|
---|
| 387 | You cannot scroll while there is an active painter on the pixmap.
|
---|
| 388 |
|
---|
| 389 | \sa QWidget::scroll(), QGraphicsItem::scroll()
|
---|
| 390 | */
|
---|
| 391 | void QPixmap::scroll(int dx, int dy, const QRect &rect, QRegion *exposed)
|
---|
| 392 | {
|
---|
| 393 | if (isNull() || (dx == 0 && dy == 0))
|
---|
| 394 | return;
|
---|
| 395 | QRect dest = rect & this->rect();
|
---|
| 396 | QRect src = dest.translated(-dx, -dy) & dest;
|
---|
| 397 | if (src.isEmpty()) {
|
---|
| 398 | if (exposed)
|
---|
| 399 | *exposed += dest;
|
---|
| 400 | return;
|
---|
| 401 | }
|
---|
| 402 |
|
---|
| 403 | detach();
|
---|
| 404 |
|
---|
| 405 | if (!data->scroll(dx, dy, src)) {
|
---|
| 406 | // Fallback
|
---|
| 407 | QPixmap pix = *this;
|
---|
| 408 | QPainter painter(&pix);
|
---|
| 409 | painter.setCompositionMode(QPainter::CompositionMode_Source);
|
---|
| 410 | painter.drawPixmap(src.translated(dx, dy), *this, src);
|
---|
| 411 | painter.end();
|
---|
| 412 | *this = pix;
|
---|
| 413 | }
|
---|
| 414 |
|
---|
| 415 | if (exposed) {
|
---|
| 416 | *exposed += dest;
|
---|
| 417 | *exposed -= src.translated(dx, dy);
|
---|
| 418 | }
|
---|
| 419 | }
|
---|
| 420 |
|
---|
| 421 | /*!
|
---|
[2] | 422 | Assigns the given \a pixmap to this pixmap and returns a reference
|
---|
| 423 | to this pixmap.
|
---|
| 424 |
|
---|
| 425 | \sa copy(), QPixmap()
|
---|
| 426 | */
|
---|
| 427 |
|
---|
| 428 | QPixmap &QPixmap::operator=(const QPixmap &pixmap)
|
---|
| 429 | {
|
---|
| 430 | if (paintingActive()) {
|
---|
| 431 | qWarning("QPixmap::operator=: Cannot assign to pixmap during painting");
|
---|
| 432 | return *this;
|
---|
| 433 | }
|
---|
| 434 | if (pixmap.paintingActive()) { // make a deep copy
|
---|
| 435 | *this = pixmap.copy();
|
---|
| 436 | } else {
|
---|
| 437 | data = pixmap.data;
|
---|
| 438 | }
|
---|
| 439 | return *this;
|
---|
| 440 | }
|
---|
| 441 |
|
---|
| 442 | /*!
|
---|
| 443 | Returns the pixmap as a QVariant.
|
---|
| 444 | */
|
---|
| 445 | QPixmap::operator QVariant() const
|
---|
| 446 | {
|
---|
| 447 | return QVariant(QVariant::Pixmap, this);
|
---|
| 448 | }
|
---|
| 449 |
|
---|
| 450 | /*!
|
---|
| 451 | \fn bool QPixmap::operator!() const
|
---|
| 452 |
|
---|
| 453 | Returns true if this is a null pixmap; otherwise returns false.
|
---|
| 454 |
|
---|
| 455 | \sa isNull()
|
---|
| 456 | */
|
---|
| 457 |
|
---|
| 458 | /*!
|
---|
| 459 | \fn QPixmap::operator QImage() const
|
---|
| 460 |
|
---|
| 461 | Returns the pixmap as a QImage.
|
---|
| 462 |
|
---|
| 463 | Use the toImage() function instead.
|
---|
| 464 | */
|
---|
| 465 |
|
---|
| 466 | /*!
|
---|
| 467 | Converts the pixmap to a QImage. Returns a null image if the
|
---|
| 468 | conversion fails.
|
---|
| 469 |
|
---|
| 470 | If the pixmap has 1-bit depth, the returned image will also be 1
|
---|
[561] | 471 | bit deep. Images with more bits will be returned in a format
|
---|
| 472 | closely represents the underlying system. Usually this will be
|
---|
| 473 | QImage::Format_ARGB32_Premultiplied for pixmaps with an alpha and
|
---|
| 474 | QImage::Format_RGB32 or QImage::Format_RGB16 for pixmaps without
|
---|
| 475 | alpha.
|
---|
[2] | 476 |
|
---|
| 477 | Note that for the moment, alpha masks on monochrome images are
|
---|
| 478 | ignored.
|
---|
| 479 |
|
---|
| 480 | \sa fromImage(), {QImage#Image Formats}{Image Formats}
|
---|
| 481 | */
|
---|
| 482 | QImage QPixmap::toImage() const
|
---|
| 483 | {
|
---|
| 484 | if (isNull())
|
---|
| 485 | return QImage();
|
---|
| 486 |
|
---|
| 487 | return data->toImage();
|
---|
| 488 | }
|
---|
| 489 |
|
---|
| 490 | /*!
|
---|
| 491 | \fn QMatrix QPixmap::trueMatrix(const QTransform &matrix, int width, int height)
|
---|
| 492 |
|
---|
| 493 | Returns the actual matrix used for transforming a pixmap with the
|
---|
| 494 | given \a width, \a height and \a matrix.
|
---|
| 495 |
|
---|
| 496 | When transforming a pixmap using the transformed() function, the
|
---|
| 497 | transformation matrix is internally adjusted to compensate for
|
---|
| 498 | unwanted translation, i.e. transformed() returns the smallest
|
---|
| 499 | pixmap containing all transformed points of the original
|
---|
| 500 | pixmap. This function returns the modified matrix, which maps
|
---|
| 501 | points correctly from the original pixmap into the new pixmap.
|
---|
| 502 |
|
---|
| 503 | \sa transformed(), {QPixmap#Pixmap Transformations}{Pixmap
|
---|
| 504 | Transformations}
|
---|
| 505 | */
|
---|
| 506 | QTransform QPixmap::trueMatrix(const QTransform &m, int w, int h)
|
---|
| 507 | {
|
---|
| 508 | return QImage::trueMatrix(m, w, h);
|
---|
| 509 | }
|
---|
| 510 |
|
---|
| 511 | /*!
|
---|
| 512 | \overload
|
---|
| 513 |
|
---|
| 514 | This convenience function loads the matrix \a m into a
|
---|
| 515 | QTransform and calls the overloaded function with the
|
---|
| 516 | QTransform and the width \a w and the height \a h.
|
---|
| 517 | */
|
---|
| 518 | QMatrix QPixmap::trueMatrix(const QMatrix &m, int w, int h)
|
---|
| 519 | {
|
---|
| 520 | return trueMatrix(QTransform(m), w, h).toAffine();
|
---|
| 521 | }
|
---|
| 522 |
|
---|
| 523 |
|
---|
| 524 | /*!
|
---|
| 525 | \fn bool QPixmap::isQBitmap() const
|
---|
| 526 |
|
---|
| 527 | Returns true if this is a QBitmap; otherwise returns false.
|
---|
| 528 | */
|
---|
| 529 |
|
---|
| 530 | bool QPixmap::isQBitmap() const
|
---|
| 531 | {
|
---|
| 532 | return data->type == QPixmapData::BitmapType;
|
---|
| 533 | }
|
---|
| 534 |
|
---|
| 535 | /*!
|
---|
| 536 | \fn bool QPixmap::isNull() const
|
---|
| 537 |
|
---|
| 538 | Returns true if this is a null pixmap; otherwise returns false.
|
---|
| 539 |
|
---|
| 540 | A null pixmap has zero width, zero height and no contents. You
|
---|
| 541 | cannot draw in a null pixmap.
|
---|
| 542 | */
|
---|
| 543 | bool QPixmap::isNull() const
|
---|
| 544 | {
|
---|
[561] | 545 | return !data || data->isNull();
|
---|
[2] | 546 | }
|
---|
| 547 |
|
---|
| 548 | /*!
|
---|
| 549 | \fn int QPixmap::width() const
|
---|
| 550 |
|
---|
| 551 | Returns the width of the pixmap.
|
---|
| 552 |
|
---|
| 553 | \sa size(), {QPixmap#Pixmap Information}{Pixmap Information}
|
---|
| 554 | */
|
---|
| 555 | int QPixmap::width() const
|
---|
| 556 | {
|
---|
[561] | 557 | return data ? data->width() : 0;
|
---|
[2] | 558 | }
|
---|
| 559 |
|
---|
| 560 | /*!
|
---|
| 561 | \fn int QPixmap::height() const
|
---|
| 562 |
|
---|
| 563 | Returns the height of the pixmap.
|
---|
| 564 |
|
---|
| 565 | \sa size(), {QPixmap#Pixmap Information}{Pixmap Information}
|
---|
| 566 | */
|
---|
| 567 | int QPixmap::height() const
|
---|
| 568 | {
|
---|
[561] | 569 | return data ? data->height() : 0;
|
---|
[2] | 570 | }
|
---|
| 571 |
|
---|
| 572 | /*!
|
---|
| 573 | \fn QSize QPixmap::size() const
|
---|
| 574 |
|
---|
| 575 | Returns the size of the pixmap.
|
---|
| 576 |
|
---|
| 577 | \sa width(), height(), {QPixmap#Pixmap Information}{Pixmap
|
---|
| 578 | Information}
|
---|
| 579 | */
|
---|
| 580 | QSize QPixmap::size() const
|
---|
| 581 | {
|
---|
[846] | 582 | return data ? QSize(data->width(), data->height()) : QSize(0, 0);
|
---|
[2] | 583 | }
|
---|
| 584 |
|
---|
| 585 | /*!
|
---|
| 586 | \fn QRect QPixmap::rect() const
|
---|
| 587 |
|
---|
| 588 | Returns the pixmap's enclosing rectangle.
|
---|
| 589 |
|
---|
| 590 | \sa {QPixmap#Pixmap Information}{Pixmap Information}
|
---|
| 591 | */
|
---|
| 592 | QRect QPixmap::rect() const
|
---|
| 593 | {
|
---|
[561] | 594 | return data ? QRect(0, 0, data->width(), data->height()) : QRect();
|
---|
[2] | 595 | }
|
---|
| 596 |
|
---|
| 597 | /*!
|
---|
| 598 | \fn int QPixmap::depth() const
|
---|
| 599 |
|
---|
| 600 | Returns the depth of the pixmap.
|
---|
| 601 |
|
---|
| 602 | The pixmap depth is also called bits per pixel (bpp) or bit planes
|
---|
| 603 | of a pixmap. A null pixmap has depth 0.
|
---|
| 604 |
|
---|
| 605 | \sa defaultDepth(), {QPixmap#Pixmap Information}{Pixmap
|
---|
| 606 | Information}
|
---|
| 607 | */
|
---|
| 608 | int QPixmap::depth() const
|
---|
| 609 | {
|
---|
[561] | 610 | return data ? data->depth() : 0;
|
---|
[2] | 611 | }
|
---|
| 612 |
|
---|
| 613 | /*!
|
---|
| 614 | \fn void QPixmap::resize(const QSize &size)
|
---|
| 615 | \overload
|
---|
| 616 | \compat
|
---|
| 617 |
|
---|
| 618 | Use QPixmap::copy() instead to get the pixmap with the new size.
|
---|
| 619 |
|
---|
| 620 | \oldcode
|
---|
| 621 | pixmap.resize(size);
|
---|
| 622 | \newcode
|
---|
| 623 | pixmap = pixmap.copy(QRect(QPoint(0, 0), size));
|
---|
| 624 | \endcode
|
---|
| 625 | */
|
---|
| 626 | #ifdef QT3_SUPPORT
|
---|
| 627 | void QPixmap::resize_helper(const QSize &s)
|
---|
| 628 | {
|
---|
| 629 | int w = s.width();
|
---|
| 630 | int h = s.height();
|
---|
| 631 | if (w < 1 || h < 1) {
|
---|
| 632 | *this = QPixmap();
|
---|
| 633 | return;
|
---|
| 634 | }
|
---|
| 635 |
|
---|
| 636 | if (size() == s)
|
---|
| 637 | return;
|
---|
| 638 |
|
---|
[846] | 639 | // QPixmap.data member may be QRuntimePixmapData so use pixmapData() function to get
|
---|
| 640 | // the actual underlaying runtime pixmap data.
|
---|
| 641 | QPixmapData *pd = pixmapData();
|
---|
| 642 |
|
---|
[2] | 643 | // Create new pixmap
|
---|
[846] | 644 | QPixmap pm(QSize(w, h), pd ? pd->type : QPixmapData::PixmapType);
|
---|
[2] | 645 | bool uninit = false;
|
---|
| 646 | #if defined(Q_WS_X11)
|
---|
[846] | 647 | QX11PixmapData *x11Data = pd && pd->classId() == QPixmapData::X11Class ? static_cast<QX11PixmapData*>(pd) : 0;
|
---|
[2] | 648 | if (x11Data) {
|
---|
| 649 | pm.x11SetScreen(x11Data->xinfo.screen());
|
---|
[561] | 650 | uninit = x11Data->flags & QX11PixmapData::Uninitialized;
|
---|
[2] | 651 | }
|
---|
| 652 | #elif defined(Q_WS_MAC)
|
---|
[846] | 653 | QMacPixmapData *macData = pd && pd->classId() == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(pd) : 0;
|
---|
[2] | 654 | if (macData)
|
---|
| 655 | uninit = macData->uninit;
|
---|
| 656 | #endif
|
---|
| 657 | if (!uninit && !isNull()) {
|
---|
| 658 | // Copy old pixmap
|
---|
| 659 | if (hasAlphaChannel())
|
---|
| 660 | pm.fill(Qt::transparent);
|
---|
| 661 | QPainter p(&pm);
|
---|
| 662 | p.drawPixmap(0, 0, *this, 0, 0, qMin(width(), w), qMin(height(), h));
|
---|
| 663 | }
|
---|
| 664 |
|
---|
[561] | 665 | #if defined(Q_WS_X11)
|
---|
[2] | 666 | if (x11Data && x11Data->x11_mask) {
|
---|
[846] | 667 | QPixmapData *newPd = pm.pixmapData();
|
---|
| 668 | QX11PixmapData *pmData = (newPd && newPd->classId() == QPixmapData::X11Class)
|
---|
| 669 | ? static_cast<QX11PixmapData*>(newPd) : 0;
|
---|
| 670 | if (pmData) {
|
---|
| 671 | pmData->x11_mask = (Qt::HANDLE)XCreatePixmap(X11->display,
|
---|
| 672 | RootWindow(x11Data->xinfo.display(),
|
---|
| 673 | x11Data->xinfo.screen()),
|
---|
| 674 | w, h, 1);
|
---|
| 675 | GC gc = XCreateGC(X11->display, pmData->x11_mask, 0, 0);
|
---|
| 676 | XCopyArea(X11->display, x11Data->x11_mask, pmData->x11_mask, gc, 0, 0,
|
---|
| 677 | qMin(width(), w), qMin(height(), h), 0, 0);
|
---|
| 678 | XFreeGC(X11->display, gc);
|
---|
| 679 | }
|
---|
[2] | 680 | }
|
---|
| 681 | #endif
|
---|
| 682 | *this = pm;
|
---|
| 683 | }
|
---|
| 684 | #endif
|
---|
| 685 |
|
---|
| 686 | /*!
|
---|
| 687 | \fn void QPixmap::resize(int width, int height)
|
---|
| 688 | \compat
|
---|
| 689 |
|
---|
| 690 | Use QPixmap::copy() instead to get the pixmap with the new size.
|
---|
| 691 |
|
---|
| 692 | \oldcode
|
---|
| 693 | pixmap.resize(10, 20);
|
---|
| 694 | \newcode
|
---|
| 695 | pixmap = pixmap.copy(0, 0, 10, 20);
|
---|
| 696 | \endcode
|
---|
| 697 | */
|
---|
| 698 |
|
---|
| 699 | /*!
|
---|
| 700 | \fn bool QPixmap::selfMask() const
|
---|
| 701 | \compat
|
---|
| 702 |
|
---|
| 703 | Returns whether the pixmap is its own mask or not.
|
---|
| 704 |
|
---|
| 705 | This function is no longer relevant since the concept of self
|
---|
| 706 | masking doesn't exists anymore.
|
---|
| 707 | */
|
---|
| 708 |
|
---|
| 709 | /*!
|
---|
| 710 | Sets a mask bitmap.
|
---|
| 711 |
|
---|
| 712 | This function merges the \a mask with the pixmap's alpha channel. A pixel
|
---|
| 713 | value of 1 on the mask means the pixmap's pixel is unchanged; a value of 0
|
---|
| 714 | means the pixel is transparent. The mask must have the same size as this
|
---|
| 715 | pixmap.
|
---|
| 716 |
|
---|
| 717 | Setting a null mask resets the mask, leaving the previously transparent
|
---|
| 718 | pixels black. The effect of this function is undefined when the pixmap is
|
---|
| 719 | being painted on.
|
---|
| 720 |
|
---|
[561] | 721 | \warning This is potentially an expensive operation.
|
---|
[2] | 722 |
|
---|
| 723 | \sa mask(), {QPixmap#Pixmap Transformations}{Pixmap Transformations},
|
---|
| 724 | QBitmap
|
---|
| 725 | */
|
---|
| 726 | void QPixmap::setMask(const QBitmap &mask)
|
---|
| 727 | {
|
---|
| 728 | if (paintingActive()) {
|
---|
| 729 | qWarning("QPixmap::setMask: Cannot set mask while pixmap is being painted on");
|
---|
| 730 | return;
|
---|
| 731 | }
|
---|
| 732 |
|
---|
| 733 | if (!mask.isNull() && mask.size() != size()) {
|
---|
| 734 | qWarning("QPixmap::setMask() mask size differs from pixmap size");
|
---|
| 735 | return;
|
---|
| 736 | }
|
---|
| 737 |
|
---|
[561] | 738 | if (isNull())
|
---|
| 739 | return;
|
---|
| 740 |
|
---|
[2] | 741 | if (static_cast<const QPixmap &>(mask).data == data) // trying to selfmask
|
---|
| 742 | return;
|
---|
| 743 |
|
---|
| 744 | detach();
|
---|
| 745 | data->setMask(mask);
|
---|
| 746 | }
|
---|
| 747 |
|
---|
| 748 | #ifndef QT_NO_IMAGE_HEURISTIC_MASK
|
---|
| 749 | /*!
|
---|
| 750 | Creates and returns a heuristic mask for this pixmap.
|
---|
| 751 |
|
---|
| 752 | The function works by selecting a color from one of the corners
|
---|
| 753 | and then chipping away pixels of that color, starting at all the
|
---|
| 754 | edges. If \a clipTight is true (the default) the mask is just
|
---|
| 755 | large enough to cover the pixels; otherwise, the mask is larger
|
---|
| 756 | than the data pixels.
|
---|
| 757 |
|
---|
| 758 | The mask may not be perfect but it should be reasonable, so you
|
---|
| 759 | can do things such as the following:
|
---|
| 760 |
|
---|
| 761 | \snippet doc/src/snippets/code/src_gui_image_qpixmap.cpp 1
|
---|
| 762 |
|
---|
| 763 | This function is slow because it involves converting to/from a
|
---|
| 764 | QImage, and non-trivial computations.
|
---|
| 765 |
|
---|
| 766 | \sa QImage::createHeuristicMask(), createMaskFromColor()
|
---|
| 767 | */
|
---|
| 768 | QBitmap QPixmap::createHeuristicMask(bool clipTight) const
|
---|
| 769 | {
|
---|
| 770 | QBitmap m = QBitmap::fromImage(toImage().createHeuristicMask(clipTight));
|
---|
| 771 | return m;
|
---|
| 772 | }
|
---|
| 773 | #endif
|
---|
| 774 |
|
---|
| 775 | /*!
|
---|
| 776 | Creates and returns a mask for this pixmap based on the given \a
|
---|
| 777 | maskColor. If the \a mode is Qt::MaskInColor, all pixels matching the
|
---|
[846] | 778 | maskColor will be transparent. If \a mode is Qt::MaskOutColor, all pixels
|
---|
| 779 | matching the maskColor will be opaque.
|
---|
[2] | 780 |
|
---|
| 781 | This function is slow because it involves converting to/from a
|
---|
| 782 | QImage.
|
---|
| 783 |
|
---|
| 784 | \sa createHeuristicMask(), QImage::createMaskFromColor()
|
---|
| 785 | */
|
---|
| 786 | QBitmap QPixmap::createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode) const
|
---|
| 787 | {
|
---|
| 788 | QImage image = toImage().convertToFormat(QImage::Format_ARGB32);
|
---|
| 789 | return QBitmap::fromImage(image.createMaskFromColor(maskColor.rgba(), mode));
|
---|
| 790 | }
|
---|
| 791 |
|
---|
| 792 | /*! \overload
|
---|
| 793 |
|
---|
| 794 | Creates and returns a mask for this pixmap based on the given \a
|
---|
| 795 | maskColor. Same as calling createMaskFromColor(maskColor,
|
---|
| 796 | Qt::MaskInColor)
|
---|
| 797 |
|
---|
| 798 | \sa createHeuristicMask(), QImage::createMaskFromColor()
|
---|
| 799 | */
|
---|
| 800 | QBitmap QPixmap::createMaskFromColor(const QColor &maskColor) const
|
---|
| 801 | {
|
---|
| 802 | return createMaskFromColor(maskColor, Qt::MaskInColor);
|
---|
| 803 | }
|
---|
| 804 |
|
---|
| 805 | /*!
|
---|
| 806 | Loads a pixmap from the file with the given \a fileName. Returns
|
---|
| 807 | true if the pixmap was successfully loaded; otherwise returns
|
---|
| 808 | false.
|
---|
| 809 |
|
---|
| 810 | The loader attempts to read the pixmap using the specified \a
|
---|
| 811 | format. If the \a format is not specified (which is the default),
|
---|
| 812 | the loader probes the file for a header to guess the file format.
|
---|
| 813 |
|
---|
| 814 | The file name can either refer to an actual file on disk or to one
|
---|
| 815 | of the application's embedded resources. See the
|
---|
| 816 | \l{resources.html}{Resource System} overview for details on how to
|
---|
| 817 | embed pixmaps and other resource files in the application's
|
---|
| 818 | executable.
|
---|
| 819 |
|
---|
| 820 | If the data needs to be modified to fit in a lower-resolution
|
---|
| 821 | result (e.g. converting from 32-bit to 8-bit), use the \a flags to
|
---|
| 822 | control the conversion.
|
---|
| 823 |
|
---|
| 824 | Note that QPixmaps are automatically added to the QPixmapCache
|
---|
| 825 | when loaded from a file; the key used is internal and can not
|
---|
| 826 | be acquired.
|
---|
| 827 |
|
---|
| 828 | \sa loadFromData(), {QPixmap#Reading and Writing Image
|
---|
| 829 | Files}{Reading and Writing Image Files}
|
---|
| 830 | */
|
---|
| 831 |
|
---|
| 832 | bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConversionFlags flags)
|
---|
| 833 | {
|
---|
| 834 | if (fileName.isEmpty())
|
---|
| 835 | return false;
|
---|
| 836 |
|
---|
| 837 | QFileInfo info(fileName);
|
---|
[846] | 838 | QString key = QLatin1Literal("qt_pixmap")
|
---|
| 839 | % info.absoluteFilePath()
|
---|
| 840 | % HexString<uint>(info.lastModified().toTime_t())
|
---|
| 841 | % HexString<quint64>(info.size())
|
---|
| 842 | % HexString<uint>(data ? data->pixelType() : QPixmapData::PixmapType);
|
---|
[2] | 843 |
|
---|
[846] | 844 | // Note: If no extension is provided, we try to match the
|
---|
| 845 | // file against known plugin extensions
|
---|
| 846 | if (!info.completeSuffix().isEmpty() && !info.exists())
|
---|
| 847 | return false;
|
---|
| 848 |
|
---|
[2] | 849 | if (QPixmapCache::find(key, *this))
|
---|
| 850 | return true;
|
---|
| 851 |
|
---|
[769] | 852 | QScopedPointer<QPixmapData> tmp(QPixmapData::create(0, 0, data ? data->type : QPixmapData::PixmapType));
|
---|
| 853 | if (tmp->fromFile(fileName, format, flags)) {
|
---|
| 854 | data = tmp.take();
|
---|
| 855 | QPixmapCache::insert(key, *this);
|
---|
| 856 | return true;
|
---|
[651] | 857 | }
|
---|
| 858 |
|
---|
[769] | 859 | return false;
|
---|
[2] | 860 | }
|
---|
| 861 |
|
---|
| 862 | /*!
|
---|
| 863 | \fn bool QPixmap::loadFromData(const uchar *data, uint len, const char *format, Qt::ImageConversionFlags flags)
|
---|
| 864 |
|
---|
| 865 | Loads a pixmap from the \a len first bytes of the given binary \a
|
---|
| 866 | data. Returns true if the pixmap was loaded successfully;
|
---|
| 867 | otherwise returns false.
|
---|
| 868 |
|
---|
| 869 | The loader attempts to read the pixmap using the specified \a
|
---|
| 870 | format. If the \a format is not specified (which is the default),
|
---|
| 871 | the loader probes the file for a header to guess the file format.
|
---|
| 872 |
|
---|
| 873 | If the data needs to be modified to fit in a lower-resolution
|
---|
| 874 | result (e.g. converting from 32-bit to 8-bit), use the \a flags to
|
---|
| 875 | control the conversion.
|
---|
| 876 |
|
---|
| 877 | \sa load(), {QPixmap#Reading and Writing Image Files}{Reading and
|
---|
| 878 | Writing Image Files}
|
---|
| 879 | */
|
---|
| 880 |
|
---|
| 881 | bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags)
|
---|
| 882 | {
|
---|
[561] | 883 | if (len == 0 || buf == 0)
|
---|
| 884 | return false;
|
---|
[2] | 885 |
|
---|
[561] | 886 | if (!data)
|
---|
| 887 | data = QPixmapData::create(0, 0, QPixmapData::PixmapType);
|
---|
| 888 |
|
---|
| 889 | return data->fromData(buf, len, format, flags);
|
---|
[2] | 890 | }
|
---|
| 891 |
|
---|
| 892 | /*!
|
---|
| 893 | \fn bool QPixmap::loadFromData(const QByteArray &data, const char *format, Qt::ImageConversionFlags flags)
|
---|
| 894 |
|
---|
| 895 | \overload
|
---|
| 896 |
|
---|
| 897 | Loads a pixmap from the binary \a data using the specified \a
|
---|
| 898 | format and conversion \a flags.
|
---|
| 899 | */
|
---|
| 900 |
|
---|
| 901 |
|
---|
| 902 | /*!
|
---|
| 903 | Saves the pixmap to the file with the given \a fileName using the
|
---|
| 904 | specified image file \a format and \a quality factor. Returns true
|
---|
| 905 | if successful; otherwise returns false.
|
---|
| 906 |
|
---|
| 907 | The \a quality factor must be in the range [0,100] or -1. Specify
|
---|
| 908 | 0 to obtain small compressed files, 100 for large uncompressed
|
---|
| 909 | files, and -1 to use the default settings.
|
---|
| 910 |
|
---|
| 911 | If \a format is 0, an image format will be chosen from \a fileName's
|
---|
| 912 | suffix.
|
---|
| 913 |
|
---|
| 914 | \sa {QPixmap#Reading and Writing Image Files}{Reading and Writing
|
---|
| 915 | Image Files}
|
---|
| 916 | */
|
---|
| 917 |
|
---|
| 918 | bool QPixmap::save(const QString &fileName, const char *format, int quality) const
|
---|
| 919 | {
|
---|
| 920 | if (isNull())
|
---|
| 921 | return false; // nothing to save
|
---|
| 922 | QImageWriter writer(fileName, format);
|
---|
| 923 | return doImageIO(&writer, quality);
|
---|
| 924 | }
|
---|
| 925 |
|
---|
| 926 | /*!
|
---|
| 927 | \overload
|
---|
| 928 |
|
---|
| 929 | This function writes a QPixmap to the given \a device using the
|
---|
| 930 | specified image file \a format and \a quality factor. This can be
|
---|
| 931 | used, for example, to save a pixmap directly into a QByteArray:
|
---|
| 932 |
|
---|
| 933 | \snippet doc/src/snippets/image/image.cpp 1
|
---|
| 934 | */
|
---|
| 935 |
|
---|
| 936 | bool QPixmap::save(QIODevice* device, const char* format, int quality) const
|
---|
| 937 | {
|
---|
| 938 | if (isNull())
|
---|
| 939 | return false; // nothing to save
|
---|
| 940 | QImageWriter writer(device, format);
|
---|
| 941 | return doImageIO(&writer, quality);
|
---|
| 942 | }
|
---|
| 943 |
|
---|
| 944 | /*! \internal
|
---|
| 945 | */
|
---|
| 946 | bool QPixmap::doImageIO(QImageWriter *writer, int quality) const
|
---|
| 947 | {
|
---|
| 948 | if (quality > 100 || quality < -1)
|
---|
| 949 | qWarning("QPixmap::save: quality out of range [-1,100]");
|
---|
| 950 | if (quality >= 0)
|
---|
| 951 | writer->setQuality(qMin(quality,100));
|
---|
| 952 | return writer->write(toImage());
|
---|
| 953 | }
|
---|
| 954 |
|
---|
| 955 |
|
---|
| 956 | // The implementation (and documentation) of
|
---|
| 957 | // QPixmap::fill(const QWidget *, const QPoint &)
|
---|
| 958 | // is in qwidget.cpp
|
---|
| 959 |
|
---|
| 960 | /*!
|
---|
| 961 | \fn void QPixmap::fill(const QWidget *widget, int x, int y)
|
---|
| 962 | \overload
|
---|
| 963 |
|
---|
| 964 | Fills the pixmap with the \a widget's background color or pixmap.
|
---|
| 965 | The given point, (\a x, \a y), defines an offset in widget
|
---|
| 966 | coordinates to which the pixmap's top-left pixel will be mapped
|
---|
| 967 | to.
|
---|
| 968 | */
|
---|
| 969 |
|
---|
| 970 | /*!
|
---|
| 971 | Fills the pixmap with the given \a color.
|
---|
| 972 |
|
---|
[561] | 973 | The effect of this function is undefined when the pixmap is
|
---|
| 974 | being painted on.
|
---|
| 975 |
|
---|
[2] | 976 | \sa {QPixmap#Pixmap Transformations}{Pixmap Transformations}
|
---|
| 977 | */
|
---|
| 978 |
|
---|
| 979 | void QPixmap::fill(const QColor &color)
|
---|
| 980 | {
|
---|
| 981 | if (isNull())
|
---|
| 982 | return;
|
---|
| 983 |
|
---|
[561] | 984 | // Some people are probably already calling fill while a painter is active, so to not break
|
---|
| 985 | // their programs, only print a warning and return when the fill operation could cause a crash.
|
---|
| 986 | if (paintingActive() && (color.alpha() != 255) && !hasAlphaChannel()) {
|
---|
| 987 | qWarning("QPixmap::fill: Cannot fill while pixmap is being painted on");
|
---|
| 988 | return;
|
---|
| 989 | }
|
---|
| 990 |
|
---|
| 991 | if (data->ref == 1) {
|
---|
| 992 | // detach() will also remove this pixmap from caches, so
|
---|
| 993 | // it has to be called even when ref == 1.
|
---|
| 994 | detach();
|
---|
| 995 | } else {
|
---|
| 996 | // Don't bother to make a copy of the data object, since
|
---|
| 997 | // it will be filled with new pixel data anyway.
|
---|
| 998 | QPixmapData *d = data->createCompatiblePixmapData();
|
---|
| 999 | d->resize(data->width(), data->height());
|
---|
| 1000 | data = d;
|
---|
| 1001 | }
|
---|
[2] | 1002 | data->fill(color);
|
---|
| 1003 | }
|
---|
| 1004 |
|
---|
| 1005 | /*! \obsolete
|
---|
| 1006 | Returns a number that identifies the contents of this QPixmap
|
---|
| 1007 | object. Distinct QPixmap objects can only have the same serial
|
---|
| 1008 | number if they refer to the same contents (but they don't have
|
---|
| 1009 | to).
|
---|
| 1010 |
|
---|
| 1011 | Use cacheKey() instead.
|
---|
| 1012 |
|
---|
| 1013 | \warning The serial number doesn't necessarily change when
|
---|
| 1014 | the pixmap is altered. This means that it may be dangerous to use
|
---|
| 1015 | it as a cache key. For caching pixmaps, we recommend using the
|
---|
| 1016 | QPixmapCache class whenever possible.
|
---|
| 1017 | */
|
---|
| 1018 | int QPixmap::serialNumber() const
|
---|
| 1019 | {
|
---|
| 1020 | if (isNull())
|
---|
| 1021 | return 0;
|
---|
| 1022 | return data->serialNumber();
|
---|
| 1023 | }
|
---|
| 1024 |
|
---|
| 1025 | /*!
|
---|
| 1026 | Returns a number that identifies this QPixmap. Distinct QPixmap
|
---|
| 1027 | objects can only have the same cache key if they refer to the same
|
---|
| 1028 | contents.
|
---|
| 1029 |
|
---|
| 1030 | The cacheKey() will change when the pixmap is altered.
|
---|
| 1031 | */
|
---|
| 1032 | qint64 QPixmap::cacheKey() const
|
---|
| 1033 | {
|
---|
[561] | 1034 | if (isNull())
|
---|
| 1035 | return 0;
|
---|
| 1036 |
|
---|
[651] | 1037 | Q_ASSERT(data);
|
---|
| 1038 | return data->cacheKey();
|
---|
[2] | 1039 | }
|
---|
| 1040 |
|
---|
| 1041 | static void sendResizeEvents(QWidget *target)
|
---|
| 1042 | {
|
---|
| 1043 | QResizeEvent e(target->size(), QSize());
|
---|
| 1044 | QApplication::sendEvent(target, &e);
|
---|
| 1045 |
|
---|
| 1046 | const QObjectList children = target->children();
|
---|
| 1047 | for (int i = 0; i < children.size(); ++i) {
|
---|
| 1048 | QWidget *child = static_cast<QWidget*>(children.at(i));
|
---|
| 1049 | if (child->isWidgetType() && !child->isWindow() && child->testAttribute(Qt::WA_PendingResizeEvent))
|
---|
| 1050 | sendResizeEvents(child);
|
---|
| 1051 | }
|
---|
| 1052 | }
|
---|
| 1053 |
|
---|
| 1054 | /*!
|
---|
| 1055 | \fn QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rectangle)
|
---|
| 1056 |
|
---|
| 1057 | Creates a pixmap and paints the given \a widget, restricted by the
|
---|
| 1058 | given \a rectangle, in it. If the \a widget has any children, then
|
---|
| 1059 | they are also painted in the appropriate positions.
|
---|
| 1060 |
|
---|
| 1061 | If no rectangle is specified (the default) the entire widget is
|
---|
| 1062 | painted.
|
---|
| 1063 |
|
---|
| 1064 | If \a widget is 0, the specified rectangle doesn't overlap the
|
---|
| 1065 | widget's rectangle, or an error occurs, the function will return a
|
---|
| 1066 | null QPixmap. If the rectangle is a superset of the given \a
|
---|
| 1067 | widget, the areas outside the \a widget are covered with the
|
---|
| 1068 | widget's background.
|
---|
| 1069 |
|
---|
| 1070 | This function actually asks \a widget to paint itself (and its
|
---|
| 1071 | children to paint themselves) by calling paintEvent() with painter
|
---|
| 1072 | redirection turned on. But QPixmap also provides the grabWindow()
|
---|
| 1073 | function which is a bit faster by grabbing pixels directly off the
|
---|
| 1074 | screen. In addition, if there are overlaying windows,
|
---|
| 1075 | grabWindow(), unlike grabWidget(), will see them.
|
---|
| 1076 |
|
---|
| 1077 | \warning Do not grab a widget from its QWidget::paintEvent().
|
---|
| 1078 | However, it is safe to grab a widget from another widget's
|
---|
| 1079 | \l {QWidget::}{paintEvent()}.
|
---|
| 1080 |
|
---|
| 1081 | \sa grabWindow()
|
---|
| 1082 | */
|
---|
| 1083 |
|
---|
| 1084 | QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rect)
|
---|
| 1085 | {
|
---|
| 1086 | if (!widget)
|
---|
| 1087 | return QPixmap();
|
---|
| 1088 |
|
---|
| 1089 | if (widget->testAttribute(Qt::WA_PendingResizeEvent) || !widget->testAttribute(Qt::WA_WState_Created))
|
---|
| 1090 | sendResizeEvents(widget);
|
---|
| 1091 |
|
---|
[846] | 1092 | widget->d_func()->prepareToRender(QRegion(),
|
---|
| 1093 | QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask);
|
---|
| 1094 |
|
---|
[2] | 1095 | QRect r(rect);
|
---|
| 1096 | if (r.width() < 0)
|
---|
| 1097 | r.setWidth(widget->width() - rect.x());
|
---|
| 1098 | if (r.height() < 0)
|
---|
| 1099 | r.setHeight(widget->height() - rect.y());
|
---|
| 1100 |
|
---|
| 1101 | if (!r.intersects(widget->rect()))
|
---|
| 1102 | return QPixmap();
|
---|
| 1103 |
|
---|
| 1104 | QPixmap res(r.size());
|
---|
[846] | 1105 | if (!qt_widget_private(widget)->isOpaque)
|
---|
| 1106 | res.fill(Qt::transparent);
|
---|
| 1107 |
|
---|
| 1108 | widget->d_func()->render(&res, QPoint(), r, QWidget::DrawWindowBackground
|
---|
| 1109 | | QWidget::DrawChildren | QWidget::IgnoreMask, true);
|
---|
[2] | 1110 | return res;
|
---|
| 1111 | }
|
---|
| 1112 |
|
---|
| 1113 | /*!
|
---|
| 1114 | \fn QPixmap QPixmap::grabWidget(QWidget *widget, int x, int y, int
|
---|
| 1115 | width, int height)
|
---|
| 1116 |
|
---|
| 1117 | \overload
|
---|
| 1118 |
|
---|
| 1119 | Creates a pixmap and paints the given \a widget, restricted by
|
---|
| 1120 | QRect(\a x, \a y, \a width, \a height), in it.
|
---|
| 1121 |
|
---|
| 1122 | \warning Do not grab a widget from its QWidget::paintEvent().
|
---|
| 1123 | However, it is safe to grab a widget from another widget's
|
---|
| 1124 | \l {QWidget::}{paintEvent()}.
|
---|
| 1125 | */
|
---|
| 1126 |
|
---|
| 1127 |
|
---|
| 1128 | /*!
|
---|
| 1129 | \since 4.5
|
---|
| 1130 |
|
---|
| 1131 | \enum QPixmap::ShareMode
|
---|
| 1132 |
|
---|
| 1133 | This enum type defines the share modes that are available when
|
---|
| 1134 | creating a QPixmap object from a raw X11 Pixmap handle.
|
---|
| 1135 |
|
---|
| 1136 | \value ImplicitlyShared This mode will cause the QPixmap object to
|
---|
| 1137 | create a copy of the internal data before it is modified, thus
|
---|
| 1138 | keeping the original X11 pixmap intact.
|
---|
| 1139 |
|
---|
| 1140 | \value ExplicitlyShared In this mode, the pixmap data will \e not be
|
---|
| 1141 | copied before it is modified, which in effect will change the
|
---|
| 1142 | original X11 pixmap.
|
---|
| 1143 |
|
---|
| 1144 | \warning This enum is only used for X11 specific functions; using
|
---|
| 1145 | it is non-portable.
|
---|
| 1146 |
|
---|
| 1147 | \sa QPixmap::fromX11Pixmap()
|
---|
| 1148 | */
|
---|
| 1149 |
|
---|
| 1150 | /*!
|
---|
| 1151 | \since 4.5
|
---|
| 1152 |
|
---|
| 1153 | \fn QPixmap QPixmap::fromX11Pixmap(Qt::HANDLE pixmap, QPixmap::ShareMode mode)
|
---|
| 1154 |
|
---|
| 1155 | Creates a QPixmap from the native X11 Pixmap handle \a pixmap,
|
---|
| 1156 | using \a mode as the share mode. The default share mode is
|
---|
| 1157 | QPixmap::ImplicitlyShared, which means that a copy of the pixmap is
|
---|
| 1158 | made if someone tries to modify it by e.g. drawing onto it.
|
---|
| 1159 |
|
---|
| 1160 | QPixmap does \e not take ownership of the \a pixmap handle, and
|
---|
| 1161 | have to be deleted by the user.
|
---|
| 1162 |
|
---|
| 1163 | \warning This function is X11 specific; using it is non-portable.
|
---|
| 1164 |
|
---|
| 1165 | \sa QPixmap::ShareMode
|
---|
| 1166 | */
|
---|
| 1167 |
|
---|
| 1168 |
|
---|
| 1169 | #if defined(Q_WS_X11) || defined(Q_WS_QWS)
|
---|
| 1170 |
|
---|
| 1171 | /*!
|
---|
| 1172 | Returns the pixmap's handle to the device context.
|
---|
| 1173 |
|
---|
| 1174 | Note that, since QPixmap make use of \l {Implicit Data
|
---|
| 1175 | Sharing}{implicit data sharing}, the detach() function must be
|
---|
| 1176 | called explicitly to ensure that only \e this pixmap's data is
|
---|
| 1177 | modified if the pixmap data is shared.
|
---|
| 1178 |
|
---|
| 1179 | \warning This function is X11 specific; using it is non-portable.
|
---|
| 1180 |
|
---|
| 1181 | \sa detach()
|
---|
| 1182 | */
|
---|
| 1183 |
|
---|
| 1184 | Qt::HANDLE QPixmap::handle() const
|
---|
| 1185 | {
|
---|
| 1186 | #if defined(Q_WS_X11)
|
---|
[846] | 1187 | const QPixmapData *pd = pixmapData();
|
---|
| 1188 | if (pd) {
|
---|
| 1189 | if (pd->classId() == QPixmapData::X11Class)
|
---|
| 1190 | return static_cast<const QX11PixmapData*>(pd)->handle();
|
---|
| 1191 | else
|
---|
| 1192 | qWarning("QPixmap::handle(): Pixmap is not an X11 class pixmap");
|
---|
| 1193 | }
|
---|
[2] | 1194 | #endif
|
---|
| 1195 | return 0;
|
---|
| 1196 | }
|
---|
| 1197 | #endif
|
---|
| 1198 |
|
---|
| 1199 |
|
---|
| 1200 | #ifdef QT3_SUPPORT
|
---|
| 1201 | static Qt::ImageConversionFlags colorModeToFlags(QPixmap::ColorMode mode)
|
---|
| 1202 | {
|
---|
| 1203 | Qt::ImageConversionFlags flags = Qt::AutoColor;
|
---|
| 1204 | switch (mode) {
|
---|
| 1205 | case QPixmap::Color:
|
---|
| 1206 | flags |= Qt::ColorOnly;
|
---|
| 1207 | break;
|
---|
| 1208 | case QPixmap::Mono:
|
---|
| 1209 | flags |= Qt::MonoOnly;
|
---|
| 1210 | break;
|
---|
| 1211 | default:
|
---|
| 1212 | break;// Nothing.
|
---|
| 1213 | }
|
---|
| 1214 | return flags;
|
---|
| 1215 | }
|
---|
| 1216 |
|
---|
| 1217 | /*!
|
---|
| 1218 | Use the constructor that takes a Qt::ImageConversionFlag instead.
|
---|
| 1219 | */
|
---|
| 1220 |
|
---|
| 1221 | QPixmap::QPixmap(const QString& fileName, const char *format, ColorMode mode)
|
---|
| 1222 | : QPaintDevice()
|
---|
| 1223 | {
|
---|
| 1224 | init(0, 0, QPixmapData::PixmapType);
|
---|
| 1225 | if (!qt_pixmap_thread_test())
|
---|
| 1226 | return;
|
---|
| 1227 |
|
---|
| 1228 | load(fileName, format, colorModeToFlags(mode));
|
---|
| 1229 | }
|
---|
| 1230 |
|
---|
| 1231 | /*!
|
---|
| 1232 | Constructs a pixmap from the QImage \a image.
|
---|
| 1233 |
|
---|
| 1234 | Use the static fromImage() function instead.
|
---|
| 1235 | */
|
---|
| 1236 | QPixmap::QPixmap(const QImage& image)
|
---|
| 1237 | : QPaintDevice()
|
---|
| 1238 | {
|
---|
| 1239 | init(0, 0, QPixmapData::PixmapType);
|
---|
| 1240 | if (!qt_pixmap_thread_test())
|
---|
| 1241 | return;
|
---|
| 1242 |
|
---|
[561] | 1243 | if (data && data->pixelType() == QPixmapData::BitmapType)
|
---|
[2] | 1244 | *this = QBitmap::fromImage(image);
|
---|
| 1245 | else
|
---|
| 1246 | *this = fromImage(image);
|
---|
| 1247 | }
|
---|
| 1248 |
|
---|
| 1249 | /*!
|
---|
| 1250 | \overload
|
---|
| 1251 |
|
---|
| 1252 | Converts the given \a image to a pixmap that is assigned to this
|
---|
| 1253 | pixmap.
|
---|
| 1254 |
|
---|
| 1255 | Use the static fromImage() function instead.
|
---|
| 1256 | */
|
---|
| 1257 |
|
---|
| 1258 | QPixmap &QPixmap::operator=(const QImage &image)
|
---|
| 1259 | {
|
---|
[561] | 1260 | if (data && data->pixelType() == QPixmapData::BitmapType)
|
---|
[2] | 1261 | *this = QBitmap::fromImage(image);
|
---|
| 1262 | else
|
---|
| 1263 | *this = fromImage(image);
|
---|
| 1264 | return *this;
|
---|
| 1265 | }
|
---|
| 1266 |
|
---|
| 1267 | /*!
|
---|
| 1268 | Use the load() function that takes a Qt::ImageConversionFlag instead.
|
---|
| 1269 | */
|
---|
| 1270 |
|
---|
| 1271 | bool QPixmap::load(const QString &fileName, const char *format, ColorMode mode)
|
---|
| 1272 | {
|
---|
| 1273 | return load(fileName, format, colorModeToFlags(mode));
|
---|
| 1274 | }
|
---|
| 1275 |
|
---|
| 1276 | /*!
|
---|
| 1277 | Use the loadFromData() function that takes a Qt::ImageConversionFlag instead.
|
---|
| 1278 | */
|
---|
| 1279 |
|
---|
| 1280 | bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, ColorMode mode)
|
---|
| 1281 | {
|
---|
| 1282 | return loadFromData(buf, len, format, colorModeToFlags(mode));
|
---|
| 1283 | }
|
---|
| 1284 |
|
---|
| 1285 | /*!
|
---|
| 1286 | Use the static fromImage() function instead.
|
---|
| 1287 | */
|
---|
| 1288 | bool QPixmap::convertFromImage(const QImage &image, ColorMode mode)
|
---|
| 1289 | {
|
---|
[561] | 1290 | if (data && data->pixelType() == QPixmapData::BitmapType)
|
---|
[2] | 1291 | *this = QBitmap::fromImage(image, colorModeToFlags(mode));
|
---|
| 1292 | else
|
---|
| 1293 | *this = fromImage(image, colorModeToFlags(mode));
|
---|
| 1294 | return !isNull();
|
---|
| 1295 | }
|
---|
| 1296 |
|
---|
| 1297 | #endif
|
---|
| 1298 |
|
---|
| 1299 | /*****************************************************************************
|
---|
| 1300 | QPixmap stream functions
|
---|
| 1301 | *****************************************************************************/
|
---|
| 1302 | #if !defined(QT_NO_DATASTREAM)
|
---|
| 1303 | /*!
|
---|
| 1304 | \relates QPixmap
|
---|
| 1305 |
|
---|
[561] | 1306 | Writes the given \a pixmap to the given \a stream as a PNG
|
---|
[2] | 1307 | image. Note that writing the stream to a file will not produce a
|
---|
| 1308 | valid image file.
|
---|
| 1309 |
|
---|
[846] | 1310 | \sa QPixmap::save(), {Serializing Qt Data Types}
|
---|
[2] | 1311 | */
|
---|
| 1312 |
|
---|
| 1313 | QDataStream &operator<<(QDataStream &stream, const QPixmap &pixmap)
|
---|
| 1314 | {
|
---|
| 1315 | return stream << pixmap.toImage();
|
---|
| 1316 | }
|
---|
| 1317 |
|
---|
| 1318 | /*!
|
---|
| 1319 | \relates QPixmap
|
---|
| 1320 |
|
---|
| 1321 | Reads an image from the given \a stream into the given \a pixmap.
|
---|
| 1322 |
|
---|
[846] | 1323 | \sa QPixmap::load(), {Serializing Qt Data Types}
|
---|
[2] | 1324 | */
|
---|
| 1325 |
|
---|
| 1326 | QDataStream &operator>>(QDataStream &stream, QPixmap &pixmap)
|
---|
| 1327 | {
|
---|
| 1328 | QImage image;
|
---|
| 1329 | stream >> image;
|
---|
| 1330 |
|
---|
| 1331 | if (image.isNull()) {
|
---|
| 1332 | pixmap = QPixmap();
|
---|
| 1333 | } else if (image.depth() == 1) {
|
---|
| 1334 | pixmap = QBitmap::fromImage(image);
|
---|
| 1335 | } else {
|
---|
| 1336 | pixmap = QPixmap::fromImage(image);
|
---|
| 1337 | }
|
---|
| 1338 | return stream;
|
---|
| 1339 | }
|
---|
| 1340 |
|
---|
[561] | 1341 | #endif // QT_NO_DATASTREAM
|
---|
[2] | 1342 |
|
---|
| 1343 | #ifdef QT3_SUPPORT
|
---|
| 1344 | Q_GUI_EXPORT void copyBlt(QPixmap *dst, int dx, int dy,
|
---|
| 1345 | const QPixmap *src, int sx, int sy, int sw, int sh)
|
---|
| 1346 | {
|
---|
| 1347 | Q_ASSERT_X(dst, "::copyBlt", "Destination pixmap must be non-null");
|
---|
| 1348 | Q_ASSERT_X(src, "::copyBlt", "Source pixmap must be non-null");
|
---|
| 1349 |
|
---|
| 1350 | if (src->hasAlphaChannel()) {
|
---|
| 1351 | if (dst->paintEngine()->hasFeature(QPaintEngine::PorterDuff)) {
|
---|
| 1352 | QPainter p(dst);
|
---|
| 1353 | p.setCompositionMode(QPainter::CompositionMode_Source);
|
---|
| 1354 | p.drawPixmap(dx, dy, *src, sx, sy, sw, sh);
|
---|
| 1355 | } else {
|
---|
| 1356 | QImage image = dst->toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
---|
| 1357 | QPainter p(&image);
|
---|
| 1358 | p.setCompositionMode(QPainter::CompositionMode_Source);
|
---|
| 1359 | p.drawPixmap(dx, dy, *src, sx, sy, sw, sh);
|
---|
| 1360 | p.end();
|
---|
| 1361 | *dst = QPixmap::fromImage(image);
|
---|
| 1362 | }
|
---|
| 1363 | } else {
|
---|
| 1364 | QPainter p(dst);
|
---|
| 1365 | p.drawPixmap(dx, dy, *src, sx, sy, sw, sh);
|
---|
| 1366 | }
|
---|
| 1367 |
|
---|
| 1368 | }
|
---|
| 1369 | #endif
|
---|
| 1370 |
|
---|
| 1371 | /*!
|
---|
| 1372 | \internal
|
---|
| 1373 | */
|
---|
| 1374 |
|
---|
| 1375 | bool QPixmap::isDetached() const
|
---|
| 1376 | {
|
---|
[561] | 1377 | return data && data->ref == 1;
|
---|
[2] | 1378 | }
|
---|
| 1379 |
|
---|
[561] | 1380 | /*! \internal
|
---|
| 1381 | ### Qt5 - remove me.
|
---|
| 1382 | */
|
---|
[2] | 1383 | void QPixmap::deref()
|
---|
| 1384 | {
|
---|
[561] | 1385 | Q_ASSERT_X(false, "QPixmap::deref()", "Do not call this function anymore!");
|
---|
[2] | 1386 | }
|
---|
| 1387 |
|
---|
| 1388 | /*!
|
---|
| 1389 | \fn QImage QPixmap::convertToImage() const
|
---|
| 1390 |
|
---|
| 1391 | Use the toImage() function instead.
|
---|
| 1392 | */
|
---|
| 1393 |
|
---|
| 1394 | /*!
|
---|
[846] | 1395 | Replaces this pixmap's data with the given \a image using the
|
---|
| 1396 | specified \a flags to control the conversion. The \a flags
|
---|
| 1397 | argument is a bitwise-OR of the \l{Qt::ImageConversionFlags}.
|
---|
| 1398 | Passing 0 for \a flags sets all the default options. Returns true
|
---|
| 1399 | if the result is that this pixmap is not null.
|
---|
[2] | 1400 |
|
---|
[846] | 1401 | Note: this function was part of Qt 3 support in Qt 4.6 and earlier.
|
---|
| 1402 | It has been promoted to official API status in 4.7 to support updating
|
---|
| 1403 | the pixmap's image without creating a new QPixmap as fromImage() would.
|
---|
| 1404 |
|
---|
| 1405 | \sa fromImage()
|
---|
| 1406 | \since 4.7
|
---|
[2] | 1407 | */
|
---|
[846] | 1408 | bool QPixmap::convertFromImage(const QImage &image, Qt::ImageConversionFlags flags)
|
---|
| 1409 | {
|
---|
| 1410 | if (image.isNull() || !data)
|
---|
| 1411 | *this = QPixmap::fromImage(image, flags);
|
---|
| 1412 | else
|
---|
| 1413 | data->fromImage(image, flags);
|
---|
| 1414 | return !isNull();
|
---|
| 1415 | }
|
---|
[2] | 1416 |
|
---|
| 1417 | /*!
|
---|
| 1418 | \fn QPixmap QPixmap::xForm(const QMatrix &matrix) const
|
---|
| 1419 |
|
---|
| 1420 | Use transformed() instead.
|
---|
| 1421 | */
|
---|
| 1422 |
|
---|
| 1423 | /*!
|
---|
| 1424 | \fn QPixmap QPixmap::scaled(int width, int height,
|
---|
| 1425 | Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode
|
---|
| 1426 | transformMode) const
|
---|
| 1427 |
|
---|
| 1428 | \overload
|
---|
| 1429 |
|
---|
| 1430 | Returns a copy of the pixmap scaled to a rectangle with the given
|
---|
| 1431 | \a width and \a height according to the given \a aspectRatioMode and
|
---|
| 1432 | \a transformMode.
|
---|
| 1433 |
|
---|
| 1434 | If either the \a width or the \a height is zero or negative, this
|
---|
| 1435 | function returns a null pixmap.
|
---|
| 1436 | */
|
---|
| 1437 |
|
---|
| 1438 | /*!
|
---|
| 1439 | \fn QPixmap QPixmap::scaled(const QSize &size, Qt::AspectRatioMode
|
---|
| 1440 | aspectRatioMode, Qt::TransformationMode transformMode) const
|
---|
| 1441 |
|
---|
| 1442 | Scales the pixmap to the given \a size, using the aspect ratio and
|
---|
| 1443 | transformation modes specified by \a aspectRatioMode and \a
|
---|
| 1444 | transformMode.
|
---|
| 1445 |
|
---|
| 1446 | \image qimage-scaling.png
|
---|
| 1447 |
|
---|
| 1448 | \list
|
---|
| 1449 | \i If \a aspectRatioMode is Qt::IgnoreAspectRatio, the pixmap
|
---|
| 1450 | is scaled to \a size.
|
---|
| 1451 | \i If \a aspectRatioMode is Qt::KeepAspectRatio, the pixmap is
|
---|
| 1452 | scaled to a rectangle as large as possible inside \a size, preserving the aspect ratio.
|
---|
| 1453 | \i If \a aspectRatioMode is Qt::KeepAspectRatioByExpanding,
|
---|
| 1454 | the pixmap is scaled to a rectangle as small as possible
|
---|
| 1455 | outside \a size, preserving the aspect ratio.
|
---|
| 1456 | \endlist
|
---|
| 1457 |
|
---|
| 1458 | If the given \a size is empty, this function returns a null
|
---|
| 1459 | pixmap.
|
---|
| 1460 |
|
---|
[561] | 1461 |
|
---|
| 1462 | In some cases it can be more beneficial to draw the pixmap to a
|
---|
| 1463 | painter with a scale set rather than scaling the pixmap. This is
|
---|
| 1464 | the case when the painter is for instance based on OpenGL or when
|
---|
| 1465 | the scale factor changes rapidly.
|
---|
| 1466 |
|
---|
[2] | 1467 | \sa isNull(), {QPixmap#Pixmap Transformations}{Pixmap
|
---|
| 1468 | Transformations}
|
---|
| 1469 |
|
---|
| 1470 | */
|
---|
| 1471 | QPixmap QPixmap::scaled(const QSize& s, Qt::AspectRatioMode aspectMode, Qt::TransformationMode mode) const
|
---|
| 1472 | {
|
---|
| 1473 | if (isNull()) {
|
---|
| 1474 | qWarning("QPixmap::scaled: Pixmap is a null pixmap");
|
---|
| 1475 | return QPixmap();
|
---|
| 1476 | }
|
---|
| 1477 | if (s.isEmpty())
|
---|
| 1478 | return QPixmap();
|
---|
| 1479 |
|
---|
| 1480 | QSize newSize = size();
|
---|
| 1481 | newSize.scale(s, aspectMode);
|
---|
| 1482 | if (newSize == size())
|
---|
| 1483 | return *this;
|
---|
| 1484 |
|
---|
[561] | 1485 | QTransform wm = QTransform::fromScale((qreal)newSize.width() / width(),
|
---|
| 1486 | (qreal)newSize.height() / height());
|
---|
| 1487 | QPixmap pix = transformed(wm, mode);
|
---|
[2] | 1488 | return pix;
|
---|
| 1489 | }
|
---|
| 1490 |
|
---|
| 1491 | /*!
|
---|
| 1492 | \fn QPixmap QPixmap::scaledToWidth(int width, Qt::TransformationMode
|
---|
| 1493 | mode) const
|
---|
| 1494 |
|
---|
| 1495 | Returns a scaled copy of the image. The returned image is scaled
|
---|
| 1496 | to the given \a width using the specified transformation \a mode.
|
---|
| 1497 | The height of the pixmap is automatically calculated so that the
|
---|
| 1498 | aspect ratio of the pixmap is preserved.
|
---|
| 1499 |
|
---|
| 1500 | If \a width is 0 or negative, a null pixmap is returned.
|
---|
| 1501 |
|
---|
| 1502 | \sa isNull(), {QPixmap#Pixmap Transformations}{Pixmap
|
---|
| 1503 | Transformations}
|
---|
| 1504 | */
|
---|
| 1505 | QPixmap QPixmap::scaledToWidth(int w, Qt::TransformationMode mode) const
|
---|
| 1506 | {
|
---|
| 1507 | if (isNull()) {
|
---|
| 1508 | qWarning("QPixmap::scaleWidth: Pixmap is a null pixmap");
|
---|
| 1509 | return copy();
|
---|
| 1510 | }
|
---|
| 1511 | if (w <= 0)
|
---|
| 1512 | return QPixmap();
|
---|
| 1513 |
|
---|
| 1514 | qreal factor = (qreal) w / width();
|
---|
[561] | 1515 | QTransform wm = QTransform::fromScale(factor, factor);
|
---|
[2] | 1516 | return transformed(wm, mode);
|
---|
| 1517 | }
|
---|
| 1518 |
|
---|
| 1519 | /*!
|
---|
| 1520 | \fn QPixmap QPixmap::scaledToHeight(int height,
|
---|
| 1521 | Qt::TransformationMode mode) const
|
---|
| 1522 |
|
---|
| 1523 | Returns a scaled copy of the image. The returned image is scaled
|
---|
| 1524 | to the given \a height using the specified transformation \a mode.
|
---|
| 1525 | The width of the pixmap is automatically calculated so that the
|
---|
| 1526 | aspect ratio of the pixmap is preserved.
|
---|
| 1527 |
|
---|
| 1528 | If \a height is 0 or negative, a null pixmap is returned.
|
---|
| 1529 |
|
---|
| 1530 | \sa isNull(), {QPixmap#Pixmap Transformations}{Pixmap
|
---|
| 1531 | Transformations}
|
---|
| 1532 | */
|
---|
| 1533 | QPixmap QPixmap::scaledToHeight(int h, Qt::TransformationMode mode) const
|
---|
| 1534 | {
|
---|
| 1535 | if (isNull()) {
|
---|
| 1536 | qWarning("QPixmap::scaleHeight: Pixmap is a null pixmap");
|
---|
| 1537 | return copy();
|
---|
| 1538 | }
|
---|
| 1539 | if (h <= 0)
|
---|
| 1540 | return QPixmap();
|
---|
| 1541 |
|
---|
| 1542 | qreal factor = (qreal) h / height();
|
---|
[561] | 1543 | QTransform wm = QTransform::fromScale(factor, factor);
|
---|
[2] | 1544 | return transformed(wm, mode);
|
---|
| 1545 | }
|
---|
| 1546 |
|
---|
| 1547 | /*!
|
---|
| 1548 | Returns a copy of the pixmap that is transformed using the given
|
---|
| 1549 | transformation \a transform and transformation \a mode. The original
|
---|
| 1550 | pixmap is not changed.
|
---|
| 1551 |
|
---|
| 1552 | The transformation \a transform is internally adjusted to compensate
|
---|
| 1553 | for unwanted translation; i.e. the pixmap produced is the smallest
|
---|
| 1554 | pixmap that contains all the transformed points of the original
|
---|
| 1555 | pixmap. Use the trueMatrix() function to retrieve the actual
|
---|
| 1556 | matrix used for transforming the pixmap.
|
---|
| 1557 |
|
---|
| 1558 | This function is slow because it involves transformation to a
|
---|
| 1559 | QImage, non-trivial computations and a transformation back to a
|
---|
| 1560 | QPixmap.
|
---|
| 1561 |
|
---|
| 1562 | \sa trueMatrix(), {QPixmap#Pixmap Transformations}{Pixmap
|
---|
| 1563 | Transformations}
|
---|
| 1564 | */
|
---|
| 1565 | QPixmap QPixmap::transformed(const QTransform &transform,
|
---|
| 1566 | Qt::TransformationMode mode) const
|
---|
| 1567 | {
|
---|
| 1568 | if (isNull() || transform.type() <= QTransform::TxTranslate)
|
---|
| 1569 | return *this;
|
---|
| 1570 |
|
---|
| 1571 | return data->transformed(transform, mode);
|
---|
| 1572 | }
|
---|
| 1573 |
|
---|
| 1574 | /*!
|
---|
| 1575 | \overload
|
---|
| 1576 |
|
---|
| 1577 | This convenience function loads the \a matrix into a
|
---|
| 1578 | QTransform and calls the overloaded function.
|
---|
| 1579 | */
|
---|
| 1580 | QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) const
|
---|
| 1581 | {
|
---|
| 1582 | return transformed(QTransform(matrix), mode);
|
---|
| 1583 | }
|
---|
| 1584 |
|
---|
| 1585 |
|
---|
| 1586 |
|
---|
| 1587 |
|
---|
| 1588 |
|
---|
| 1589 |
|
---|
| 1590 |
|
---|
| 1591 |
|
---|
| 1592 | /*!
|
---|
| 1593 | \class QPixmap
|
---|
| 1594 |
|
---|
| 1595 | \brief The QPixmap class is an off-screen image representation
|
---|
| 1596 | that can be used as a paint device.
|
---|
| 1597 |
|
---|
[561] | 1598 | \ingroup painting
|
---|
[2] | 1599 | \ingroup shared
|
---|
| 1600 |
|
---|
[561] | 1601 |
|
---|
[2] | 1602 | Qt provides four classes for handling image data: QImage, QPixmap,
|
---|
| 1603 | QBitmap and QPicture. QImage is designed and optimized for I/O,
|
---|
| 1604 | and for direct pixel access and manipulation, while QPixmap is
|
---|
| 1605 | designed and optimized for showing images on screen. QBitmap is
|
---|
| 1606 | only a convenience class that inherits QPixmap, ensuring a depth
|
---|
| 1607 | of 1. The isQBitmap() function returns true if a QPixmap object is
|
---|
[561] | 1608 | really a bitmap, otherwise returns false. Finally, the QPicture class
|
---|
| 1609 | is a paint device that records and replays QPainter commands.
|
---|
[2] | 1610 |
|
---|
| 1611 | A QPixmap can easily be displayed on the screen using QLabel or
|
---|
| 1612 | one of QAbstractButton's subclasses (such as QPushButton and
|
---|
| 1613 | QToolButton). QLabel has a pixmap property, whereas
|
---|
[561] | 1614 | QAbstractButton has an icon property.
|
---|
[2] | 1615 |
|
---|
| 1616 | In addition to the ordinary constructors, a QPixmap can be
|
---|
| 1617 | constructed using the static grabWidget() and grabWindow()
|
---|
| 1618 | functions which creates a QPixmap and paints the given widget, or
|
---|
[561] | 1619 | window, into it.
|
---|
[2] | 1620 |
|
---|
[561] | 1621 | QPixmap objects can be passed around by value since the QPixmap
|
---|
| 1622 | class uses implicit data sharing. For more information, see the \l
|
---|
| 1623 | {Implicit Data Sharing} documentation. QPixmap objects can also be
|
---|
| 1624 | streamed.
|
---|
| 1625 |
|
---|
[2] | 1626 | Depending on the system, QPixmap is stored using a RGB32 or a
|
---|
| 1627 | premultiplied alpha format. If the image has an alpha channel, and
|
---|
| 1628 | if the system allows, the preferred format is premultiplied alpha.
|
---|
| 1629 | Note also that QPixmap, unlike QImage, may be hardware dependent.
|
---|
[561] | 1630 | On X11, Mac and Symbian, a QPixmap is stored on the server side while
|
---|
| 1631 | a QImage is stored on the client side (on Windows, these two classes
|
---|
[2] | 1632 | have an equivalent internal representation, i.e. both QImage and
|
---|
| 1633 | QPixmap are stored on the client side and don't use any GDI
|
---|
| 1634 | resources).
|
---|
| 1635 |
|
---|
[561] | 1636 | Note that the pixel data in a pixmap is internal and is managed by
|
---|
| 1637 | the underlying window system. Because QPixmap is a QPaintDevice
|
---|
| 1638 | subclass, QPainter can be used to draw directly onto pixmaps.
|
---|
| 1639 | Pixels can only be accessed through QPainter functions or by
|
---|
| 1640 | converting the QPixmap to a QImage. However, the fill() function
|
---|
| 1641 | is available for initializing the entire pixmap with a given color.
|
---|
| 1642 |
|
---|
[2] | 1643 | There are functions to convert between QImage and
|
---|
| 1644 | QPixmap. Typically, the QImage class is used to load an image
|
---|
| 1645 | file, optionally manipulating the image data, before the QImage
|
---|
| 1646 | object is converted into a QPixmap to be shown on
|
---|
| 1647 | screen. Alternatively, if no manipulation is desired, the image
|
---|
| 1648 | file can be loaded directly into a QPixmap. On Windows, the
|
---|
| 1649 | QPixmap class also supports conversion between \c HBITMAP and
|
---|
[561] | 1650 | QPixmap. On Symbian, the QPixmap class also supports conversion
|
---|
| 1651 | between CFbsBitmap and QPixmap.
|
---|
[2] | 1652 |
|
---|
| 1653 | QPixmap provides a collection of functions that can be used to
|
---|
| 1654 | obtain a variety of information about the pixmap. In addition,
|
---|
| 1655 | there are several functions that enables transformation of the
|
---|
| 1656 | pixmap.
|
---|
| 1657 |
|
---|
| 1658 | \tableofcontents
|
---|
| 1659 |
|
---|
| 1660 | \section1 Reading and Writing Image Files
|
---|
| 1661 |
|
---|
| 1662 | QPixmap provides several ways of reading an image file: The file
|
---|
| 1663 | can be loaded when constructing the QPixmap object, or by using
|
---|
| 1664 | the load() or loadFromData() functions later on. When loading an
|
---|
| 1665 | image, the file name can either refer to an actual file on disk or
|
---|
| 1666 | to one of the application's embedded resources. See \l{The Qt
|
---|
| 1667 | Resource System} overview for details on how to embed images and
|
---|
| 1668 | other resource files in the application's executable.
|
---|
| 1669 |
|
---|
| 1670 | Simply call the save() function to save a QPixmap object.
|
---|
| 1671 |
|
---|
| 1672 | The complete list of supported file formats are available through
|
---|
| 1673 | the QImageReader::supportedImageFormats() and
|
---|
| 1674 | QImageWriter::supportedImageFormats() functions. New file formats
|
---|
| 1675 | can be added as plugins. By default, Qt supports the following
|
---|
| 1676 | formats:
|
---|
| 1677 |
|
---|
| 1678 | \table
|
---|
| 1679 | \header \o Format \o Description \o Qt's support
|
---|
| 1680 | \row \o BMP \o Windows Bitmap \o Read/write
|
---|
| 1681 | \row \o GIF \o Graphic Interchange Format (optional) \o Read
|
---|
| 1682 | \row \o JPG \o Joint Photographic Experts Group \o Read/write
|
---|
| 1683 | \row \o JPEG \o Joint Photographic Experts Group \o Read/write
|
---|
| 1684 | \row \o PNG \o Portable Network Graphics \o Read/write
|
---|
| 1685 | \row \o PBM \o Portable Bitmap \o Read
|
---|
| 1686 | \row \o PGM \o Portable Graymap \o Read
|
---|
| 1687 | \row \o PPM \o Portable Pixmap \o Read/write
|
---|
| 1688 | \row \o XBM \o X11 Bitmap \o Read/write
|
---|
| 1689 | \row \o XPM \o X11 Pixmap \o Read/write
|
---|
| 1690 | \endtable
|
---|
| 1691 |
|
---|
| 1692 | \section1 Pixmap Information
|
---|
| 1693 |
|
---|
| 1694 | QPixmap provides a collection of functions that can be used to
|
---|
| 1695 | obtain a variety of information about the pixmap:
|
---|
| 1696 |
|
---|
| 1697 | \table
|
---|
| 1698 | \header
|
---|
| 1699 | \o \o Available Functions
|
---|
| 1700 | \row
|
---|
| 1701 | \o Geometry
|
---|
| 1702 | \o
|
---|
| 1703 | The size(), width() and height() functions provide information
|
---|
| 1704 | about the pixmap's size. The rect() function returns the image's
|
---|
| 1705 | enclosing rectangle.
|
---|
| 1706 |
|
---|
| 1707 | \row
|
---|
| 1708 | \o Alpha component
|
---|
| 1709 | \o
|
---|
| 1710 |
|
---|
| 1711 | The hasAlphaChannel() returns true if the pixmap has a format that
|
---|
[769] | 1712 | respects the alpha channel, otherwise returns false. The hasAlpha(),
|
---|
| 1713 | setMask() and mask() functions are legacy and should not be used.
|
---|
| 1714 | They are potentially very slow.
|
---|
[2] | 1715 |
|
---|
[561] | 1716 | The createHeuristicMask() function creates and returns a 1-bpp
|
---|
| 1717 | heuristic mask (i.e. a QBitmap) for this pixmap. It works by
|
---|
| 1718 | selecting a color from one of the corners and then chipping away
|
---|
| 1719 | pixels of that color, starting at all the edges. The
|
---|
| 1720 | createMaskFromColor() function creates and returns a mask (i.e. a
|
---|
| 1721 | QBitmap) for the pixmap based on a given color.
|
---|
[2] | 1722 |
|
---|
| 1723 | \row
|
---|
| 1724 | \o Low-level information
|
---|
| 1725 | \o
|
---|
| 1726 |
|
---|
| 1727 | The depth() function returns the depth of the pixmap. The
|
---|
| 1728 | defaultDepth() function returns the default depth, i.e. the depth
|
---|
| 1729 | used by the application on the given screen.
|
---|
| 1730 |
|
---|
| 1731 | The cacheKey() function returns a number that uniquely
|
---|
| 1732 | identifies the contents of the QPixmap object.
|
---|
| 1733 |
|
---|
| 1734 | The x11Info() function returns information about the configuration
|
---|
[561] | 1735 | of the X display used by the screen to which the pixmap currently
|
---|
| 1736 | belongs. The x11PictureHandle() function returns the X11 Picture
|
---|
| 1737 | handle of the pixmap for XRender support. Note that the two latter
|
---|
| 1738 | functions are only available on x11.
|
---|
[2] | 1739 |
|
---|
| 1740 | \endtable
|
---|
| 1741 |
|
---|
| 1742 | \section1 Pixmap Conversion
|
---|
| 1743 |
|
---|
| 1744 | A QPixmap object can be converted into a QImage using the
|
---|
| 1745 | toImage() function. Likewise, a QImage can be converted into a
|
---|
| 1746 | QPixmap using the fromImage(). If this is too expensive an
|
---|
| 1747 | operation, you can use QBitmap::fromImage() instead.
|
---|
| 1748 |
|
---|
| 1749 | In addition, on Windows, the QPixmap class supports conversion to
|
---|
[561] | 1750 | and from HBITMAP: the toWinHBITMAP() function creates a HBITMAP
|
---|
[2] | 1751 | equivalent to the QPixmap, based on the given HBitmapFormat, and
|
---|
| 1752 | returns the HBITMAP handle. The fromWinHBITMAP() function returns
|
---|
| 1753 | a QPixmap that is equivalent to the given bitmap which has the
|
---|
[561] | 1754 | specified format. The QPixmap class also supports conversion to
|
---|
| 1755 | and from HICON: the toWinHICON() function creates a HICON equivalent
|
---|
| 1756 | to the QPixmap, and returns the HICON handle. The fromWinHICON()
|
---|
| 1757 | function returns a QPixmap that is equivalent to the given icon.
|
---|
[2] | 1758 |
|
---|
[561] | 1759 | In addition, on Symbian, the QPixmap class supports conversion to
|
---|
| 1760 | and from CFbsBitmap: the toSymbianCFbsBitmap() function creates
|
---|
| 1761 | CFbsBitmap equivalent to the QPixmap, based on given mode and returns
|
---|
| 1762 | a CFbsBitmap object. The fromSymbianCFbsBitmap() function returns a
|
---|
| 1763 | QPixmap that is equivalent to the given bitmap and given mode.
|
---|
| 1764 |
|
---|
[2] | 1765 | \section1 Pixmap Transformations
|
---|
| 1766 |
|
---|
| 1767 | QPixmap supports a number of functions for creating a new pixmap
|
---|
[561] | 1768 | that is a transformed version of the original:
|
---|
[2] | 1769 |
|
---|
| 1770 | The scaled(), scaledToWidth() and scaledToHeight() functions
|
---|
| 1771 | return scaled copies of the pixmap, while the copy() function
|
---|
| 1772 | creates a QPixmap that is a plain copy of the original one.
|
---|
| 1773 |
|
---|
| 1774 | The transformed() function returns a copy of the pixmap that is
|
---|
| 1775 | transformed with the given transformation matrix and
|
---|
| 1776 | transformation mode: Internally, the transformation matrix is
|
---|
| 1777 | adjusted to compensate for unwanted translation,
|
---|
| 1778 | i.e. transformed() returns the smallest pixmap containing all
|
---|
| 1779 | transformed points of the original pixmap. The static trueMatrix()
|
---|
| 1780 | function returns the actual matrix used for transforming the
|
---|
| 1781 | pixmap.
|
---|
| 1782 |
|
---|
[846] | 1783 | \note When using the native X11 graphics system, the pixmap
|
---|
| 1784 | becomes invalid when the QApplication instance is destroyed.
|
---|
| 1785 |
|
---|
[2] | 1786 | \sa QBitmap, QImage, QImageReader, QImageWriter
|
---|
| 1787 | */
|
---|
| 1788 |
|
---|
| 1789 |
|
---|
| 1790 | /*!
|
---|
| 1791 | \typedef QPixmap::DataPtr
|
---|
| 1792 | \internal
|
---|
| 1793 | */
|
---|
| 1794 |
|
---|
| 1795 | /*!
|
---|
| 1796 | \fn DataPtr &QPixmap::data_ptr()
|
---|
| 1797 | \internal
|
---|
| 1798 | */
|
---|
| 1799 |
|
---|
| 1800 | /*!
|
---|
| 1801 | Returns true if this pixmap has an alpha channel, \e or has a
|
---|
| 1802 | mask, otherwise returns false.
|
---|
| 1803 |
|
---|
[561] | 1804 | \sa hasAlphaChannel(), mask()
|
---|
[2] | 1805 | */
|
---|
| 1806 | bool QPixmap::hasAlpha() const
|
---|
| 1807 | {
|
---|
[846] | 1808 | #if defined(Q_WS_X11)
|
---|
| 1809 | if (data && data->hasAlphaChannel())
|
---|
| 1810 | return true;
|
---|
| 1811 | QPixmapData *pd = pixmapData();
|
---|
| 1812 | if (pd && pd->classId() == QPixmapData::X11Class) {
|
---|
| 1813 | QX11PixmapData *x11Data = static_cast<QX11PixmapData*>(pd);
|
---|
| 1814 | #ifndef QT_NO_XRENDER
|
---|
| 1815 | if (x11Data->picture && x11Data->d == 32)
|
---|
| 1816 | return true;
|
---|
| 1817 | #endif
|
---|
| 1818 | if (x11Data->d == 1 || x11Data->x11_mask)
|
---|
| 1819 | return true;
|
---|
| 1820 | }
|
---|
| 1821 | return false;
|
---|
| 1822 | #else
|
---|
| 1823 | return data && data->hasAlphaChannel();
|
---|
| 1824 | #endif
|
---|
[2] | 1825 | }
|
---|
| 1826 |
|
---|
| 1827 | /*!
|
---|
| 1828 | Returns true if the pixmap has a format that respects the alpha
|
---|
| 1829 | channel, otherwise returns false.
|
---|
| 1830 |
|
---|
[561] | 1831 | \sa hasAlpha()
|
---|
[2] | 1832 | */
|
---|
| 1833 | bool QPixmap::hasAlphaChannel() const
|
---|
| 1834 | {
|
---|
[561] | 1835 | return data && data->hasAlphaChannel();
|
---|
[2] | 1836 | }
|
---|
| 1837 |
|
---|
| 1838 | /*!
|
---|
[561] | 1839 | \internal
|
---|
[2] | 1840 | */
|
---|
| 1841 | int QPixmap::metric(PaintDeviceMetric metric) const
|
---|
| 1842 | {
|
---|
[561] | 1843 | return data ? data->metric(metric) : 0;
|
---|
[2] | 1844 | }
|
---|
| 1845 |
|
---|
| 1846 | /*!
|
---|
| 1847 | \fn void QPixmap::setAlphaChannel(const QPixmap &alphaChannel)
|
---|
[561] | 1848 | \obsolete
|
---|
[2] | 1849 |
|
---|
| 1850 | Sets the alpha channel of this pixmap to the given \a alphaChannel
|
---|
| 1851 | by converting the \a alphaChannel into 32 bit and using the
|
---|
| 1852 | intensity of the RGB pixel values.
|
---|
| 1853 |
|
---|
| 1854 | The effect of this function is undefined when the pixmap is being
|
---|
| 1855 | painted on.
|
---|
| 1856 |
|
---|
[561] | 1857 | \warning This is potentially an expensive operation. Most usecases
|
---|
| 1858 | for this function are covered by QPainter and compositionModes
|
---|
| 1859 | which will normally execute faster.
|
---|
| 1860 |
|
---|
[2] | 1861 | \sa alphaChannel(), {QPixmap#Pixmap Transformations}{Pixmap
|
---|
| 1862 | Transformations}
|
---|
| 1863 | */
|
---|
| 1864 | void QPixmap::setAlphaChannel(const QPixmap &alphaChannel)
|
---|
| 1865 | {
|
---|
| 1866 | if (alphaChannel.isNull())
|
---|
| 1867 | return;
|
---|
| 1868 |
|
---|
| 1869 | if (paintingActive()) {
|
---|
| 1870 | qWarning("QPixmap::setAlphaChannel: "
|
---|
| 1871 | "Cannot set alpha channel while pixmap is being painted on");
|
---|
| 1872 | return;
|
---|
| 1873 | }
|
---|
| 1874 |
|
---|
| 1875 | if (width() != alphaChannel.width() && height() != alphaChannel.height()) {
|
---|
| 1876 | qWarning("QPixmap::setAlphaChannel: "
|
---|
| 1877 | "The pixmap and the alpha channel pixmap must have the same size");
|
---|
| 1878 | return;
|
---|
| 1879 | }
|
---|
| 1880 |
|
---|
| 1881 | detach();
|
---|
| 1882 | data->setAlphaChannel(alphaChannel);
|
---|
| 1883 | }
|
---|
| 1884 |
|
---|
| 1885 | /*!
|
---|
[561] | 1886 | \obsolete
|
---|
| 1887 |
|
---|
[2] | 1888 | Returns the alpha channel of the pixmap as a new grayscale QPixmap in which
|
---|
| 1889 | each pixel's red, green, and blue values are given the alpha value of the
|
---|
| 1890 | original pixmap. The color depth of the returned pixmap is the system depth
|
---|
| 1891 | on X11 and 8-bit on Windows and Mac OS X.
|
---|
| 1892 |
|
---|
| 1893 | You can use this function while debugging
|
---|
| 1894 | to get a visible image of the alpha channel. If the pixmap doesn't have an
|
---|
| 1895 | alpha channel, i.e., the alpha channel's value for all pixels equals
|
---|
| 1896 | 0xff), a null pixmap is returned. You can check this with the \c isNull()
|
---|
| 1897 | function.
|
---|
| 1898 |
|
---|
| 1899 | We show an example:
|
---|
| 1900 |
|
---|
| 1901 | \snippet doc/src/snippets/alphachannel.cpp 0
|
---|
| 1902 |
|
---|
| 1903 | \image alphachannelimage.png The pixmap and channelImage QPixmaps
|
---|
| 1904 |
|
---|
[561] | 1905 | \warning This is an expensive operation. The alpha channel of the
|
---|
| 1906 | pixmap is extracted dynamically from the pixeldata. Most usecases of this
|
---|
| 1907 | function are covered by QPainter and compositionModes which will normally
|
---|
| 1908 | execute faster.
|
---|
| 1909 |
|
---|
[2] | 1910 | \sa setAlphaChannel(), {QPixmap#Pixmap Information}{Pixmap
|
---|
| 1911 | Information}
|
---|
| 1912 | */
|
---|
| 1913 | QPixmap QPixmap::alphaChannel() const
|
---|
| 1914 | {
|
---|
[561] | 1915 | return data ? data->alphaChannel() : QPixmap();
|
---|
[2] | 1916 | }
|
---|
| 1917 |
|
---|
| 1918 | /*!
|
---|
[561] | 1919 | \internal
|
---|
[2] | 1920 | */
|
---|
| 1921 | QPaintEngine *QPixmap::paintEngine() const
|
---|
| 1922 | {
|
---|
[561] | 1923 | return data ? data->paintEngine() : 0;
|
---|
[2] | 1924 | }
|
---|
| 1925 |
|
---|
| 1926 | /*!
|
---|
| 1927 | \fn QBitmap QPixmap::mask() const
|
---|
| 1928 |
|
---|
[561] | 1929 | Extracts a bitmap mask from the pixmap's alpha channel.
|
---|
[2] | 1930 |
|
---|
[561] | 1931 | \warning This is potentially an expensive operation. The mask of
|
---|
| 1932 | the pixmap is extracted dynamically from the pixeldata.
|
---|
[2] | 1933 |
|
---|
| 1934 | \sa setMask(), {QPixmap#Pixmap Information}{Pixmap Information}
|
---|
| 1935 | */
|
---|
| 1936 | QBitmap QPixmap::mask() const
|
---|
| 1937 | {
|
---|
[561] | 1938 | return data ? data->mask() : QBitmap();
|
---|
[2] | 1939 | }
|
---|
| 1940 |
|
---|
| 1941 | /*!
|
---|
| 1942 | Returns the default pixmap depth used by the application.
|
---|
| 1943 |
|
---|
| 1944 | On Windows and Mac, the default depth is always 32. On X11 and
|
---|
| 1945 | embedded, the depth of the screen will be returned by this
|
---|
| 1946 | function.
|
---|
| 1947 |
|
---|
| 1948 | \sa depth(), QColormap::depth(), {QPixmap#Pixmap Information}{Pixmap Information}
|
---|
| 1949 |
|
---|
| 1950 | */
|
---|
| 1951 | int QPixmap::defaultDepth()
|
---|
| 1952 | {
|
---|
| 1953 | #if defined(Q_WS_QWS)
|
---|
| 1954 | return QScreen::instance()->depth();
|
---|
| 1955 | #elif defined(Q_WS_X11)
|
---|
| 1956 | return QX11Info::appDepth();
|
---|
[561] | 1957 | #elif defined(Q_WS_WINCE)
|
---|
[2] | 1958 | return QColormap::instance().depth();
|
---|
| 1959 | #elif defined(Q_WS_WIN)
|
---|
| 1960 | return 32; // XXX
|
---|
[95] | 1961 | #elif defined(Q_WS_PM)
|
---|
| 1962 | return 32; // @todo check this
|
---|
[2] | 1963 | #elif defined(Q_WS_MAC)
|
---|
| 1964 | return 32;
|
---|
[561] | 1965 | #elif defined(Q_OS_SYMBIAN)
|
---|
| 1966 | return S60->screenDepth;
|
---|
[2] | 1967 | #endif
|
---|
| 1968 | }
|
---|
| 1969 |
|
---|
| 1970 | /*!
|
---|
| 1971 | Detaches the pixmap from shared pixmap data.
|
---|
| 1972 |
|
---|
| 1973 | A pixmap is automatically detached by Qt whenever its contents are
|
---|
| 1974 | about to change. This is done in almost all QPixmap member
|
---|
| 1975 | functions that modify the pixmap (fill(), fromImage(),
|
---|
| 1976 | load(), etc.), and in QPainter::begin() on a pixmap.
|
---|
| 1977 |
|
---|
| 1978 | There are two exceptions in which detach() must be called
|
---|
| 1979 | explicitly, that is when calling the handle() or the
|
---|
| 1980 | x11PictureHandle() function (only available on X11). Otherwise,
|
---|
| 1981 | any modifications done using system calls, will be performed on
|
---|
| 1982 | the shared data.
|
---|
| 1983 |
|
---|
| 1984 | The detach() function returns immediately if there is just a
|
---|
| 1985 | single reference or if the pixmap has not been initialized yet.
|
---|
| 1986 | */
|
---|
| 1987 | void QPixmap::detach()
|
---|
| 1988 | {
|
---|
[561] | 1989 | if (!data)
|
---|
| 1990 | return;
|
---|
| 1991 |
|
---|
[846] | 1992 | // QPixmap.data member may be QRuntimePixmapData so use pixmapData() function to get
|
---|
| 1993 | // the actual underlaying runtime pixmap data.
|
---|
| 1994 | QPixmapData *pd = pixmapData();
|
---|
| 1995 | QPixmapData::ClassId id = pd->classId();
|
---|
[2] | 1996 | if (id == QPixmapData::RasterClass) {
|
---|
[846] | 1997 | QRasterPixmapData *rasterData = static_cast<QRasterPixmapData*>(pd);
|
---|
[2] | 1998 | rasterData->image.detach();
|
---|
| 1999 | }
|
---|
| 2000 |
|
---|
[561] | 2001 | if (data->is_cached && data->ref == 1)
|
---|
[846] | 2002 | QImagePixmapCleanupHooks::executePixmapDataModificationHooks(pd);
|
---|
[2] | 2003 |
|
---|
| 2004 | #if defined(Q_WS_MAC)
|
---|
[846] | 2005 | QMacPixmapData *macData = id == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(pd) : 0;
|
---|
[2] | 2006 | if (macData) {
|
---|
| 2007 | if (macData->cg_mask) {
|
---|
| 2008 | CGImageRelease(macData->cg_mask);
|
---|
| 2009 | macData->cg_mask = 0;
|
---|
| 2010 | }
|
---|
| 2011 | }
|
---|
| 2012 | #endif
|
---|
| 2013 |
|
---|
| 2014 | if (data->ref != 1) {
|
---|
| 2015 | *this = copy();
|
---|
| 2016 | }
|
---|
| 2017 | ++data->detach_no;
|
---|
| 2018 |
|
---|
| 2019 | #if defined(Q_WS_X11)
|
---|
[846] | 2020 | if (pd->classId() == QPixmapData::X11Class) {
|
---|
| 2021 | QX11PixmapData *d = static_cast<QX11PixmapData*>(pd);
|
---|
[561] | 2022 | d->flags &= ~QX11PixmapData::Uninitialized;
|
---|
[2] | 2023 |
|
---|
| 2024 | // reset the cache data
|
---|
| 2025 | if (d->hd2) {
|
---|
| 2026 | XFreePixmap(X11->display, d->hd2);
|
---|
| 2027 | d->hd2 = 0;
|
---|
| 2028 | }
|
---|
| 2029 | }
|
---|
| 2030 | #elif defined(Q_WS_MAC)
|
---|
| 2031 | if (macData) {
|
---|
| 2032 | macData->macReleaseCGImageRef();
|
---|
| 2033 | macData->uninit = false;
|
---|
| 2034 | }
|
---|
| 2035 | #endif
|
---|
| 2036 | }
|
---|
| 2037 |
|
---|
| 2038 | /*!
|
---|
| 2039 | \fn QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags)
|
---|
| 2040 |
|
---|
| 2041 | Converts the given \a image to a pixmap using the specified \a
|
---|
| 2042 | flags to control the conversion. The \a flags argument is a
|
---|
| 2043 | bitwise-OR of the \l{Qt::ImageConversionFlags}. Passing 0 for \a
|
---|
| 2044 | flags sets all the default options.
|
---|
| 2045 |
|
---|
| 2046 | In case of monochrome and 8-bit images, the image is first
|
---|
| 2047 | converted to a 32-bit pixmap and then filled with the colors in
|
---|
| 2048 | the color table. If this is too expensive an operation, you can
|
---|
| 2049 | use QBitmap::fromImage() instead.
|
---|
| 2050 |
|
---|
[846] | 2051 | \sa fromImageReader(), toImage(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
|
---|
[2] | 2052 | */
|
---|
| 2053 | QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags)
|
---|
| 2054 | {
|
---|
| 2055 | if (image.isNull())
|
---|
| 2056 | return QPixmap();
|
---|
| 2057 |
|
---|
| 2058 | QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem();
|
---|
[561] | 2059 | QScopedPointer<QPixmapData> data(gs ? gs->createPixmapData(QPixmapData::PixmapType)
|
---|
| 2060 | : QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixmapType));
|
---|
[2] | 2061 | data->fromImage(image, flags);
|
---|
[561] | 2062 | return QPixmap(data.take());
|
---|
[2] | 2063 | }
|
---|
| 2064 |
|
---|
| 2065 | /*!
|
---|
[846] | 2066 | \fn QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags)
|
---|
| 2067 |
|
---|
| 2068 | Create a QPixmap from an image read directly from an \a imageReader.
|
---|
| 2069 | The \a flags argument is a bitwise-OR of the \l{Qt::ImageConversionFlags}.
|
---|
| 2070 | Passing 0 for \a flags sets all the default options.
|
---|
| 2071 |
|
---|
| 2072 | On some systems, reading an image directly to QPixmap can use less memory than
|
---|
| 2073 | reading a QImage to convert it to QPixmap.
|
---|
| 2074 |
|
---|
| 2075 | \sa fromImage(), toImage(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
|
---|
| 2076 | */
|
---|
| 2077 | QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags)
|
---|
| 2078 | {
|
---|
| 2079 | QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem();
|
---|
| 2080 | QScopedPointer<QPixmapData> data(gs ? gs->createPixmapData(QPixmapData::PixmapType)
|
---|
| 2081 | : QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixmapType));
|
---|
| 2082 | data->fromImageReader(imageReader, flags);
|
---|
| 2083 | return QPixmap(data.take());
|
---|
| 2084 | }
|
---|
| 2085 |
|
---|
| 2086 | /*!
|
---|
[2] | 2087 | \fn QPixmap QPixmap::grabWindow(WId window, int x, int y, int
|
---|
| 2088 | width, int height)
|
---|
| 2089 |
|
---|
| 2090 | Creates and returns a pixmap constructed by grabbing the contents
|
---|
| 2091 | of the given \a window restricted by QRect(\a x, \a y, \a width,
|
---|
| 2092 | \a height).
|
---|
| 2093 |
|
---|
| 2094 | The arguments (\a{x}, \a{y}) specify the offset in the window,
|
---|
| 2095 | whereas (\a{width}, \a{height}) specify the area to be copied. If
|
---|
| 2096 | \a width is negative, the function copies everything to the right
|
---|
| 2097 | border of the window. If \a height is negative, the function
|
---|
| 2098 | copies everything to the bottom of the window.
|
---|
| 2099 |
|
---|
| 2100 | The window system identifier (\c WId) can be retrieved using the
|
---|
| 2101 | QWidget::winId() function. The rationale for using a window
|
---|
| 2102 | identifier and not a QWidget, is to enable grabbing of windows
|
---|
| 2103 | that are not part of the application, window system frames, and so
|
---|
| 2104 | on.
|
---|
| 2105 |
|
---|
| 2106 | The grabWindow() function grabs pixels from the screen, not from
|
---|
| 2107 | the window, i.e. if there is another window partially or entirely
|
---|
| 2108 | over the one you grab, you get pixels from the overlying window,
|
---|
| 2109 | too. The mouse cursor is generally not grabbed.
|
---|
| 2110 |
|
---|
[769] | 2111 | Note on X11 that if the given \a window doesn't have the same depth
|
---|
[2] | 2112 | as the root window, and another window partially or entirely
|
---|
| 2113 | obscures the one you grab, you will \e not get pixels from the
|
---|
| 2114 | overlying window. The contents of the obscured areas in the
|
---|
| 2115 | pixmap will be undefined and uninitialized.
|
---|
| 2116 |
|
---|
[769] | 2117 | On Windows Vista and above grabbing a layered window, which is
|
---|
| 2118 | created by setting the Qt::WA_TranslucentBackground attribute, will
|
---|
| 2119 | not work. Instead grabbing the desktop widget should work.
|
---|
| 2120 |
|
---|
[2] | 2121 | \warning In general, grabbing an area outside the screen is not
|
---|
| 2122 | safe. This depends on the underlying window system.
|
---|
| 2123 |
|
---|
| 2124 | \sa grabWidget(), {Screenshot Example}
|
---|
| 2125 | */
|
---|
| 2126 |
|
---|
| 2127 | /*!
|
---|
| 2128 | \internal
|
---|
| 2129 | */
|
---|
| 2130 | QPixmapData* QPixmap::pixmapData() const
|
---|
| 2131 | {
|
---|
[846] | 2132 | if (data) {
|
---|
| 2133 | QPixmapData* pm = data.data();
|
---|
| 2134 | return pm->runtimeData() ? pm->runtimeData() : pm;
|
---|
| 2135 | }
|
---|
| 2136 |
|
---|
| 2137 | return 0;
|
---|
[2] | 2138 | }
|
---|
| 2139 |
|
---|
[846] | 2140 |
|
---|
[561] | 2141 | /*!
|
---|
| 2142 | \enum QPixmap::HBitmapFormat
|
---|
| 2143 |
|
---|
| 2144 | \bold{Win32 only:} This enum defines how the conversion between \c
|
---|
| 2145 | HBITMAP and QPixmap is performed.
|
---|
| 2146 |
|
---|
| 2147 | \warning This enum is only available on Windows.
|
---|
| 2148 |
|
---|
| 2149 | \value NoAlpha The alpha channel is ignored and always treated as
|
---|
| 2150 | being set to fully opaque. This is preferred if the \c HBITMAP is
|
---|
| 2151 | used with standard GDI calls, such as \c BitBlt().
|
---|
| 2152 |
|
---|
| 2153 | \value PremultipliedAlpha The \c HBITMAP is treated as having an
|
---|
| 2154 | alpha channel and premultiplied colors. This is preferred if the
|
---|
| 2155 | \c HBITMAP is accessed through the \c AlphaBlend() GDI function.
|
---|
| 2156 |
|
---|
| 2157 | \value Alpha The \c HBITMAP is treated as having a plain alpha
|
---|
| 2158 | channel. This is the preferred format if the \c HBITMAP is going
|
---|
| 2159 | to be used as an application icon or systray icon.
|
---|
| 2160 |
|
---|
| 2161 | \sa fromWinHBITMAP(), toWinHBITMAP()
|
---|
| 2162 | */
|
---|
| 2163 |
|
---|
| 2164 | /*! \fn HBITMAP QPixmap::toWinHBITMAP(HBitmapFormat format) const
|
---|
| 2165 | \bold{Win32 only:} Creates a \c HBITMAP equivalent to the QPixmap,
|
---|
| 2166 | based on the given \a format. Returns the \c HBITMAP handle.
|
---|
| 2167 |
|
---|
| 2168 | It is the caller's responsibility to free the \c HBITMAP data
|
---|
| 2169 | after use.
|
---|
| 2170 |
|
---|
| 2171 | \warning This function is only available on Windows.
|
---|
| 2172 |
|
---|
| 2173 | \sa fromWinHBITMAP(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
|
---|
| 2174 | */
|
---|
| 2175 |
|
---|
| 2176 | /*! \fn QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format)
|
---|
| 2177 | \bold{Win32 only:} Returns a QPixmap that is equivalent to the
|
---|
| 2178 | given \a bitmap. The conversion is based on the specified \a
|
---|
| 2179 | format.
|
---|
| 2180 |
|
---|
| 2181 | \warning This function is only available on Windows.
|
---|
| 2182 |
|
---|
| 2183 | \sa toWinHBITMAP(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
|
---|
| 2184 |
|
---|
| 2185 | */
|
---|
| 2186 |
|
---|
| 2187 | /*! \fn HICON QPixmap::toWinHICON() const
|
---|
| 2188 | \since 4.6
|
---|
| 2189 |
|
---|
| 2190 | \bold{Win32 only:} Creates a \c HICON equivalent to the QPixmap.
|
---|
| 2191 | Returns the \c HICON handle.
|
---|
| 2192 |
|
---|
| 2193 | It is the caller's responsibility to free the \c HICON data after use.
|
---|
| 2194 |
|
---|
| 2195 | \warning This function is only available on Windows.
|
---|
| 2196 |
|
---|
| 2197 | \sa fromWinHICON(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
|
---|
| 2198 | */
|
---|
| 2199 |
|
---|
| 2200 | /*! \fn QPixmap QPixmap::fromWinHICON(HICON icon)
|
---|
| 2201 | \since 4.6
|
---|
| 2202 |
|
---|
| 2203 | \bold{Win32 only:} Returns a QPixmap that is equivalent to the given
|
---|
| 2204 | \a icon.
|
---|
| 2205 |
|
---|
| 2206 | \warning This function is only available on Windows.
|
---|
| 2207 |
|
---|
| 2208 | \sa toWinHICON(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
|
---|
| 2209 |
|
---|
| 2210 | */
|
---|
| 2211 |
|
---|
| 2212 | /*! \fn const QX11Info &QPixmap::x11Info() const
|
---|
| 2213 | \bold{X11 only:} Returns information about the configuration of
|
---|
| 2214 | the X display used by the screen to which the pixmap currently belongs.
|
---|
| 2215 |
|
---|
| 2216 | \warning This function is only available on X11.
|
---|
| 2217 |
|
---|
| 2218 | \sa {QPixmap#Pixmap Information}{Pixmap Information}
|
---|
| 2219 | */
|
---|
| 2220 |
|
---|
| 2221 | /*! \fn Qt::HANDLE QPixmap::x11PictureHandle() const
|
---|
| 2222 | \bold{X11 only:} Returns the X11 Picture handle of the pixmap for
|
---|
| 2223 | XRender support.
|
---|
| 2224 |
|
---|
| 2225 | This function will return 0 if XRender support is not compiled
|
---|
| 2226 | into Qt, if the XRender extension is not supported on the X11
|
---|
| 2227 | display, or if the handle could not be created. Use of this
|
---|
| 2228 | function is not portable.
|
---|
| 2229 |
|
---|
| 2230 | \warning This function is only available on X11.
|
---|
| 2231 |
|
---|
| 2232 | \sa {QPixmap#Pixmap Information}{Pixmap Information}
|
---|
| 2233 | */
|
---|
| 2234 |
|
---|
| 2235 | /*! \fn int QPixmap::x11SetDefaultScreen(int screen)
|
---|
| 2236 | \internal
|
---|
| 2237 | */
|
---|
| 2238 |
|
---|
| 2239 | /*! \fn void QPixmap::x11SetScreen(int screen)
|
---|
| 2240 | \internal
|
---|
| 2241 | */
|
---|
| 2242 |
|
---|
| 2243 | /*! \fn QRgb* QPixmap::clut() const
|
---|
| 2244 | \internal
|
---|
| 2245 | */
|
---|
| 2246 |
|
---|
| 2247 | /*! \fn int QPixmap::numCols() const
|
---|
| 2248 | \obsolete
|
---|
| 2249 | \internal
|
---|
| 2250 | \sa colorCount()
|
---|
| 2251 | */
|
---|
| 2252 |
|
---|
| 2253 | /*! \fn int QPixmap::colorCount() const
|
---|
| 2254 | \since 4.6
|
---|
| 2255 | \internal
|
---|
| 2256 | */
|
---|
| 2257 |
|
---|
| 2258 | /*! \fn const uchar* QPixmap::qwsBits() const
|
---|
| 2259 | \internal
|
---|
| 2260 | \since 4.1
|
---|
| 2261 | */
|
---|
| 2262 |
|
---|
| 2263 | /*! \fn int QPixmap::qwsBytesPerLine() const
|
---|
| 2264 | \internal
|
---|
| 2265 | \since 4.1
|
---|
| 2266 | */
|
---|
| 2267 |
|
---|
[2] | 2268 | QT_END_NAMESPACE
|
---|