Qt 6.x
The Qt SDK
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
79 : QPaintDevice()
80{
82 doInit(0, 0, QPlatformPixmap::PixmapType);
83}
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
134 : QPaintDevice(), data(d)
135{
136}
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
285 QPlatformPixmap *d = data->createCompatiblePlatformPixmap();
286 d->copy(data.data(), r);
287 return QPixmap(d);
288}
289
313void QPixmap::scroll(int dx, int dy, const QRect &rect, QRegion *exposed)
314{
315 if (isNull() || (dx == 0 && dy == 0))
316 return;
317 QRect dest = rect & this->rect();
318 QRect src = dest.translated(-dx, -dy) & dest;
319 if (src.isEmpty()) {
320 if (exposed)
321 *exposed += dest;
322 return;
323 }
324
325 detach();
326
327 if (!data->scroll(dx, dy, src)) {
328 // Fallback
329 QPixmap pix = *this;
332 painter.drawPixmap(src.translated(dx, dy), *this, src);
333 painter.end();
334 *this = pix;
335 }
336
337 if (exposed) {
338 *exposed += dest;
339 *exposed -= src.translated(dx, dy);
340 }
341}
342
351{
352 if (paintingActive()) {
353 qWarning("QPixmap::operator=: Cannot assign to pixmap during painting");
354 return *this;
355 }
356 if (pixmap.paintingActive()) { // make a deep copy
357 pixmap.copy().swap(*this);
358 } else {
359 data = pixmap.data;
360 }
361 return *this;
362}
363
383QPixmap::operator QVariant() const
384{
385 return QVariant::fromValue(*this);
386}
387
413{
414 if (isNull())
415 return QImage();
416
417 return data->toImage();
418}
419
437{
438 return QImage::trueMatrix(m, w, h);
439}
440
448{
449 return data && data->type == QPlatformPixmap::BitmapType;
450}
451
460bool QPixmap::isNull() const
461{
462 return !data || data->isNull();
463}
464
472int QPixmap::width() const
473{
474 return data ? data->width() : 0;
475}
476
485{
486 return data ? data->height() : 0;
487}
488
498{
499 return data ? QSize(data->width(), data->height()) : QSize(0, 0);
500}
501
510{
511 return data ? QRect(0, 0, data->width(), data->height()) : QRect();
512}
513
525int QPixmap::depth() const
526{
527 return data ? data->depth() : 0;
528}
529
548{
549 if (paintingActive()) {
550 qWarning("QPixmap::setMask: Cannot set mask while pixmap is being painted on");
551 return;
552 }
553
554 if (!mask.isNull() && mask.size() != size()) {
555 qWarning("QPixmap::setMask() mask size differs from pixmap size");
556 return;
557 }
558
559 if (isNull())
560 return;
561
562 if (static_cast<const QPixmap &>(mask).data == data) // trying to selfmask
563 return;
564
565 detach();
566 data->setMask(mask);
567}
568
581{
582 if (!data)
583 return qreal(1.0);
584 return data->devicePixelRatio();
585}
586
609{
610 if (isNull())
611 return;
612
613 if (scaleFactor == data->devicePixelRatio())
614 return;
615
616 detach();
617 data->setDevicePixelRatio(scaleFactor);
618}
619
631{
632 if (!data)
633 return QSizeF(0, 0);
634 return QSizeF(data->width(), data->height()) / data->devicePixelRatio();
635}
636
637#ifndef QT_NO_IMAGE_HEURISTIC_MASK
658{
660 return m;
661}
662#endif
663
676{
678 return QBitmap::fromImage(std::move(image).createMaskFromColor(maskColor.rgba(), mode));
679}
680
708bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConversionFlags flags)
709{
710 if (!fileName.isEmpty()) {
711
713 // Note: If no extension is provided, we try to match the
714 // file against known plugin extensions
715 if (info.completeSuffix().isEmpty() || info.exists()) {
716 const bool inGuiThread = qApp->thread() == QThread::currentThread();
717
718 QString key = "qt_pixmap"_L1
723
724 if (inGuiThread && QPixmapCache::find(key, this))
725 return true;
726
728
729 if (data->fromFile(fileName, format, flags)) {
730 if (inGuiThread)
732 return true;
733 }
734 }
735 }
736
737 if (!isNull()) {
738 if (isQBitmap())
739 *this = QBitmap();
740 else
741 data.reset();
742 }
743 return false;
744}
745
765bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags)
766{
767 if (len == 0 || buf == nullptr) {
768 data.reset();
769 return false;
770 }
771
773
774 if (data->fromData(buf, len, format, flags))
775 return true;
776
777 data.reset();
778 return false;
779}
780
807bool QPixmap::save(const QString &fileName, const char *format, int quality) const
808{
809 if (isNull())
810 return false; // nothing to save
812 return doImageIO(&writer, quality);
813}
814
825bool QPixmap::save(QIODevice* device, const char* format, int quality) const
826{
827 if (isNull())
828 return false; // nothing to save
829 QImageWriter writer(device, format);
830 return doImageIO(&writer, quality);
831}
832
835bool QPixmap::doImageIO(QImageWriter *writer, int quality) const
836{
837 if (quality > 100 || quality < -1)
838 qWarning("QPixmap::save: quality out of range [-1,100]");
839 if (quality >= 0)
840 writer->setQuality(qMin(quality,100));
841 return writer->write(toImage());
842}
843
844
855{
856 if (isNull())
857 return;
858
859 // Some people are probably already calling fill while a painter is active, so to not break
860 // their programs, only print a warning and return when the fill operation could cause a crash.
861 if (paintingActive() && (color.alpha() != 255) && !hasAlphaChannel()) {
862 qWarning("QPixmap::fill: Cannot fill while pixmap is being painted on");
863 return;
864 }
865
866 if (data->ref.loadRelaxed() == 1) {
867 // detach() will also remove this pixmap from caches, so
868 // it has to be called even when ref == 1.
869 detach();
870 } else {
871 // Don't bother to make a copy of the data object, since
872 // it will be filled with new pixel data anyway.
873 QPlatformPixmap *d = data->createCompatiblePlatformPixmap();
874 d->resize(data->width(), data->height());
875 d->setDevicePixelRatio(data->devicePixelRatio());
876 data = d;
877 }
878 data->fill(color);
879}
880
889{
890 if (isNull())
891 return 0;
892
893 Q_ASSERT(data);
894 return data->cacheKey();
895}
896
897#if 0
898static void sendResizeEvents(QWidget *target)
899{
900 QResizeEvent e(target->size(), QSize());
902
903 const QObjectList children = target->children();
904 for (int i = 0; i < children.size(); ++i) {
905 QWidget *child = static_cast<QWidget*>(children.at(i));
906 if (child->isWidgetType() && !child->isWindow() && child->testAttribute(Qt::WA_PendingResizeEvent))
908 }
909}
910#endif
911
912
913/*****************************************************************************
914 QPixmap stream functions
915 *****************************************************************************/
916#if !defined(QT_NO_DATASTREAM)
928{
929 return stream << pixmap.toImage();
930}
931
941{
943 stream >> image;
944
945 if (image.isNull()) {
946 pixmap = QPixmap();
947 } else if (image.depth() == 1) {
948 pixmap = QBitmap::fromImage(std::move(image));
949 } else {
950 pixmap = QPixmap::fromImage(std::move(image));
951 }
952 return stream;
953}
954
955#endif // QT_NO_DATASTREAM
956
962{
963 return data && data->ref.loadRelaxed() == 1;
964}
965
980bool QPixmap::convertFromImage(const QImage &image, Qt::ImageConversionFlags flags)
981{
982 detach();
983 if (image.isNull() || !data)
985 else
986 data->fromImage(image, flags);
987 return !isNull();
988}
989
1039{
1040 if (isNull()) {
1041 qWarning("QPixmap::scaled: Pixmap is a null pixmap");
1042 return QPixmap();
1043 }
1044 if (s.isEmpty())
1045 return QPixmap();
1046
1047 QSize newSize = size();
1048 newSize.scale(s, aspectMode);
1049 newSize.rwidth() = qMax(newSize.width(), 1);
1050 newSize.rheight() = qMax(newSize.height(), 1);
1051 if (newSize == size())
1052 return *this;
1053
1054 Q_TRACE_SCOPE(QPixmap_scaled, s, aspectMode, mode);
1055
1056 QTransform wm = QTransform::fromScale((qreal)newSize.width() / width(),
1057 (qreal)newSize.height() / height());
1058 QPixmap pix = transformed(wm, mode);
1059 return pix;
1060}
1061
1077{
1078 if (isNull()) {
1079 qWarning("QPixmap::scaleWidth: Pixmap is a null pixmap");
1080 return copy();
1081 }
1082 if (w <= 0)
1083 return QPixmap();
1084
1085 Q_TRACE_SCOPE(QPixmap_scaledToWidth, w, mode);
1086
1087 qreal factor = (qreal) w / width();
1088 QTransform wm = QTransform::fromScale(factor, factor);
1089 return transformed(wm, mode);
1090}
1091
1107{
1108 if (isNull()) {
1109 qWarning("QPixmap::scaleHeight: Pixmap is a null pixmap");
1110 return copy();
1111 }
1112 if (h <= 0)
1113 return QPixmap();
1114
1115 Q_TRACE_SCOPE(QPixmap_scaledToHeight, h, mode);
1116
1117 qreal factor = (qreal) h / height();
1118 QTransform wm = QTransform::fromScale(factor, factor);
1119 return transformed(wm, mode);
1120}
1121
1142{
1143 if (isNull() || transform.type() <= QTransform::TxTranslate)
1144 return *this;
1145
1146 return data->transformed(transform, mode);
1147}
1148
1324bool QPixmap::hasAlpha() const
1325{
1326 return data && data->hasAlphaChannel();
1327}
1328
1335bool QPixmap::hasAlphaChannel() const
1336{
1337 return data && data->hasAlphaChannel();
1338}
1339
1343int QPixmap::metric(PaintDeviceMetric metric) const
1344{
1345 return data ? data->metric(metric) : 0;
1346}
1347
1352{
1353 return data ? data->paintEngine() : nullptr;
1354}
1355
1366QBitmap QPixmap::mask() const
1367{
1368 return data ? data->mask() : QBitmap();
1369}
1370
1382{
1384 if (Q_LIKELY(primary))
1385 return primary->depth();
1386 qWarning("QPixmap: QGuiApplication must be created before calling defaultDepth().");
1387 return 0;
1388}
1389
1408{
1409 if (!data)
1410 return;
1411
1412 // QPixmap.data member may be QRuntimePlatformPixmap so use handle() function to get
1413 // the actual underlying runtime pixmap data.
1414 QPlatformPixmap *pd = handle();
1416 if (id == QPlatformPixmap::RasterClass) {
1417 QRasterPlatformPixmap *rasterData = static_cast<QRasterPlatformPixmap*>(pd);
1418 rasterData->image.detach();
1419 }
1420
1421 if (data->is_cached && data->ref.loadRelaxed() == 1)
1423
1424 if (data->ref.loadRelaxed() != 1) {
1425 *this = copy();
1426 }
1427 ++data->detach_no;
1428}
1429
1445QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags)
1446{
1447 if (image.isNull())
1448 return QPixmap();
1449
1450 if (Q_UNLIKELY(!qobject_cast<QGuiApplication *>(QCoreApplication::instance()))) {
1451 qWarning("QPixmap::fromImage: QPixmap cannot be created without a QGuiApplication");
1452 return QPixmap();
1453 }
1454
1455 std::unique_ptr<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType));
1456 data->fromImage(image, flags);
1457 return QPixmap(data.release());
1458}
1459
1473{
1474 if (image.isNull())
1475 return QPixmap();
1476
1477 if (Q_UNLIKELY(!qobject_cast<QGuiApplication *>(QCoreApplication::instance()))) {
1478 qWarning("QPixmap::fromImageInPlace: QPixmap cannot be created without a QGuiApplication");
1479 return QPixmap();
1480 }
1481
1482 std::unique_ptr<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType));
1483 data->fromImageInPlace(image, flags);
1484 return QPixmap(data.release());
1485}
1486
1499QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags)
1500{
1501 if (Q_UNLIKELY(!qobject_cast<QGuiApplication *>(QCoreApplication::instance()))) {
1502 qWarning("QPixmap::fromImageReader: QPixmap cannot be created without a QGuiApplication");
1503 return QPixmap();
1504 }
1505
1506 std::unique_ptr<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType));
1507 data->fromImageReader(imageReader, flags);
1508 return QPixmap(data.release());
1509}
1510
1515{
1516 return data.data();
1517}
1518
1519#ifndef QT_NO_DEBUG_STREAM
1521{
1522 QDebugStateSaver saver(dbg);
1523 dbg.resetFormat();
1524 dbg.nospace();
1525 dbg << "QPixmap(";
1526 if (r.isNull()) {
1527 dbg << "null";
1528 } else {
1529 dbg << r.size() << ",depth=" << r.depth()
1530 << ",devicePixelRatio=" << r.devicePixelRatio()
1531 << ",cacheKey=" << Qt::showbase << Qt::hex << r.cacheKey() << Qt::dec << Qt::noshowbase;
1532 }
1533 dbg << ')';
1534 return dbg;
1535}
1536#endif
1537
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:30
qint64 toSecsSinceEpoch() const
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore \reentrant
Definition qfileinfo.h:22
QDateTime lastModified() const
Returns the date and time when the file was last modified.
Definition qfileinfo.h:156
QString completeSuffix() const
Returns the complete suffix (extension) of the file.
QString absoluteFilePath() const
Returns an absolute path including the file name.
qint64 size() const
Returns the file size in bytes.
bool exists() const
Returns true if the file exists; otherwise returns false.
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...
bool write(const QImage &image)
Writes the image image to the assigned device or file name.
void setQuality(int quality)
Sets the quality setting of the image format to quality.
\inmodule QtGui
Definition qimage.h:37
@ Format_ARGB32
Definition qimage.h:47
void detach()
Definition qimage.cpp:1104
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:4785
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const &
Definition qimage.h:124
qsizetype size() const noexcept
Definition qlist.h:386
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
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:484
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:980
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:412
QSizeF deviceIndependentSize() const
Returns the size of the pixmap in device independent pixels.
Definition qpixmap.cpp:630
QPixmap scaledToWidth(int w, Qt::TransformationMode mode=Qt::FastTransformation) const
Returns a scaled copy of the image.
Definition qpixmap.cpp:1038
bool isDetached() const
Definition qpixmap.cpp:961
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:675
static QPixmap fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags=Qt::AutoColor)
Create a QPixmap from an image read directly from an imageReader.
Definition qpixmap.cpp:1499
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:436
friend class QBitmap
Definition qpixmap.h:133
QSize size() const
Returns the size of the pixmap.
Definition qpixmap.cpp:497
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:708
void scroll(int dx, int dy, int x, int y, int width, int height, QRegion *exposed=nullptr)
Definition qpixmap.h:158
int depth() const
Returns the depth of the pixmap.
Definition qpixmap.cpp:525
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:460
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:472
static QPixmap fromImageInPlace(QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Definition qpixmap.cpp:1472
QPlatformPixmap * handle() const
Definition qpixmap.cpp:1514
QBitmap createHeuristicMask(bool clipTight=true) const
Creates and returns a heuristic mask for this pixmap.
Definition qpixmap.cpp:657
void detach()
Detaches the pixmap from shared pixmap data.
Definition qpixmap.cpp:1407
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:547
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:927
void setDevicePixelRatio(qreal scaleFactor)
Sets the device pixel ratio for the pixmap.
Definition qpixmap.cpp:608
QRect rect() const
Returns the pixmap's enclosing rectangle.
Definition qpixmap.cpp:509
QPixmap & operator=(const QPixmap &)
Assigns the given pixmap to this pixmap and returns a reference to this pixmap.
Definition qpixmap.cpp:350
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition qpixmap.cpp:854
qreal devicePixelRatio() const
Returns the device pixel ratio for the pixmap.
Definition qpixmap.cpp:580
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:765
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:1445
qint64 cacheKey() const
Returns a number that identifies this QPixmap.
Definition qpixmap.cpp:888
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:807
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:447
virtual bool hasCapability(Capability cap) const
The QPlatformPixmap class provides an abstraction for native pixmaps.
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:166
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:260
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:547
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:207
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:132
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:129
constexpr int & rheight() noexcept
Returns a reference to the height.
Definition qsize.h:156
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:144
constexpr int & rwidth() noexcept
Returns a reference to the width.
Definition qsize.h:153
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:1083
static QThread * currentThread()
Definition qthread.cpp:966
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:64
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:531
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
double e
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:301
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:162
#define qFatal
Definition qlogging.h:164
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]
GLenum src
GLint GLsizei width
GLenum type
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum target
GLbitfield flags
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLuint GLenum GLenum transform
GLenum GLsizei len
GLdouble s
[6]
Definition qopenglext.h:235
static bool qt_pixmap_thread_test()
Definition qpixmap.cpp:49
QDebug operator<<(QDebug dbg, const QPixmap &r)
Definition qpixmap.cpp:1520
#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:27
unsigned int uint
Definition qtypes.h:29
long long qint64
Definition qtypes.h:55
double qreal
Definition qtypes.h:92
static void sendResizeEvents(QWidget *target)
Definition qwidget.cpp:5192
QFileInfo info(fileName)
[8]
QDataStream & operator>>(QDataStream &in, MyClass &myObj)
QLayoutItem * child
[0]
widget render & pixmap
QPainter painter(this)
[7]