Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qpixmap.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <qglobal.h>
5
6#include "qpixmap.h"
7#include <qpa/qplatformpixmap.h>
9
10#include "qbitmap.h"
11#include "qimage.h"
12#include "qpainter.h"
13#include "qdatastream.h"
14#include "qbuffer.h"
15#include <private/qguiapplication_p.h>
16#include "qevent.h"
17#include "qfile.h"
18#include "qfileinfo.h"
19#include "qpixmapcache.h"
20#include "qdatetime.h"
21#include "qimagereader.h"
22#include "qimagewriter.h"
23#include "qpaintengine.h"
24#include "qscreen.h"
25#include "qthread.h"
26#include "qdebug.h"
27
28#include <qpa/qplatformintegration.h>
29
30#include "qpixmap_raster_p.h"
31#include "private/qhexstring_p.h"
32
33#include <qtgui_tracepoints_p.h>
34
35#include <memory>
36
38
39using namespace Qt::StringLiterals;
40
43
44// MSVC 19.28 does show spurious warning "C4723: potential divide by 0" for code that divides
45// by height() in release builds. Anyhow, all the code paths in this file are only executed
46// for valid QPixmap's, where height() cannot be 0. Therefore disable the warning.
48
50{
52 qFatal("QPixmap: Must construct a QGuiApplication before a QPixmap");
53 return false;
54 }
56 && qApp->thread() != QThread::currentThread()
58 qWarning("QPixmap: It is not safe to use pixmaps outside the GUI thread on this platform");
59 return false;
60 }
61 return true;
62}
63
64void QPixmap::doInit(int w, int h, int type)
65{
66 if ((w > 0 && h > 0) || type == QPlatformPixmap::BitmapType)
68 else
69 data = nullptr;
70}
71
84
100 : QPixmap(QSize(w, h))
101{
102}
103
115 : QPixmap(size, QPlatformPixmap::PixmapType)
116{
117}
118
122QPixmap::QPixmap(const QSize &s, int type)
123{
125 doInit(0, 0, static_cast<QPlatformPixmap::PixelType>(type));
126 else
127 doInit(s.width(), s.height(), static_cast<QPlatformPixmap::PixelType>(type));
128}
129
137
167QPixmap::QPixmap(const QString& fileName, const char *format, Qt::ImageConversionFlags flags)
168 : QPaintDevice()
169{
170 doInit(0, 0, QPlatformPixmap::PixmapType);
172 return;
173
175}
176
184 : QPaintDevice()
185{
186 if (!qt_pixmap_thread_test()) {
187 doInit(0, 0, QPlatformPixmap::PixmapType);
188 return;
189 }
190 if (pixmap.paintingActive()) { // make a deep copy
191 pixmap.copy().swap(*this);
192 } else {
193 data = pixmap.data;
194 }
195}
196
204
205
220#ifndef QT_NO_IMAGEFORMAT_XPM
221QPixmap::QPixmap(const char * const xpm[])
222 : QPaintDevice()
223{
224 doInit(0, 0, QPlatformPixmap::PixmapType);
225 if (!xpm)
226 return;
227
228 QImage image(xpm);
229 if (!image.isNull()) {
230 if (data && data->pixelType() == QPlatformPixmap::BitmapType)
231 *this = QBitmap::fromImage(std::move(image));
232 else
233 *this = fromImage(std::move(image));
234 }
235}
236#endif
237
238
244{
245 Q_ASSERT(!data || data->ref.loadRelaxed() >= 1); // Catch if ref-counting changes again
246}
247
252{
253 return QInternal::Pixmap;
254}
255
277{
278 if (isNull())
279 return QPixmap();
280
281 QRect r(0, 0, width(), height());
282 if (!rect.isEmpty())
283 r = r.intersected(rect);
284
286 d->copy(data.data(), r);
287 return QPixmap(d);
288}
289
310void QPixmap::scroll(int dx, int dy, const QRect &rect, QRegion *exposed)
311{
312 if (isNull() || (dx == 0 && dy == 0))
313 return;
314 QRect dest = rect & this->rect();
315 QRect src = dest.translated(-dx, -dy) & dest;
316 if (src.isEmpty()) {
317 if (exposed)
318 *exposed += dest;
319 return;
320 }
321
322 detach();
323
324 if (!data->scroll(dx, dy, src)) {
325 // Fallback
326 QPixmap pix = *this;
329 painter.drawPixmap(src.translated(dx, dy), *this, src);
330 painter.end();
331 *this = pix;
332 }
333
334 if (exposed) {
335 *exposed += dest;
336 *exposed -= src.translated(dx, dy);
337 }
338}
339
348{
349 if (paintingActive()) {
350 qWarning("QPixmap::operator=: Cannot assign to pixmap during painting");
351 return *this;
352 }
353 if (pixmap.paintingActive()) { // make a deep copy
354 pixmap.copy().swap(*this);
355 } else {
356 data = pixmap.data;
357 }
358 return *this;
359}
360
379QPixmap::operator QVariant() const
380{
381 return QVariant::fromValue(*this);
382}
383
409{
410 if (isNull())
411 return QImage();
412
413 return data->toImage();
414}
415
433{
434 return QImage::trueMatrix(m, w, h);
435}
436
444{
445 return data && data->type == QPlatformPixmap::BitmapType;
446}
447
456bool QPixmap::isNull() const
457{
458 return !data || data->isNull();
459}
460
468int QPixmap::width() const
469{
470 return data ? data->width() : 0;
471}
472
481{
482 return data ? data->height() : 0;
483}
484
494{
495 return data ? QSize(data->width(), data->height()) : QSize(0, 0);
496}
497
506{
507 return data ? QRect(0, 0, data->width(), data->height()) : QRect();
508}
509
521int QPixmap::depth() const
522{
523 return data ? data->depth() : 0;
524}
525
544{
545 if (paintingActive()) {
546 qWarning("QPixmap::setMask: Cannot set mask while pixmap is being painted on");
547 return;
548 }
549
550 if (!mask.isNull() && mask.size() != size()) {
551 qWarning("QPixmap::setMask() mask size differs from pixmap size");
552 return;
553 }
554
555 if (isNull())
556 return;
557
558 if (static_cast<const QPixmap &>(mask).data == data) // trying to selfmask
559 return;
560
561 detach();
562 data->setMask(mask);
563}
564
577{
578 if (!data)
579 return qreal(1.0);
580 return data->devicePixelRatio();
581}
582
605{
606 if (isNull())
607 return;
608
609 if (scaleFactor == data->devicePixelRatio())
610 return;
611
612 detach();
613 data->setDevicePixelRatio(scaleFactor);
614}
615
627{
628 if (!data)
629 return QSizeF(0, 0);
630 return QSizeF(data->width(), data->height()) / data->devicePixelRatio();
631}
632
633#ifndef QT_NO_IMAGE_HEURISTIC_MASK
654{
656 return m;
657}
658#endif
659
676
704bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConversionFlags flags)
705{
706 if (!fileName.isEmpty()) {
707
709 // Note: If no extension is provided, we try to match the
710 // file against known plugin extensions
711 if (info.completeSuffix().isEmpty() || info.exists()) {
712 const bool inGuiThread = qApp->thread() == QThread::currentThread();
713
714 QString key = "qt_pixmap"_L1
715 % info.absoluteFilePath()
716 % HexString<uint>(info.lastModified(QTimeZone::UTC).toSecsSinceEpoch())
717 % HexString<quint64>(info.size())
718 % HexString<uint>(data ? data->pixelType() : QPlatformPixmap::PixmapType);
719
720 if (inGuiThread && QPixmapCache::find(key, this))
721 return true;
722
724
725 if (data->fromFile(fileName, format, flags)) {
726 if (inGuiThread)
728 return true;
729 }
730 }
731 }
732
733 if (!isNull()) {
734 if (isQBitmap())
735 *this = QBitmap();
736 else
737 data.reset();
738 }
739 return false;
740}
741
761bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags)
762{
763 if (len == 0 || buf == nullptr) {
764 data.reset();
765 return false;
766 }
767
769
770 if (data->fromData(buf, len, format, flags))
771 return true;
772
773 data.reset();
774 return false;
775}
776
803bool QPixmap::save(const QString &fileName, const char *format, int quality) const
804{
805 if (isNull())
806 return false; // nothing to save
808 return doImageIO(&writer, quality);
809}
810
821bool QPixmap::save(QIODevice* device, const char* format, int quality) const
822{
823 if (isNull())
824 return false; // nothing to save
825 QImageWriter writer(device, format);
826 return doImageIO(&writer, quality);
827}
828
831bool QPixmap::doImageIO(QImageWriter *writer, int quality) const
832{
833 if (quality > 100 || quality < -1)
834 qWarning("QPixmap::save: quality out of range [-1,100]");
835 if (quality >= 0)
836 writer->setQuality(qMin(quality,100));
837 return writer->write(toImage());
838}
839
840
851{
852 if (isNull())
853 return;
854
855 // Some people are probably already calling fill while a painter is active, so to not break
856 // their programs, only print a warning and return when the fill operation could cause a crash.
857 if (paintingActive() && (color.alpha() != 255) && !hasAlphaChannel()) {
858 qWarning("QPixmap::fill: Cannot fill while pixmap is being painted on");
859 return;
860 }
861
862 if (data->ref.loadRelaxed() == 1) {
863 // detach() will also remove this pixmap from caches, so
864 // it has to be called even when ref == 1.
865 detach();
866 } else {
867 // Don't bother to make a copy of the data object, since
868 // it will be filled with new pixel data anyway.
870 d->resize(data->width(), data->height());
871 d->setDevicePixelRatio(data->devicePixelRatio());
872 data = d;
873 }
874 data->fill(color);
875}
876
885{
886 if (isNull())
887 return 0;
888
889 Q_ASSERT(data);
890 return data->cacheKey();
891}
892
893#if 0
894static void sendResizeEvents(QWidget *target)
895{
896 QResizeEvent e(target->size(), QSize());
898
899 const QObjectList children = target->children();
900 for (int i = 0; i < children.size(); ++i) {
901 QWidget *child = static_cast<QWidget*>(children.at(i));
902 if (child->isWidgetType() && !child->isWindow() && child->testAttribute(Qt::WA_PendingResizeEvent))
904 }
905}
906#endif
907
908
909/*****************************************************************************
910 QPixmap stream functions
911 *****************************************************************************/
912#if !defined(QT_NO_DATASTREAM)
924{
925 return stream << pixmap.toImage();
926}
927
937{
939 stream >> image;
940
941 if (image.isNull()) {
942 pixmap = QPixmap();
943 } else if (image.depth() == 1) {
944 pixmap = QBitmap::fromImage(std::move(image));
945 } else {
946 pixmap = QPixmap::fromImage(std::move(image));
947 }
948 return stream;
949}
950
951#endif // QT_NO_DATASTREAM
952
958{
959 return data && data->ref.loadRelaxed() == 1;
960}
961
971bool QPixmap::convertFromImage(const QImage &image, Qt::ImageConversionFlags flags)
972{
973 detach();
974 if (image.isNull() || !data)
976 else
977 data->fromImage(image, flags);
978 return !isNull();
979}
980
1030{
1031 if (isNull()) {
1032 qWarning("QPixmap::scaled: Pixmap is a null pixmap");
1033 return QPixmap();
1034 }
1035 if (s.isEmpty())
1036 return QPixmap();
1037
1038 QSize newSize = size();
1039 newSize.scale(s, aspectMode);
1040 newSize.rwidth() = qMax(newSize.width(), 1);
1041 newSize.rheight() = qMax(newSize.height(), 1);
1042 if (newSize == size())
1043 return *this;
1044
1045 Q_TRACE_SCOPE(QPixmap_scaled, s, aspectMode, mode);
1046
1047 QTransform wm = QTransform::fromScale((qreal)newSize.width() / width(),
1048 (qreal)newSize.height() / height());
1049 QPixmap pix = transformed(wm, mode);
1050 return pix;
1051}
1052
1068{
1069 if (isNull()) {
1070 qWarning("QPixmap::scaleWidth: Pixmap is a null pixmap");
1071 return copy();
1072 }
1073 if (w <= 0)
1074 return QPixmap();
1075
1076 Q_TRACE_SCOPE(QPixmap_scaledToWidth, w, mode);
1077
1078 qreal factor = (qreal) w / width();
1079 QTransform wm = QTransform::fromScale(factor, factor);
1080 return transformed(wm, mode);
1081}
1082
1098{
1099 if (isNull()) {
1100 qWarning("QPixmap::scaleHeight: Pixmap is a null pixmap");
1101 return copy();
1102 }
1103 if (h <= 0)
1104 return QPixmap();
1105
1106 Q_TRACE_SCOPE(QPixmap_scaledToHeight, h, mode);
1107
1108 qreal factor = (qreal) h / height();
1109 QTransform wm = QTransform::fromScale(factor, factor);
1110 return transformed(wm, mode);
1111}
1112
1133{
1134 if (isNull() || transform.type() <= QTransform::TxTranslate)
1135 return *this;
1136
1137 return data->transformed(transform, mode);
1138}
1139
1316bool QPixmap::hasAlpha() const
1317{
1318 return data && data->hasAlphaChannel();
1319}
1320
1327bool QPixmap::hasAlphaChannel() const
1328{
1329 return data && data->hasAlphaChannel();
1330}
1331
1335int QPixmap::metric(PaintDeviceMetric metric) const
1336{
1337 return data ? data->metric(metric) : 0;
1338}
1339
1344{
1345 return data ? data->paintEngine() : nullptr;
1346}
1347
1358QBitmap QPixmap::mask() const
1359{
1360 return data ? data->mask() : QBitmap();
1361}
1362
1374{
1376 if (Q_LIKELY(primary))
1377 return primary->depth();
1378 qWarning("QPixmap: QGuiApplication must be created before calling defaultDepth().");
1379 return 0;
1380}
1381
1400{
1401 if (!data)
1402 return;
1403
1404 // QPixmap.data member may be QRuntimePlatformPixmap so use handle() function to get
1405 // the actual underlying runtime pixmap data.
1406 QPlatformPixmap *pd = handle();
1408 if (id == QPlatformPixmap::RasterClass) {
1409 QRasterPlatformPixmap *rasterData = static_cast<QRasterPlatformPixmap*>(pd);
1410 rasterData->image.detach();
1411 }
1412
1413 if (data->is_cached && data->ref.loadRelaxed() == 1)
1415
1416 if (data->ref.loadRelaxed() != 1) {
1417 *this = copy();
1418 }
1419 ++data->detach_no;
1420}
1421
1437QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags)
1438{
1439 if (image.isNull())
1440 return QPixmap();
1441
1442 if (Q_UNLIKELY(!qobject_cast<QGuiApplication *>(QCoreApplication::instance()))) {
1443 qWarning("QPixmap::fromImage: QPixmap cannot be created without a QGuiApplication");
1444 return QPixmap();
1445 }
1446
1447 std::unique_ptr<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType));
1448 data->fromImage(image, flags);
1449 return QPixmap(data.release());
1450}
1451
1465{
1466 if (image.isNull())
1467 return QPixmap();
1468
1469 if (Q_UNLIKELY(!qobject_cast<QGuiApplication *>(QCoreApplication::instance()))) {
1470 qWarning("QPixmap::fromImageInPlace: QPixmap cannot be created without a QGuiApplication");
1471 return QPixmap();
1472 }
1473
1474 std::unique_ptr<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType));
1475 data->fromImageInPlace(image, flags);
1476 return QPixmap(data.release());
1477}
1478
1491QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags)
1492{
1493 if (Q_UNLIKELY(!qobject_cast<QGuiApplication *>(QCoreApplication::instance()))) {
1494 qWarning("QPixmap::fromImageReader: QPixmap cannot be created without a QGuiApplication");
1495 return QPixmap();
1496 }
1497
1498 std::unique_ptr<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType));
1499 data->fromImageReader(imageReader, flags);
1500 return QPixmap(data.release());
1501}
1502
1507{
1508 return data.data();
1509}
1510
1511#ifndef QT_NO_DEBUG_STREAM
1513{
1514 QDebugStateSaver saver(dbg);
1515 dbg.resetFormat();
1516 dbg.nospace();
1517 dbg << "QPixmap(";
1518 if (r.isNull()) {
1519 dbg << "null";
1520 } else {
1521 dbg << r.size() << ",depth=" << r.depth()
1522 << ",devicePixelRatio=" << r.devicePixelRatio()
1523 << ",cacheKey=" << Qt::showbase << Qt::hex << r.cacheKey() << Qt::dec << Qt::noshowbase;
1524 }
1525 dbg << ')';
1526 return dbg;
1527}
1528#endif
1529
IOBluetoothDevice * device
\inmodule QtGui
Definition qbitmap.h:16
static QBitmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Returns a copy of the given image converted to a bitmap using the specified image conversion flags.
Definition qbitmap.cpp:170
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
QRgb rgba() const noexcept
Returns the RGB value of the color, including its alpha.
Definition qcolor.cpp:1376
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
\inmodule QtCore\reentrant
Definition qdatastream.h:46
\inmodule QtCore
\inmodule QtCore
static QPlatformIntegration * platformIntegration()
static QGuiApplicationPrivate * instance()
QScreen * primaryScreen
the primary (or default) screen of the application.
\inmodule QtCore \reentrant
Definition qiodevice.h:34
static void executePlatformPixmapModificationHooks(QPlatformPixmap *)
The QImageReader class provides a format independent interface for reading images from files or other...
The QImageWriter class provides a format independent interface for writing images to files or other d...
\inmodule QtGui
Definition qimage.h:37
@ Format_ARGB32
Definition qimage.h:47
void detach()
Definition qimage.cpp:1128
static QTransform trueMatrix(const QTransform &, int w, int h)
Returns a copy of the image that is transformed using the given transformation matrix and transformat...
Definition qimage.cpp:4802
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const &
Definition qimage.h:125
qsizetype size() const noexcept
Definition qlist.h:397
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
bool paintingActive() const
\inmodule QtGui
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
bool end()
Ends painting.
@ CompositionMode_Source
Definition qpainter.h:101
static bool find(const QString &key, QPixmap *pixmap)
Looks for a cached pixmap associated with the given key in the cache.
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
int metric(PaintDeviceMetric) const override
int height() const
Returns the height of the pixmap.
Definition qpixmap.cpp:480
bool convertFromImage(const QImage &img, Qt::ImageConversionFlags flags=Qt::AutoColor)
Replaces this pixmap's data with the given image using the specified flags to control the conversion.
Definition qpixmap.cpp:971
QPixmap scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
Definition qpixmap.h:78
QPixmap()
Constructs a null pixmap.
Definition qpixmap.cpp:78
QImage toImage() const
Converts the pixmap to a QImage.
Definition qpixmap.cpp:408
QSizeF deviceIndependentSize() const
Returns the size of the pixmap in device independent pixels.
Definition qpixmap.cpp:626
QPixmap scaledToWidth(int w, Qt::TransformationMode mode=Qt::FastTransformation) const
Returns a scaled copy of the image.
Definition qpixmap.cpp:1029
bool isDetached() const
Definition qpixmap.cpp:957
QBitmap createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode=Qt::MaskInColor) const
Creates and returns a mask for this pixmap based on the given maskColor.
Definition qpixmap.cpp:671
static QPixmap fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags=Qt::AutoColor)
Create a QPixmap from an image read directly from an imageReader.
Definition qpixmap.cpp:1491
QPaintEngine * paintEngine() const override
static QTransform trueMatrix(const QTransform &m, int w, int h)
Returns the actual matrix used for transforming a pixmap with the given width, height and matrix.
Definition qpixmap.cpp:432
friend class QBitmap
Definition qpixmap.h:133
QSize size() const
Returns the size of the pixmap.
Definition qpixmap.cpp:493
bool load(const QString &fileName, const char *format=nullptr, Qt::ImageConversionFlags flags=Qt::AutoColor)
Loads a pixmap from the file with the given fileName.
Definition qpixmap.cpp:704
void scroll(int dx, int dy, int x, int y, int width, int height, QRegion *exposed=nullptr)
This convenience function is equivalent to calling QPixmap::scroll(dx, dy, QRect(x,...
Definition qpixmap.h:158
int depth() const
Returns the depth of the pixmap.
Definition qpixmap.cpp:521
QPixmap scaledToHeight(int h, Qt::TransformationMode mode=Qt::FastTransformation) const
Returns a scaled copy of the image.
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition qpixmap.cpp:456
QBitmap mask() const
Returns true if this pixmap has an alpha channel, or has a mask, otherwise returns false.
int width() const
Returns the width of the pixmap.
Definition qpixmap.cpp:468
static QPixmap fromImageInPlace(QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Definition qpixmap.cpp:1464
QPlatformPixmap * handle() const
Definition qpixmap.cpp:1506
QBitmap createHeuristicMask(bool clipTight=true) const
Creates and returns a heuristic mask for this pixmap.
Definition qpixmap.cpp:653
void detach()
Detaches the pixmap from shared pixmap data.
Definition qpixmap.cpp:1399
QPixmap copy(int x, int y, int width, int height) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qpixmap.h:153
void setMask(const QBitmap &)
Sets a mask bitmap.
Definition qpixmap.cpp:543
QPixmap transformed(const QTransform &, Qt::TransformationMode mode=Qt::FastTransformation) const
static int defaultDepth()
QDataStream & operator<<(QDataStream &stream, const QPixmap &pixmap)
Writes the given pixmap to the given stream as a PNG image.
Definition qpixmap.cpp:923
void setDevicePixelRatio(qreal scaleFactor)
Sets the device pixel ratio for the pixmap.
Definition qpixmap.cpp:604
QRect rect() const
Returns the pixmap's enclosing rectangle.
Definition qpixmap.cpp:505
QPixmap & operator=(const QPixmap &)
Assigns the given pixmap to this pixmap and returns a reference to this pixmap.
Definition qpixmap.cpp:347
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition qpixmap.cpp:850
qreal devicePixelRatio() const
Returns the device pixel ratio for the pixmap.
Definition qpixmap.cpp:576
int devType() const override
Definition qpixmap.cpp:251
bool loadFromData(const uchar *buf, uint len, const char *format=nullptr, Qt::ImageConversionFlags flags=Qt::AutoColor)
Loads a pixmap from the len first bytes of the given binary data.
Definition qpixmap.cpp:761
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition qpixmap.cpp:1437
qint64 cacheKey() const
Returns a number that identifies this QPixmap.
Definition qpixmap.cpp:884
bool hasAlphaChannel() const
bool save(const QString &fileName, const char *format=nullptr, int quality=-1) const
Saves the pixmap to the file with the given fileName using the specified image file format and qualit...
Definition qpixmap.cpp:803
bool hasAlpha() const
~QPixmap()
Destroys the pixmap.
Definition qpixmap.cpp:243
bool isQBitmap() const
Returns true if this is a QBitmap; otherwise returns false.
Definition qpixmap.cpp:443
The QPlatformPixmap class provides an abstraction for native pixmaps.
virtual QPlatformPixmap * createCompatiblePlatformPixmap() const
static QPlatformPixmap * create(int w, int h, PixelType type)
ClassId classId() const
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
Definition qrect.h:167
constexpr QRect translated(int dx, int dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
Definition qrect.h:261
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
QRegion translated(int dx, int dy) const
Definition qregion.cpp:593
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
int depth
the color depth of the screen
Definition qscreen.h:40
\inmodule QtCore
Definition qsize.h:208
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
constexpr int & rheight() noexcept
Returns a reference to the height.
Definition qsize.h:157
void scale(int w, int h, Qt::AspectRatioMode mode) noexcept
Scales the size to a rectangle with the given width and height, according to the specified mode:
Definition qsize.h:145
constexpr int & rwidth() noexcept
Returns a reference to the width.
Definition qsize.h:154
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QThread * currentThread()
Definition qthread.cpp:1039
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
static QTransform fromScale(qreal dx, qreal dy)
Creates a matrix which corresponds to a scaling of sx horizontally and sy vertically.
\inmodule QtCore
Definition qvariant.h:65
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:536
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
rect
[4]
QPixmap pix
Combined button and popup list for selecting options.
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
TransformationMode
QTextStream & showbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::ShowBase) on stream and r...
@ WA_PendingResizeEvent
Definition qnamespace.h:302
AspectRatioMode
QTextStream & noshowbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::ShowBase) on stream and ...
QTextStream & dec(QTextStream &stream)
Calls QTextStream::setIntegerBase(10) on stream and returns stream.
Definition image.cpp:4
#define Q_UNLIKELY(x)
#define QT_WARNING_DISABLE_MSVC(number)
#define Q_LIKELY(x)
#define qApp
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
EGLStreamKHR stream
#define qWarning
Definition qlogging.h:166
#define qFatal
Definition qlogging.h:168
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLenum mode
const GLfloat * m
GLuint64 key
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLboolean r
[2]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum src
GLint GLsizei width
GLuint color
[2]
GLenum type
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum target
GLbitfield flags
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLuint GLenum GLenum transform
GLdouble s
[6]
Definition qopenglext.h:235
GLenum GLsizei len
static bool qt_pixmap_thread_test()
Definition qpixmap.cpp:49
QDebug operator<<(QDebug dbg, const QPixmap &r)
Definition qpixmap.cpp:1512
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define QT_DEFINE_QESDP_SPECIALIZATION_DTOR(Class)
#define Q_TRACE_PARAM_REPLACE(in, out)
Definition qtrace_p.h:231
#define Q_TRACE_SCOPE(x,...)
Definition qtrace_p.h:146
#define Q_TRACE_INSTRUMENT(provider)
Definition qtrace_p.h:230
unsigned char uchar
Definition qtypes.h:32
unsigned int uint
Definition qtypes.h:34
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187
static void sendResizeEvents(QWidget *target)
Definition qwidget.cpp:5188
QDataStream & operator>>(QDataStream &in, MyClass &myObj)
QLayoutItem * child
[0]
widget render & pixmap
QPainter painter(this)
[7]
QHostInfo info
[0]