56 #include <private/qapplication_p.h> 57 #include <private/qgraphicssystem_p.h> 58 #include <private/qwidget_p.h> 70 # include "private/qt_mac_p.h" 71 # include "private/qpixmap_mac_p.h" 80 # include <private/qt_x11_p.h> 81 # include <private/qpixmap_x11_p.h> 84 #if defined(Q_OS_SYMBIAN) 85 # include <private/qt_s60_p.h> 89 #include "private/qstylehelper_p.h" 102 qFatal(
"QPixmap: Must construct a QApplication before a QPaintDevice");
108 #if defined (Q_WS_X11) 111 #elif defined (Q_WS_QPA) 113 printf(
"Lighthouse plugin does not support threaded pixmaps!\n");
121 qWarning(
"QPixmap: It is not safe to use pixmaps outside the GUI thread");
130 init(w, h,
int(type));
138 qWarning(
"QPixmap: Cannot create a QPixmap when no GUI is being used");
246 init(0, 0, static_cast<QPixmapData::PixelType>(type));
294 load(fileName, format, flags);
332 #ifndef QT_NO_IMAGEFORMAT_XPM 436 if (
isNull() || (dx == 0 && dy == 0))
474 qWarning(
"QPixmap::operator=: Cannot assign to pixmap during painting");
478 *
this = pixmap.
copy();
717 void QPixmap::resize_helper(
const QSize &s)
721 if (w < 1 || h < 1) {
736 #if defined(Q_WS_X11) 742 #elif defined(Q_WS_MAC) 747 if (!uninit && !
isNull()) {
755 #if defined(Q_WS_X11) 759 ? static_cast<QX11PixmapData*>(newPd) : 0;
768 XFreeGC(
X11->display, gc);
825 qWarning(
"QPixmap::setMask: Cannot set mask while pixmap is being painted on");
830 qWarning(
"QPixmap::setMask() mask size differs from pixmap size");
837 if (static_cast<const QPixmap &>(mask).
data ==
data)
844 #ifndef QT_NO_IMAGE_HEURISTIC_MASK 951 if (tmp->
fromFile(fileName, format, flags)) {
981 if (len == 0 || buf == 0)
1049 if (quality > 100 || quality < -1)
1050 qWarning(
"QPixmap::save: quality out of range [-1,100]");
1088 qWarning(
"QPixmap::fill: Cannot fill while pixmap is being painted on");
1151 for (
int i = 0; i < children.
size(); ++i) {
1196 widget->d_func()->prepareToRender(
QRegion(),
1279 #if defined(Q_WS_X11) || defined(Q_WS_QWS) 1301 #if defined(Q_WS_X11) 1304 return static_cast<const QX11PixmapData*>(pd)->handle();
1312 static Qt::ImageConversionFlags colorModeToFlags(QPixmap::ColorMode mode)
1339 load(fileName,
format, colorModeToFlags(mode));
1387 return load(fileName,
format, colorModeToFlags(mode));
1407 *
this =
fromImage(image, colorModeToFlags(mode));
1416 #if !defined(QT_NO_DATASTREAM) 1432 return stream << pixmap.
toImage();
1451 if (image.isNull()) {
1453 }
else if (image.depth() == 1) {
1461 #endif // QT_NO_DATASTREAM 1465 const QPixmap *src,
int sx,
int sy,
int sw,
int sh)
1467 Q_ASSERT_X(dst,
"::copyBlt",
"Destination pixmap must be non-null");
1468 Q_ASSERT_X(src,
"::copyBlt",
"Source pixmap must be non-null");
1505 Q_ASSERT_X(
false,
"QPixmap::deref()",
"Do not call this function anymore!");
1606 qWarning(
"QPixmap::scaled: Pixmap is a null pixmap");
1613 newSize.
scale(s, aspectMode);
1616 if (newSize ==
size())
1645 qWarning(
"QPixmap::scaleWidth: Pixmap is a null pixmap");
1676 qWarning(
"QPixmap::scaleHeight: Pixmap is a null pixmap");
1940 #if defined(Q_WS_X11) 1946 #ifndef QT_NO_XRENDER 1947 if (x11Data->
picture && x11Data->
d == 32)
1950 if (x11Data->
d == 1 || x11Data->
x11_mask)
2001 if (alphaChannel.
isNull())
2005 qWarning(
"QPixmap::setAlphaChannel: " 2006 "Cannot set alpha channel while pixmap is being painted on");
2011 qWarning(
"QPixmap::setAlphaChannel: " 2012 "The pixmap and the alpha channel pixmap must have the same size");
2094 #if defined(Q_WS_QWS) 2096 #elif defined(Q_WS_X11) 2098 #elif defined(Q_WS_WINCE) 2100 #elif defined(Q_WS_WIN) 2102 #elif defined(Q_WS_MAC) 2104 #elif defined(Q_OS_SYMBIAN) 2105 return S60->screenDepth;
2106 #elif defined(Q_WS_QPA) 2145 #if defined(Q_WS_MAC) 2148 if (macData->cg_mask) {
2149 CGImageRelease(macData->cg_mask);
2150 macData->cg_mask = 0;
2160 #if defined(Q_WS_X11) 2167 XFreePixmap(
X11->display, d->
hd2);
2171 #elif defined(Q_WS_MAC) 2173 macData->macReleaseCGImageRef();
2174 macData->uninit =
false;
The QVariant class acts like a union for the most common Qt data types.
virtual QPixmapData * createCompatiblePixmapData() const
The QPainter class performs low-level painting on widgets and other paint devices.
QT_DEPRECATED int serialNumber() const
Returns a number that identifies the contents of this QPixmap object.
The QColor class provides colors based on RGB, HSV or CMYK values.
QPixmap scaledToHeight(int h, Qt::TransformationMode mode=Qt::FastTransformation) const
virtual bool fromFile(const QString &filename, const char *format, Qt::ImageConversionFlags flags)
QImage toImage() const
Converts the pixmap to a QImage.
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.
virtual QPixmap transformed(const QTransform &matrix, Qt::TransformationMode mode) const
static int defaultDepth()
Returns the default pixmap depth used by the application.
static QColormap instance(int screen=-1)
The QLatin1Literal class provides a thin wrapper around string literals used in source code...
QPixmap & operator=(const QPixmap &)
Assigns the given pixmap to this pixmap and returns a reference to this pixmap.
void setHeight(int h)
Sets the height of the rectangle to the given height.
QPixmap()
Constructs a null pixmap.
static mach_timebase_info_data_t info
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Q_GUI_EXPORT qint64 qt_pixmap_id(const QPixmap &pixmap)
static QMatrix trueMatrix(const QMatrix &m, int w, int h)
This convenience function loads the matrix m into a QTransform and calls the overloaded function with...
#define QT_END_NAMESPACE
This macro expands to.
QT_DEPRECATED void setAlphaChannel(const QPixmap &)
Sets the alpha channel of this pixmap to the given alphaChannel by converting the alphaChannel into 3...
QPixmap scaledToWidth(int w, Qt::TransformationMode mode=Qt::FastTransformation) const
Returns a scaled copy of the image.
int width() const
Returns the width of the pixmap.
QPointer< QWidget > widget
QSize size() const
Returns the size of the pixmap.
virtual QPixmapData * runtimeData() const
virtual void fill(const QColor &color)=0
The QMatrix class specifies 2D transformations of a coordinate system.
friend Q_GUI_EXPORT QDataStream & operator>>(QDataStream &, QPixmap &)
Reads an image from the given stream into the given pixmap.
void detach()
Detaches the pixmap from shared pixmap data.
static int appDepth(int screen=-1)
Returns the color depth (bits per pixel) used by the application on the given screen.
void setMask(const QBitmap &)
Sets a mask bitmap.
QExplicitlySharedDataPointer< QPixmapData > data
void init(int, int, Type=PixmapType)
bool isNull() const
Returns true if it is a null image, otherwise returns false.
T * take()
Returns the value of the pointer referenced by this object.
virtual void resize(int width, int height)=0
uint toTime_t() const
Returns the datetime as the number of seconds that have passed since 1970-01-01T00:00:00, Coordinated Universal Time (Qt::UTC).
QString completeSuffix() const
Returns the complete suffix of the file.
QDataStream & operator<<(QDataStream &stream, const QPixmap &pixmap)
Writes the given pixmap to the given stream as a PNG image.
QPixmap scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
void setQuality(int quality)
This is an image format specific function that sets the quality level of the image to quality...
int width() const
Returns the width of the rectangle.
QPixmap transformed(const QMatrix &, Qt::TransformationMode mode=Qt::FastTransformation) const
This convenience function loads the matrix into a QTransform and calls the overloaded function...
QString absoluteFilePath() const
Returns an absolute path including the file name.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool exists() const
Returns true if the file exists; otherwise returns false.
Qt::HANDLE handle() const
Returns the pixmap's handle to the device context.
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
virtual QPaintEngine * paintEngine() const =0
int depth() const
Returns the depth of the pixmap.
int height() const
Returns the height of the rectangle.
bool load(const QString &fileName, const char *format=0, Qt::ImageConversionFlags flags=Qt::AutoColor)
Loads a pixmap from the file with the given fileName.
The QString class provides a Unicode character string.
virtual QBitmap mask() const
virtual bool fromData(const uchar *buffer, uint len, const char *format, Qt::ImageConversionFlags flags)
QT_DEPRECATED QPixmap alphaChannel() const
Returns the alpha channel of the pixmap as a new grayscale QPixmap in which each pixel's red...
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
bool paintingActive() const
static QPixmap * find(const QString &key)
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
static bool qt_pixmap_thread_test()
PixelType pixelType() const
virtual QPixmap alphaChannel() const
The QBitmap class provides monochrome (1-bit depth) pixmaps.
virtual QImage toImage() const =0
int width() const
Returns the width.
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
T * data() const
Returns a pointer to the shared data object.
#define QT_BEGIN_NAMESPACE
This macro expands to.
~QPixmap()
Destroys the pixmap.
int metric(PaintDeviceMetric) const
static void sendResizeEvents(QWidget *target)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
The QImageWriter class provides a format independent interface for writing images to files or other d...
virtual void fromImage(const QImage &image, Qt::ImageConversionFlags flags)=0
QSize size() const
Returns the size of the rectangle.
const T & at(int i) const
Returns the item at index position i in the list.
void scroll(int dx, int dy, int x, int y, int width, int height, QRegion *exposed=0)
void detach()
If multiple images share common data, this image makes a copy of the data and detaches itself from th...
The QResizeEvent class contains event parameters for resize events.
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
bool isQBitmap() const
Returns true if this is a QBitmap; otherwise returns false.
static QScreen * instance()
Returns a pointer to the application's QScreen instance.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
virtual int metric(QPaintDevice::PaintDeviceMetric metric) const =0
The QRegion class specifies a clip region for a painter.
bool loadFromData(const uchar *buf, uint len, const char *format=0, Qt::ImageConversionFlags flags=Qt::AutoColor)
Loads a pixmap from the len first bytes of the given binary data.
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
static QString graphics_system_name
The QImageReader class provides a format independent interface for reading images from files or other...
virtual bool hasAlphaChannel() const =0
static void executePixmapDataModificationHooks(QPixmapData *)
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
static QPixmap fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags=Qt::AutoColor)
Create a QPixmap from an image read directly from an imageReader.
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Q_CORE_EXPORT void qFatal(const char *,...)
#define Q_ASSERT_X(cond, where, what)
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
qint64 size() const
Returns the file size in bytes.
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
QBitmap mask() const
Extracts a bitmap mask from the pixmap's alpha channel.
QBitmap createMaskFromColor(const QColor &maskColor) const
Creates and returns a mask for this pixmap based on the given maskColor.
ushort alpha
Returns the alpha color component of this color.
int y() const
Returns the y-coordinate of the rectangle's top edge.
bool doImageIO(QImageWriter *io, int quality) const
bool hasAlpha() const
Returns true if this pixmap has an alpha channel, or has a mask, otherwise returns false...
int x() const
Returns the x-coordinate of the rectangle's left edge.
QApplication::Type qt_appType
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
The QPoint class defines a point in the plane using integer precision.
int size() const
Returns the number of items in the list.
int & rheight()
Returns a reference to the height.
void setWidth(int w)
Sets the width of the rectangle to the given width.
virtual void copy(const QPixmapData *data, const QRect &rect)
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
static QPixmapData * create(int w, int h, PixelType type)
virtual void setMask(const QBitmap &mask)
const QObjectList & children() const
Returns a list of child objects.
qint64 cacheKey() const
Returns a number that identifies this QPixmap.
QRect rect() const
Returns the pixmap's enclosing rectangle.
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...
The QPixmap class is an off-screen image representation that can be used as a paint device...
void scale(int w, int h, Qt::AspectRatioMode mode)
Scales the size to a rectangle with the given width and height, according to the specified 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...
int height() const
Returns the height of the pixmap.
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 QSize class defines the size of a two-dimensional object using integer point precision.
virtual void setAlphaChannel(const QPixmap &alphaChannel)
The QDataStream class provides serialization of binary data to a QIODevice.
bool intersects(const QRect &r) const
Returns true if this rectangle intersects with the given rectangle (i.
virtual QPixmapData * createPixmapData(QPixmapData::PixelType type) const =0
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
QPaintEngine * paintEngine() const
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
static QGraphicsSystem * graphicsSystem()
QPixmap copy(int x, int y, int width, int height) const
Returns a deep copy of the subset of the pixmap that is specified by the rectangle QRect( x...
The QFileInfo class provides system-independent file information.
bool hasAlphaChannel() const
Returns true if the pixmap has a format that respects the alpha channel, otherwise returns false...
static QPixmapData * createDefaultPixmapData(QPixmapData::PixelType type)
The QIODevice class is the base interface class of all I/O devices in Qt.
QBitmap createHeuristicMask(bool clipTight=true) const
Creates and returns a heuristic mask for this pixmap.
bool write(const QImage &image)
Writes the image image to the assigned device or file name.
bool save(const QString &fileName, const char *format=0, int quality=-1) const
Saves the pixmap to the file with the given fileName using the specified image file format and qualit...
static QString fileName(const QString &fileUrl)
QImage createMaskFromColor(QRgb color, Qt::MaskMode mode=Qt::MaskInColor) const
Creates and returns a mask for this image based on the given color value.
virtual bool scroll(int dx, int dy, const QRect &rect)
static QPixmap grabWidget(QWidget *widget, const QRect &rect)
Creates a pixmap and paints the given widget, restricted by the given rectangle, in it...
static Display * display()
Returns the default display for the application.
static QMatrix trueMatrix(const QMatrix &, int w, int h)
Returns the actual matrix used for transforming an image with the given width, height and matrix...
virtual void fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags)
int & rwidth()
Returns a reference to the width.
int depth() const
Returns the depth of the framebuffer, in bits per pixel.
int screen() const
Returns the number of the screen currently in use.
bool hasFeature(PaintEngineFeatures feature) const
Returns true if the paint engine supports the specified feature; otherwise returns false...
QPixmapData * pixmapData() const
QDateTime lastModified() const
Returns the date and time when the file was last modified.