7#include <qpa/qplatformpixmap.h>
15#include <private/qguiapplication_p.h>
28#include <qpa/qplatformintegration.h>
31#include "private/qhexstring_p.h"
33#include <qtgui_tracepoints_p.h>
52 qFatal(
"QPixmap: Must construct a QGuiApplication before a QPixmap");
58 qWarning(
"QPixmap: It is not safe to use pixmaps outside the GUI thread on this platform");
64void QPixmap::doInit(
int w,
int h,
int type)
190 if (
pixmap.paintingActive()) {
191 pixmap.copy().swap(*
this);
220#ifndef QT_NO_IMAGEFORMAT_XPM
229 if (!
image.isNull()) {
315 if (
isNull() || (dx == 0 && dy == 0))
327 if (!
data->scroll(dx, dy,
src)) {
353 qWarning(
"QPixmap::operator=: Cannot assign to pixmap during painting");
356 if (
pixmap.paintingActive()) {
357 pixmap.copy().swap(*
this);
417 return data->toImage();
550 qWarning(
"QPixmap::setMask: Cannot set mask while pixmap is being painted on");
555 qWarning(
"QPixmap::setMask() mask size differs from pixmap size");
584 return data->devicePixelRatio();
613 if (scaleFactor ==
data->devicePixelRatio())
617 data->setDevicePixelRatio(scaleFactor);
637#ifndef QT_NO_IMAGE_HEURISTIC_MASK
767 if (
len == 0 ||
buf ==
nullptr) {
812 return doImageIO(&writer, quality);
830 return doImageIO(&writer, quality);
835bool QPixmap::doImageIO(
QImageWriter *writer,
int quality)
const
837 if (quality > 100 || quality < -1)
838 qWarning(
"QPixmap::save: quality out of range [-1,100]");
862 qWarning(
"QPixmap::fill: Cannot fill while pixmap is being painted on");
866 if (
data->ref.loadRelaxed() == 1) {
874 d->resize(
data->width(),
data->height());
875 d->setDevicePixelRatio(
data->devicePixelRatio());
894 return data->cacheKey();
904 for (
int i = 0;
i < children.
size(); ++
i) {
916#if !defined(QT_NO_DATASTREAM)
945 if (
image.isNull()) {
947 }
else if (
image.depth() == 1) {
963 return data &&
data->ref.loadRelaxed() == 1;
1041 qWarning(
"QPixmap::scaled: Pixmap is a null pixmap");
1048 newSize.
scale(
s, aspectMode);
1051 if (newSize ==
size())
1079 qWarning(
"QPixmap::scaleWidth: Pixmap is a null pixmap");
1109 qWarning(
"QPixmap::scaleHeight: Pixmap is a null pixmap");
1326 return data &&
data->hasAlphaChannel();
1337 return data &&
data->hasAlphaChannel();
1353 return data ?
data->paintEngine() :
nullptr;
1385 return primary->
depth();
1386 qWarning(
"QPixmap: QGuiApplication must be created before calling defaultDepth().");
1421 if (
data->is_cached &&
data->ref.loadRelaxed() == 1)
1424 if (
data->ref.loadRelaxed() != 1) {
1451 qWarning(
"QPixmap::fromImage: QPixmap cannot be created without a QGuiApplication");
1478 qWarning(
"QPixmap::fromImageInPlace: QPixmap cannot be created without a QGuiApplication");
1502 qWarning(
"QPixmap::fromImageReader: QPixmap cannot be created without a QGuiApplication");
1507 data->fromImageReader(imageReader,
flags);
1519#ifndef QT_NO_DEBUG_STREAM
1529 dbg <<
r.size() <<
",depth=" <<
r.depth()
1530 <<
",devicePixelRatio=" <<
r.devicePixelRatio()
IOBluetoothDevice * device
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.
The QColor class provides colors based on RGB, HSV or CMYK values.
QRgb rgba() const noexcept
Returns the RGB value of the color, including its alpha.
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
qint64 toSecsSinceEpoch() const
\inmodule QtCore \reentrant
QDateTime lastModified() const
Returns the date and time when the file was last modified.
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
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.
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...
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const &
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
bool paintingActive() const
The QPainter class performs low-level painting on widgets and other paint devices.
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.
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...
int metric(PaintDeviceMetric) const override
int height() const
Returns the height of the pixmap.
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.
QPixmap scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
QPixmap()
Constructs a null pixmap.
QImage toImage() const
Converts the pixmap to a QImage.
QSizeF deviceIndependentSize() const
Returns the size of the pixmap in device independent pixels.
QPixmap scaledToWidth(int w, Qt::TransformationMode mode=Qt::FastTransformation) const
Returns a scaled copy of the image.
QBitmap createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode=Qt::MaskInColor) const
Creates and returns a mask for this pixmap based on the given maskColor.
static QPixmap fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags=Qt::AutoColor)
Create a QPixmap from an image read directly from an imageReader.
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.
QSize size() const
Returns the size of the pixmap.
bool load(const QString &fileName, const char *format=nullptr, Qt::ImageConversionFlags flags=Qt::AutoColor)
Loads a pixmap from the file with the given fileName.
void scroll(int dx, int dy, int x, int y, int width, int height, QRegion *exposed=nullptr)
int depth() const
Returns the depth of the pixmap.
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.
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.
static QPixmap fromImageInPlace(QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
QPlatformPixmap * handle() const
QBitmap createHeuristicMask(bool clipTight=true) const
Creates and returns a heuristic mask for this pixmap.
void detach()
Detaches the pixmap from shared pixmap data.
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...
void setMask(const QBitmap &)
Sets a mask bitmap.
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.
void setDevicePixelRatio(qreal scaleFactor)
Sets the device pixel ratio for the pixmap.
QRect rect() const
Returns the pixmap's enclosing rectangle.
QPixmap & operator=(const QPixmap &)
Assigns the given pixmap to this pixmap and returns a reference to this pixmap.
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
qreal devicePixelRatio() const
Returns the device pixel ratio for the pixmap.
int devType() const override
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.
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.
qint64 cacheKey() const
Returns a number that identifies this QPixmap.
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...
~QPixmap()
Destroys the pixmap.
bool isQBitmap() const
Returns true if this is a QBitmap; otherwise returns false.
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
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,...
The QRegion class specifies a clip region for a painter.
QRegion translated(int dx, int dy) const
The QResizeEvent class contains event parameters for resize events.
The QScreen class is used to query screen properties. \inmodule QtGui.
int depth
the color depth of the screen
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr int & rheight() noexcept
Returns a reference to the height.
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:
constexpr int & rwidth() noexcept
Returns a reference to the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QThread * currentThread()
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 >
Combined button and popup list for selecting options.
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
QTextStream & showbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::ShowBase) on stream and r...
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.
#define QT_WARNING_DISABLE_MSVC(number)
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
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei const GLchar * buf
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
static bool qt_pixmap_thread_test()
QDebug operator<<(QDebug dbg, const QPixmap &r)
#define QT_DEFINE_QESDP_SPECIALIZATION_DTOR(Class)
#define Q_TRACE_PARAM_REPLACE(in, out)
#define Q_TRACE_SCOPE(x,...)
#define Q_TRACE_INSTRUMENT(provider)
QFileInfo info(fileName)
[8]