Qt 4.8
|
The QPixmap class is an off-screen image representation that can be used as a paint device. More...
#include <qpixmap.h>
Public Types | |
typedef QExplicitlySharedDataPointer< QPixmapData > | DataPtr |
enum | HBitmapFormat { NoAlpha, PremultipliedAlpha, Alpha } |
HBITMAP and QPixmap is performed. More... | |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric { PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM, PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY, PdmPhysicalDpiX, PdmPhysicalDpiY } |
Public Functions | |
QT_DEPRECATED QPixmap | alphaChannel () const |
Returns the alpha channel of the pixmap as a new grayscale QPixmap in which each pixel's red, green, and blue values are given the alpha value of the original pixmap. More... | |
qint64 | cacheKey () const |
Returns a number that identifies this QPixmap. More... | |
QRgb * | clut () const |
int | colorCount () const |
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. More... | |
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, y, width, height). More... | |
QPixmap | copy (const QRect &rect=QRect()) const |
Returns a deep copy of the subset of the pixmap that is specified by the given rectangle. More... | |
QBitmap | createHeuristicMask (bool clipTight=true) const |
Creates and returns a heuristic mask for this pixmap. More... | |
QBitmap | createMaskFromColor (const QColor &maskColor) const |
Creates and returns a mask for this pixmap based on the given maskColor. More... | |
QBitmap | createMaskFromColor (const QColor &maskColor, Qt::MaskMode mode) const |
Creates and returns a mask for this pixmap based on the given maskColor. More... | |
DataPtr & | data_ptr () |
int | depth () const |
Returns the depth of the pixmap. More... | |
void | detach () |
Detaches the pixmap from shared pixmap data. More... | |
int | devType () const |
void | fill (const QColor &fillColor=Qt::white) |
Fills the pixmap with the given color. More... | |
void | fill (const QWidget *widget, const QPoint &ofs) |
Fills the pixmap with the widget's background color or pixmap according to the given offset. More... | |
void | fill (const QWidget *widget, int xofs, int yofs) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the pixmap with the widget's background color or pixmap. More... | |
Qt::HANDLE | handle () const |
Returns the pixmap's handle to the device context. More... | |
bool | hasAlpha () const |
Returns true if this pixmap has an alpha channel, or has a mask, otherwise returns false. More... | |
bool | hasAlphaChannel () const |
Returns true if the pixmap has a format that respects the alpha channel, otherwise returns false. More... | |
int | height () const |
Returns the height of the pixmap. More... | |
bool | isDetached () const |
bool | isNull () const |
Returns true if this is a null pixmap; otherwise returns false. More... | |
bool | isQBitmap () const |
Returns true if this is a QBitmap; otherwise returns false. More... | |
bool | load (const QString &fileName, const char *format=0, Qt::ImageConversionFlags flags=Qt::AutoColor) |
Loads a pixmap from the file with the given fileName. More... | |
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. More... | |
bool | loadFromData (const QByteArray &data, const char *format=0, Qt::ImageConversionFlags flags=Qt::AutoColor) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Loads a pixmap from the binary data using the specified format and conversion flags. More... | |
QBitmap | mask () const |
Extracts a bitmap mask from the pixmap's alpha channel. More... | |
QT_DEPRECATED int | numCols () const |
operator QVariant () const | |
Returns the pixmap as a QVariant. More... | |
bool | operator! () const |
Returns true if this is a null pixmap; otherwise returns false. More... | |
QPixmap & | operator= (const QPixmap &) |
Assigns the given pixmap to this pixmap and returns a reference to this pixmap. More... | |
QPaintEngine * | paintEngine () const |
QPixmapData * | pixmapData () const |
QPixmap () | |
Constructs a null pixmap. More... | |
QPixmap (QPixmapData *data) | |
QPixmap (int w, int h) | |
Constructs a pixmap with the given width and height. More... | |
QPixmap (const QSize &) | |
Constructs a pixmap of the given size. More... | |
QPixmap (const QString &fileName, const char *format=0, Qt::ImageConversionFlags flags=Qt::AutoColor) | |
Constructs a pixmap from the file with the given fileName. More... | |
QPixmap (const char *const xpm[]) | |
Constructs a pixmap from the given xpm data, which must be a valid XPM image. More... | |
QPixmap (const QPixmap &) | |
Constructs a pixmap that is a copy of the given pixmap. More... | |
const uchar * | qwsBits () const |
int | qwsBytesPerLine () const |
QRect | rect () const |
Returns the pixmap's enclosing rectangle. More... | |
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 quality factor. More... | |
bool | save (QIODevice *device, const char *format=0, int quality=-1) const |
This function writes a QPixmap to the given device using the specified image file format and quality factor. More... | |
QPixmap | scaled (int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const |
QPixmap | scaled (const QSize &s, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const |
QPixmap | scaledToHeight (int h, Qt::TransformationMode mode=Qt::FastTransformation) const |
QPixmap | scaledToWidth (int w, Qt::TransformationMode mode=Qt::FastTransformation) const |
Returns a scaled copy of the image. More... | |
void | scroll (int dx, int dy, int x, int y, int width, int height, QRegion *exposed=0) |
void | scroll (int dx, int dy, const QRect &rect, QRegion *exposed=0) |
Scrolls the area rect of this pixmap by (dx, dy). More... | |
QT_DEPRECATED int | serialNumber () const |
Returns a number that identifies the contents of this QPixmap object. More... | |
QT_DEPRECATED void | setAlphaChannel (const QPixmap &) |
Sets the alpha channel of this pixmap to the given alphaChannel by converting the alphaChannel into 32 bit and using the intensity of the RGB pixel values. More... | |
void | setMask (const QBitmap &) |
Sets a mask bitmap. More... | |
QSize | size () const |
Returns the size of the pixmap. More... | |
void | swap (QPixmap &other) |
Swaps pixmap other with this pixmap. More... | |
QImage | toImage () const |
Converts the pixmap to a QImage. More... | |
CGImageRef | toMacCGImageRef () const |
Creates a CGImageRef equivalent to the QPixmap. More... | |
HBITMAP | toWinHBITMAP (HBitmapFormat format=NoAlpha) const |
It is the caller's responsibility to free the HBITMAP data after use. More... | |
HICON | toWinHICON () const |
Returns the HICON handle. More... | |
QPixmap | transformed (const QMatrix &, Qt::TransformationMode mode=Qt::FastTransformation) const |
This convenience function loads the matrix into a QTransform and calls the overloaded function. More... | |
QPixmap | transformed (const QTransform &, Qt::TransformationMode mode=Qt::FastTransformation) const |
Returns a copy of the pixmap that is transformed using the given transformation transform and transformation mode. More... | |
int | width () const |
Returns the width of the pixmap. More... | |
~QPixmap () | |
Destroys the pixmap. More... | |
Public Functions inherited from QPaintDevice | |
int | colorCount () const |
int | depth () const |
virtual HDC | getDC () const |
int | height () const |
int | heightMM () const |
int | logicalDpiX () const |
int | logicalDpiY () const |
QT_DEPRECATED int | numColors () const |
bool | paintingActive () const |
int | physicalDpiX () const |
int | physicalDpiY () const |
virtual void | releaseDC (HDC hdc) const |
int | width () const |
int | widthMM () const |
virtual | ~QPaintDevice () |
Static Public Functions | |
static int | defaultDepth () |
Returns the default pixmap depth used by the application. More... | |
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. More... | |
static QPixmap | fromImageReader (QImageReader *imageReader, Qt::ImageConversionFlags flags=Qt::AutoColor) |
Create a QPixmap from an image read directly from an imageReader. More... | |
static QPixmap | fromMacCGImageRef (CGImageRef image) |
Returns a QPixmap that is equivalent to the given image. More... | |
static QPixmap | fromWinHBITMAP (HBITMAP hbitmap, HBitmapFormat format=NoAlpha) |
Win32 only: Returns a QPixmap that is equivalent to the given bitmap. More... | |
static QPixmap | fromWinHICON (HICON hicon) |
static QPixmap | grabWidget (QWidget *widget, const QRect &rect) |
Creates a pixmap and paints the given widget, restricted by the given rectangle, in it. More... | |
static QPixmap | grabWidget (QWidget *widget, int x=0, int y=0, int w=-1, int h=-1) |
static QPixmap | grabWindow (WId, int x=0, int y=0, int w=-1, int h=-1) |
Creates and returns a pixmap constructed by grabbing the contents of the given window restricted by QRect(x, y, width, height). More... | |
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 the QTransform and the width w and the height h. More... | |
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. More... | |
Static Public Functions inherited from QPaintDevice | |
static QWSDisplay * | qwsDisplay () |
Protected Functions | |
int | metric (PaintDeviceMetric) const |
Protected Functions inherited from QPaintDevice | |
QPaintDevice () | |
Private Types | |
enum | Type { PixmapType, BitmapType } |
Private Functions | |
void | deref () |
bool | doImageIO (QImageWriter *io, int quality) const |
void | init (int, int, Type=PixmapType) |
void | init (int, int, int) |
void | initAlphaPixmap (uchar *bytes, int length, struct tagBITMAPINFO *bmi) |
QPixmap (const QSize &s, Type) | |
QPixmap (const QSize &s, int type) | |
Properties | |
QExplicitlySharedDataPointer< QPixmapData > | data |
Friends | |
Q_GUI_EXPORT QDataStream & | operator>> (QDataStream &, QPixmap &) |
Reads an image from the given stream into the given pixmap. More... | |
class | QBitmap |
class | QCoreGraphicsPaintEngine |
class | QGLWidget |
class | QMacPixmapData |
class | QPaintDevice |
class | QPainter |
class | QPixmapData |
class | QRasterBuffer |
class | QSymbianRasterPixmapData |
CGContextRef | qt_mac_cg_context (const QPaintDevice *) |
Returns the CoreGraphics CGContextRef of the paint device. More... | |
IconRef | qt_mac_create_iconref (const QPixmap &) |
CGImageRef | qt_mac_create_imagemask (const QPixmap &, const QRectF &) |
quint32 * | qt_mac_pixmap_get_base (const QPixmap *) |
int | qt_mac_pixmap_get_bytes_per_line (const QPixmap *) |
Q_GUI_EXPORT qint64 | qt_pixmap_id (const QPixmap &pixmap) |
class | QWidgetPrivate |
class | QX11PaintEngine |
class | QX11PixmapData |
Related Functions | |
(Note that these are not member functions.) | |
QDataStream & | operator<< (QDataStream &stream, const QPixmap &pixmap) |
Writes the given pixmap to the given stream as a PNG image. More... | |
Related Functions inherited from QPaintDevice | |
const Q_GUI_EXPORT QX11Info * | qt_x11Info (const QPaintDevice *pd) |
Returns the QX11Info structure for the pd paint device. More... | |
Additional Inherited Members | |
Protected Variables inherited from QPaintDevice | |
ushort | painters |
The QPixmap class is an off-screen image representation that can be used as a paint device.
Qt provides four classes for handling image data: QImage, QPixmap, QBitmap and QPicture. QImage is designed and optimized for I/O, and for direct pixel access and manipulation, while QPixmap is designed and optimized for showing images on screen. QBitmap is only a convenience class that inherits QPixmap, ensuring a depth of 1. The isQBitmap() function returns true if a QPixmap object is really a bitmap, otherwise returns false. Finally, the QPicture class is a paint device that records and replays QPainter commands.
A QPixmap can easily be displayed on the screen using QLabel or one of QAbstractButton's subclasses (such as QPushButton and QToolButton). QLabel has a pixmap property, whereas QAbstractButton has an icon property.
In addition to the ordinary constructors, a QPixmap can be constructed using the static grabWidget() and grabWindow() functions which creates a QPixmap and paints the given widget, or window, into it.
QPixmap objects can be passed around by value since the QPixmap class uses implicit data sharing. For more information, see the Implicit Data Sharing documentation. QPixmap objects can also be streamed.
Note that the pixel data in a pixmap is internal and is managed by the underlying window system. Because QPixmap is a QPaintDevice subclass, QPainter can be used to draw directly onto pixmaps. Pixels can only be accessed through QPainter functions or by converting the QPixmap to a QImage. However, the fill() function is available for initializing the entire pixmap with a given color.
There are functions to convert between QImage and QPixmap. Typically, the QImage class is used to load an image file, optionally manipulating the image data, before the QImage object is converted into a QPixmap to be shown on screen. Alternatively, if no manipulation is desired, the image file can be loaded directly into a QPixmap. On Windows, the QPixmap class also supports conversion between HBITMAP
and QPixmap. On Symbian, the QPixmap class also supports conversion between CFbsBitmap and QPixmap.
QPixmap provides a collection of functions that can be used to obtain a variety of information about the pixmap. In addition, there are several functions that enables transformation of the pixmap.
QPixmap provides several ways of reading an image file: The file can be loaded when constructing the QPixmap object, or by using the load() or loadFromData() functions later on. When loading an image, the file name can either refer to an actual file on disk or to one of the application's embedded resources. See The Qt Resource System overview for details on how to embed images and other resource files in the application's executable.
Simply call the save() function to save a QPixmap object.
The complete list of supported file formats are available through the QImageReader::supportedImageFormats() and QImageWriter::supportedImageFormats() functions. New file formats can be added as plugins. By default, Qt supports the following formats:
Format | Description | Qt's support |
BMP | Windows Bitmap | Read/write |
GIF | Graphic Interchange Format (optional) | Read |
JPG | Joint Photographic Experts Group | Read/write |
JPEG | Joint Photographic Experts Group | Read/write |
PNG | Portable Network Graphics | Read/write |
PBM | Portable Bitmap | Read |
PGM | Portable Graymap | Read |
PPM | Portable Pixmap | Read/write |
XBM | X11 Bitmap | Read/write |
XPM | X11 Pixmap | Read/write |
QPixmap provides a collection of functions that can be used to obtain a variety of information about the pixmap:
Available Functions | |
Geometry | The size(), width() and height() functions provide information about the pixmap's size. The rect() function returns the image's enclosing rectangle. |
Alpha component | The hasAlphaChannel() returns true if the pixmap has a format that respects the alpha channel, otherwise returns false. The hasAlpha(), setMask() and mask() functions are legacy and should not be used. They are potentially very slow. The createHeuristicMask() function creates and returns a 1-bpp heuristic mask (i.e. a QBitmap) for this pixmap. It works by selecting a color from one of the corners and then chipping away pixels of that color, starting at all the edges. The createMaskFromColor() function creates and returns a mask (i.e. a QBitmap) for the pixmap based on a given color. |
Low-level information | The depth() function returns the depth of the pixmap. The defaultDepth() function returns the default depth, i.e. the depth used by the application on the given screen. The cacheKey() function returns a number that uniquely identifies the contents of the QPixmap object. The x11Info() function returns information about the configuration of the X display used by the screen to which the pixmap currently belongs. The x11PictureHandle() function returns the X11 Picture handle of the pixmap for XRender support. Note that the two latter functions are only available on x11. |
A QPixmap object can be converted into a QImage using the toImage() function. Likewise, a QImage can be converted into a QPixmap using the fromImage(). If this is too expensive an operation, you can use QBitmap::fromImage() instead.
In addition, on Windows, the QPixmap class supports conversion to and from HBITMAP: the toWinHBITMAP() function creates a HBITMAP equivalent to the QPixmap, based on the given HBitmapFormat, and returns the HBITMAP handle. The fromWinHBITMAP() function returns a QPixmap that is equivalent to the given bitmap which has the specified format. The QPixmap class also supports conversion to and from HICON: the toWinHICON() function creates a HICON equivalent to the QPixmap, and returns the HICON handle. The fromWinHICON() function returns a QPixmap that is equivalent to the given icon.
In addition, on Symbian, the QPixmap class supports conversion to and from CFbsBitmap: the toSymbianCFbsBitmap() function creates CFbsBitmap equivalent to the QPixmap, based on given mode and returns a CFbsBitmap object. The fromSymbianCFbsBitmap() function returns a QPixmap that is equivalent to the given bitmap and given mode.
QPixmap supports a number of functions for creating a new pixmap that is a transformed version of the original:
The scaled(), scaledToWidth() and scaledToHeight() functions return scaled copies of the pixmap, while the copy() function creates a QPixmap that is a plain copy of the original one.
The transformed() function returns a copy of the pixmap that is transformed with the given transformation matrix and transformation mode: Internally, the transformation matrix is adjusted to compensate for unwanted translation, i.e. transformed() returns the smallest pixmap containing all transformed points of the original pixmap. The static trueMatrix() function returns the actual matrix used for transforming the pixmap.
HBITMAP and QPixmap is performed.
Win32 only: This enum defines how the conversion between
HBITMAP
is used with standard GDI calls, such as BitBlt()
.HBITMAP
is treated as having an alpha channel and premultiplied colors. This is preferred if the HBITMAP
is accessed through the AlphaBlend()
GDI function.HBITMAP
is treated as having a plain alpha channel. This is the preferred format if the HBITMAP
is going to be used as an application icon or systray icon.Enumerator | |
---|---|
NoAlpha | |
PremultipliedAlpha | |
Alpha |
|
private |
Enumerator | |
---|---|
PixmapType | |
BitmapType |
Definition at line 257 of file qpixmap.h.
QPixmap::QPixmap | ( | ) |
Constructs a null pixmap.
Definition at line 174 of file qpixmap.cpp.
Referenced by alphaChannel(), copy(), depth(), QBitmap::fromImage(), fromImage(), fromImageReader(), fromWinHBITMAP(), fromWinHICON(), grabWidget(), handle(), scaled(), scaledToHeight(), scaledToWidth(), and toWinHBITMAP().
|
explicit |
Definition at line 254 of file qpixmap.cpp.
QPixmap::QPixmap | ( | int | width, |
int | height | ||
) |
Constructs a pixmap with the given width and height.
If either width or height is zero, a null pixmap is constructed.
Definition at line 198 of file qpixmap.cpp.
QPixmap::QPixmap | ( | const QSize & | size | ) |
Constructs a pixmap of the given size.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 220 of file qpixmap.cpp.
QPixmap::QPixmap | ( | const QString & | fileName, |
const char * | format = 0 , |
||
Qt::ImageConversionFlags | flags = Qt::AutoColor |
||
) |
Constructs a pixmap from the file with the given fileName.
If the file does not exist or is of an unknown format, the pixmap becomes a null pixmap.
The loader attempts to read the pixmap using the specified format. If the format is not specified (which is the default), the loader probes the file for a header to guess the file format.
The file name can either refer to an actual file on disk or to one of the application's embedded resources. See the Resource System overview for details on how to embed images and other resource files in the application's executable.
If the image needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the flags to control the conversion.
The fileName, format and flags parameters are passed on to load(). This means that the data in fileName is not compiled into the binary. If fileName contains a relative path (e.g. the filename only) the relevant file must be found relative to the runtime working directory.
Definition at line 287 of file qpixmap.cpp.
QPixmap::QPixmap | ( | const char *const | xpm[] | ) |
Constructs a pixmap from the given xpm data, which must be a valid XPM image.
Errors are silently ignored.
Note that it's possible to squeeze the XPM variable a little bit by using an unusual declaration:
The extra const
makes the entire definition read-only, which is slightly more efficient (for example, when the code is in a shared library) and ROMable when the application is to be stored in ROM.
Definition at line 333 of file qpixmap.cpp.
QPixmap::QPixmap | ( | const QPixmap & | pixmap | ) |
Constructs a pixmap that is a copy of the given pixmap.
Definition at line 303 of file qpixmap.cpp.
QPixmap::~QPixmap | ( | ) |
Definition at line 232 of file qpixmap.cpp.
|
private |
Definition at line 243 of file qpixmap.cpp.
QPixmap QPixmap::alphaChannel | ( | ) | const |
Returns the alpha channel of the pixmap as a new grayscale QPixmap in which each pixel's red, green, and blue values are given the alpha value of the original pixmap.
The color depth of the returned pixmap is the system depth on X11 and 8-bit on Windows and Mac OS X.
You can use this function while debugging to get a visible image of the alpha channel. If the pixmap doesn't have an alpha channel, i.e., the alpha channel's value for all pixels equals 0xff), a null pixmap is returned. You can check this with the isNull()
function.
We show an example:
Definition at line 2051 of file qpixmap.cpp.
qint64 QPixmap::cacheKey | ( | ) | const |
Returns a number that identifies this QPixmap.
Distinct QPixmap objects can only have the same cache key if they refer to the same contents.
The cacheKey() will change when the pixmap is altered.
Definition at line 1136 of file qpixmap.cpp.
Referenced by QPdfEngine::drawPixmap(), QTextHtmlExporter::emitBackgroundAttribute(), QGLBlurTextureCache::insertBlurTextureInfo(), operator<<(), QBrush::operator==(), QPixmapIconEngine::pixmap(), qBrushDark(), qBrushLight(), qBrushSetAlphaF(), qDrawPlainRect(), qt_mac_fill_background(), qt_pixmap_id(), QLabel::setPixmap(), and QGLBlurTextureCache::takeBlurTextureInfo().
QRgb * QPixmap::clut | ( | ) | const |
Definition at line 115 of file qpixmap_qws.cpp.
int QPixmap::colorCount | ( | ) | const |
Definition at line 130 of file qpixmap_qws.cpp.
Referenced by numCols().
bool QPixmap::convertFromImage | ( | const QImage & | image, |
Qt::ImageConversionFlags | flags = Qt::AutoColor |
||
) |
Replaces this pixmap's data with the given image using the specified flags to control the conversion.
The flags argument is a bitwise-OR of the Qt::ImageConversionFlags. Passing 0 for flags sets all the default options. Returns true if the result is that this pixmap is not null.
Note: this function was part of Qt 3 support in Qt 4.6 and earlier. It has been promoted to official API status in 4.7 to support updating the pixmap's image without creating a new QPixmap as fromImage() would.
Definition at line 1531 of file qpixmap.cpp.
Referenced by handle().
|
inline |
Returns a deep copy of the subset of the pixmap that is specified by the rectangle QRect( x, y, width, height).
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 302 of file qpixmap.h.
Referenced by detach(), QPixmapBlurFilter::draw(), QPixmapColorizeFilter::draw(), QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QPSPrintEngine::drawPixmap(), QWin32PrintEngine::drawPixmap(), QPdfEngine::drawPixmap(), QPainter::drawPixmap(), QOpenGLPaintEngine::drawTiledPixmap(), operator=(), QPixmap(), scaledToHeight(), and scaledToWidth().
Returns a deep copy of the subset of the pixmap that is specified by the given rectangle.
For more information on deep copies, see the Implicit Data Sharing documentation.
If the given rectangle is empty, the whole image is copied.
Definition at line 394 of file qpixmap.cpp.
QBitmap QPixmap::createHeuristicMask | ( | bool | clipTight = true | ) | const |
Creates and returns a heuristic mask for this pixmap.
The function works by selecting a color from one of the corners and then chipping away pixels of that color, starting at all the edges. If clipTight is true (the default) the mask is just large enough to cover the pixels; otherwise, the mask is larger than the data pixels.
The mask may not be perfect but it should be reasonable, so you can do things such as the following:
This function is slow because it involves converting to/from a QImage, and non-trivial computations.
Definition at line 864 of file qpixmap.cpp.
Referenced by isServerProcess(), qDrawPlainRect(), and QGraphicsPixmapItemPrivate::updateShape().
Creates and returns a mask for this pixmap based on the given maskColor.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Same as calling createMaskFromColor(maskColor, Qt::MaskInColor)
Definition at line 899 of file qpixmap.cpp.
QBitmap QPixmap::createMaskFromColor | ( | const QColor & | maskColor, |
Qt::MaskMode | mode | ||
) | const |
Creates and returns a mask for this pixmap based on the given maskColor.
If the mode is Qt::MaskInColor, all pixels matching the maskColor will be transparent. If mode is Qt::MaskOutColor, all pixels matching the maskColor will be opaque.
This function is slow because it involves converting to/from a QImage.
Definition at line 882 of file qpixmap.cpp.
|
inline |
Definition at line 297 of file qpixmap.h.
Referenced by QX11WindowSurface::beginPaint(), QGLContextPrivate::bindTextureFromNativePixmap(), QX11GLWindowSurface::flush(), QMeeGoGraphicsSystem::getLiveTextureHandle(), QMeeGoLivePixmapData::getSurfaceForBackingPixmap(), QMeeGoLivePixmapData::invalidateSurfaces(), QMeeGoGraphicsSystem::lockLiveTexture(), qt_toRasterPixmap(), qt_toX11Pixmap(), QMeeGoGraphicsSystem::releaseLiveTexture(), and QX11GLWindowSurface::scroll().
|
static |
Returns the default pixmap depth used by the application.
On Windows and Mac, the default depth is always 32. On X11 and embedded, the depth of the screen will be returned by this function.
Definition at line 2092 of file qpixmap.cpp.
Referenced by QMacPixmapData::fromImage().
int QPixmap::depth | ( | ) | const |
Returns the depth of the pixmap.
The pixmap depth is also called bits per pixel (bpp) or bit planes of a pixmap. A null pixmap has depth 0.
Definition at line 695 of file qpixmap.cpp.
Referenced by QPainter::begin(), QX11WindowSurface::beginPaint(), QCoreGraphicsPaintEngine::drawPixmap(), QOpenGLPaintEngine::drawPixmap(), QRasterPaintEngine::drawPixmap(), QPdfEngine::drawTiledPixmap(), QX11PaintEngine::drawTiledPixmap(), QOpenGLPaintEngine::drawTiledPixmap(), QPaintEngine::drawTiledPixmap(), QX11PaintEnginePrivate::fillPolygon_dev(), QPixmapCache::insert(), QMeeGoLivePixmapData::lock(), QBitmap::operator=(), QGLOverlayWidget::paintGL(), QCursor::QCursor(), qDrawPlainRect(), qt_mac_draw_pattern(), QPixmapCache::replace(), QCursorData::setBitmap(), toWinHBITMAP(), QPainterPrivate::updateEmulationSpecifier(), and QX11Data::xdndMimeDataForAtom().
|
private |
Definition at line 1503 of file qpixmap.cpp.
void QPixmap::detach | ( | ) |
Detaches the pixmap from shared pixmap data.
A pixmap is automatically detached by Qt whenever its contents are about to change. This is done in almost all QPixmap member functions that modify the pixmap (fill(), fromImage(), load(), etc.), and in QPainter::begin() on a pixmap.
There are two exceptions in which detach() must be called explicitly, that is when calling the handle() or the x11PictureHandle() function (only available on X11). Otherwise, any modifications done using system calls, will be performed on the shared data.
The detach() function returns immediately if there is just a single reference or if the pixmap has not been initialized yet.
Definition at line 2128 of file qpixmap.cpp.
Referenced by fill(), scroll(), setAlphaChannel(), and setMask().
|
virtual |
Reimplemented from QPaintDevice.
Definition at line 363 of file qpixmap.cpp.
|
private |
Definition at line 1047 of file qpixmap.cpp.
Referenced by save().
Fills the pixmap with the given color.
The effect of this function is undefined when the pixmap is being painted on.
Definition at line 1080 of file qpixmap.cpp.
Referenced by _q_paintIntoCache(), QX11PixmapData::alphaChannel(), QBalloonTip::balloon(), QBitmap::clear(), create32BitCursor(), QOleDropSource::createCursors(), QItemDelegate::decoration(), depth(), QMacStylePrivate::drawColorlessButton(), QMacStylePrivate::drawCombobox(), QPlastiqueStyle::drawComplexControl(), QCleanlooksStyle::drawComplexControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QGtkStyle::drawControl(), QMacStyle::drawControl(), QGraphicsScenePrivate::drawItemHelper(), QDeclarativeTextPrivate::drawOutline(), QOpenGLPaintEngine::drawPixmap(), QWindowsVistaStyle::drawPrimitive(), QPlastiqueStyle::drawPrimitive(), QMacStylePrivate::drawTableHeader(), QX11PaintEngine::drawTiledPixmap(), QOpenGLPaintEngine::drawTiledPixmap(), QPaintEngine::drawTiledPixmap(), fromMacCGImageRef(), QComboMenuDelegate::getStyleOption(), grabWidget(), QStyledItemDelegate::initStyleOption(), QColorWell::mouseMoveEvent(), QColorShowLabel::mouseMoveEvent(), QDeclarativePaintedItem::paint(), QAxHostWidget::paintEvent(), QGraphicsItemEffectSourcePrivate::pixmap(), QWidgetEffectSourcePrivate::pixmap(), QMacStyle::polish(), QCursor::QCursor(), qt_mac_convert_iconref(), qt_mac_draw_pattern(), QWidgetPrivate::render_helper(), QAbstractItemViewPrivate::renderToPixmap(), QTreeViewPrivate::renderTreeToPixmapForAnimation(), QX11GLWindowSurface::setGeometry(), QTabBarPrivate::setupMovableTab(), QHeaderViewPrivate::setupSectionIndicator(), QWorkspacePrivate::showMaximizeControls(), QWindowsVistaStyle::standardIconImplementation(), QMacStyle::standardIconImplementation(), QMacStyle::styleHint(), QDeclarativeTextPrivate::textDocumentImage(), QDeclarativeTextPrivate::textLayoutImage(), toWinHICON(), QX11PixmapData::transformed(), and QCursorData::update().
Fills the pixmap with the widget's background color or pixmap according to the given offset.
The QPoint offset defines a point in widget coordinates to which the pixmap's top-left pixel will be mapped to. This is only significant if the widget has a background pixmap; otherwise the pixmap will simply be filled with the background color of the widget.
Definition at line 2385 of file qwidget.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the pixmap with the widget's background color or pixmap.
The given point, (x, y), defines an offset in widget coordinates to which the pixmap's top-left pixel will be mapped to.
Definition at line 107 of file qpixmap.h.
Referenced by fill().
|
static |
Converts the given image to a pixmap using the specified flags to control the conversion.
The flags argument is a bitwise-OR of the Qt::ImageConversionFlags. Passing 0 for flags sets all the default options.
In case of monochrome and 8-bit images, the image is first converted to a 32-bit pixmap and then filled with the colors in the color table. If this is too expensive an operation, you can use QBitmap::fromImage() instead.
Definition at line 2197 of file qpixmap.cpp.
Referenced by QX11PixmapData::alphaChannel(), QPixmapData::alphaChannel(), QDirectFBCursor::changeCursor(), QBitmap::clear(), convert(), convertFromImage(), createPixmapDataSync(), darkenPixmap(), QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QMacStylePrivate::drawColorlessButton(), QWindowsVistaStyle::drawControl(), QCommonStyle::drawControl(), QWindowsStyle::drawControl(), QMotifStyle::drawControl(), QPaintEngine::drawImage(), QWindowsStyle::drawPrimitive(), QDeclarativePixmapReply::event(), fromWinHBITMAP(), fromWinHICON(), QWindowsMobileStyle::generatedIconPixmap(), QCommonStyle::generatedIconPixmap(), QMacStyle::generatedIconPixmap(), QGtkPainter::getIcon(), getPixmap(), QWindowSurface::grabWidget(), QXlibIntegration::grabWindow(), QVNCIntegration::grabWindow(), handle(), QPainterState::init(), QStyledItemDelegate::initStyleOption(), isServerProcess(), QMoviePrivate::next(), QLabel::paintEvent(), QColorLuminancePicker::paintEvent(), QSvgIconEngine::pixmap(), QTexturedBrushData::pixmap(), qBrushDark(), qBrushLight(), qBrushSetAlphaF(), QPixmap(), QAlphaWidget::render(), QGtkPainter::renderTheme(), QColorPicker::resizeEvent(), QAlphaWidget::run(), QItemDelegate::selected(), QWSServer::setBackground(), QCursor::setPos(), QCommonStyle::standardPixmap(), QWindowsMobileStyle::standardPixmap(), QMotifStyle::standardPixmap(), QGtkStyle::standardPixmap(), toWinHICON(), QX11PixmapData::transformed(), QPixmapData::transformed(), and QX11Data::xdndMimeDataForAtom().
|
static |
Create a QPixmap from an image read directly from an imageReader.
The flags argument is a bitwise-OR of the Qt::ImageConversionFlags. Passing 0 for flags sets all the default options.
On some systems, reading an image directly to QPixmap can use less memory than reading a QImage to convert it to QPixmap.
Definition at line 2221 of file qpixmap.cpp.
|
static |
Returns a QPixmap that is equivalent to the given image.
Definition at line 1271 of file qpixmap_mac.cpp.
Referenced by QMacPasteboardMimeHTMLText::convertFromMime(), QMacPasteboardMimeTiff::convertToMime(), QWizardPrivate::findDefaultBackgroundPixmap(), qt_mac_grabDisplayRect(), and qt_mac_grabScreenRect().
|
static |
Win32 only: Returns a QPixmap that is equivalent to the given bitmap.
The conversion is based on the specified format.
Definition at line 179 of file qpixmap_win.cpp.
Referenced by QGLContext::choosePixelFormat(), IPictureToQPixmap(), and QAxHostWidget::paintEvent().
|
static |
Win32 only: Returns a QPixmap that is equivalent to the given icon.
Definition at line 386 of file qpixmap_win.cpp.
Referenced by QFileIconProviderPrivate::getWinIcon(), loadIconFromShell32(), QWindowsStyle::standardIconImplementation(), QWindowsStyle::standardPixmap(), and toWinHICON().
Creates a pixmap and paints the given widget, restricted by the given rectangle, in it.
If the widget has any children, then they are also painted in the appropriate positions.
If no rectangle is specified (the default) the entire widget is painted.
If widget is 0, the specified rectangle doesn't overlap the widget's rectangle, or an error occurs, the function will return a null QPixmap. If the rectangle is a superset of the given widget, the areas outside the widget are covered with the widget's background.
This function actually asks widget to paint itself (and its children to paint themselves) by calling paintEvent() with painter redirection turned on. But QPixmap also provides the grabWindow() function which is a bit faster by grabbing pixels directly off the screen. In addition, if there are overlaying windows, grabWindow(), unlike grabWidget(), will see them.
Definition at line 1188 of file qpixmap.cpp.
Referenced by QAxServerBase::Draw(), QRollEffect::QRollEffect(), and QAlphaWidget::run().
|
inlinestatic |
Definition at line 128 of file qpixmap.h.
Creates and returns a pixmap constructed by grabbing the contents of the given window restricted by QRect(x, y, width, height).
The arguments ({x}, {y}) specify the offset in the window, whereas ({width}, {height}) specify the area to be copied. If width is negative, the function copies everything to the right border of the window. If height is negative, the function copies everything to the bottom of the window.
The window system identifier (WId
) can be retrieved using the QWidget::winId() function. The rationale for using a window identifier and not a QWidget, is to enable grabbing of windows that are not part of the application, window system frames, and so on.
The grabWindow() function grabs pixels from the screen, not from the window, i.e. if there is another window partially or entirely over the one you grab, you get pixels from the overlying window, too. The mouse cursor is generally not grabbed.
Note on X11 that if the given window doesn't have the same depth as the root window, and another window partially or entirely obscures the one you grab, you will not get pixels from the overlying window. The contents of the obscured areas in the pixmap will be undefined and uninitialized.
On Windows Vista and above grabbing a layered window, which is created by setting the Qt::WA_TranslucentBackground attribute, will not work. Instead grabbing the desktop widget should work.
Definition at line 972 of file qpixmap_mac.cpp.
Referenced by QWindowsVistaStyle::drawComplexControl(), QAlphaWidget::run(), QWhatsThat::showEvent(), and QX11PixmapData::transformed().
Qt::HANDLE QPixmap::handle | ( | ) | const |
Returns the pixmap's handle to the device context.
Note that, since QPixmap make use of Implicit {Data Sharing}{implicit data sharing}, the detach() function must be called explicitly to ensure that only this pixmap's data is modified if the pixmap data is shared.
Definition at line 1299 of file qpixmap.cpp.
Referenced by QX11PixmapData::bitmap_to_mask(), QX11PaintEngine::drawPixmap(), QX11PaintEngine::drawTiledPixmap(), QX11GLWindowSurface::flush(), QX11WindowSurface::flush(), QRasterWindowSurface::flush(), QX11GLWindowSurface::grabWidget(), QX11WindowSurface::grabWidget(), QMeeGoLivePixmapData::handle(), QMeeGoLivePixmapData::initializeThroughEGLImage(), QX11PixmapData::mask_to_bitmap(), menuItemEntry(), QGLOverlayWidget::paintGL(), QCursor::QCursor(), qstring_to_xtp(), QX11GLWindowSurface::scroll(), QX11WindowSurface::scroll(), QX11WindowSurface::setGeometry(), QX11PixmapData::setMask(), QX11PixmapData::transformed(), QX11PaintEngine::updateBrush(), and QX11Data::xdndMimeDataForAtom().
bool QPixmap::hasAlpha | ( | ) | const |
Returns true if this pixmap has an alpha channel, or has a mask, otherwise returns false.
Definition at line 1938 of file qpixmap.cpp.
Referenced by QAlphaPaintEngine::drawPixmap(), QGL2PaintEngineEx::drawPixmap(), QGL2PaintEngineExPrivate::drawPixmapFragments(), QAlphaPaintEngine::drawTiledPixmap(), QX11PaintEngine::drawTiledPixmap(), QX11PaintEnginePrivate::fillPolygon_dev(), QStyleSheetBorderData::isOpaque(), QSplashScreen::setPixmap(), and QPainterPrivate::updateEmulationSpecifier().
bool QPixmap::hasAlphaChannel | ( | ) | const |
Returns true if the pixmap has a format that respects the alpha channel, otherwise returns false.
Definition at line 1965 of file qpixmap.cpp.
Referenced by CapabilitiesToStateMask::canBlitterDrawPixmap(), depth(), QDirectFBPaintEngine::drawPixmap(), QPaintEngine::drawTiledPixmap(), fill(), QMeeGoLivePixmapData::initializeThroughEGLImage(), QBrush::isOpaque(), and qDrawPlainRect().
int QPixmap::height | ( | ) | const |
Returns the height of the pixmap.
Definition at line 645 of file qpixmap.cpp.
Referenced by QX11WindowSurface::beginPaint(), QX11PixmapData::bitmap_to_mask(), copy(), QXlibCursor::createCursorBitmap(), QOleDropSource::createCursors(), QWSDisplay::defineCursor(), depth(), QDragManager::drag(), QAxServerBase::Draw(), QTreeViewPrivate::drawAnimatedOperation(), QRenderRule::drawBackgroundImage(), QMacStylePrivate::drawCombobox(), QCommonStyle::drawControl(), QWindowsCEStyle::drawControl(), QWindowsVistaStyle::drawControl(), QPlastiqueStyle::drawControl(), QWindowsMobileStyle::drawControl(), QCleanlooksStyle::drawControl(), QWindowsXPStyle::drawControl(), QWindowsStyle::drawControl(), QGtkStyle::drawControl(), QMotifStyle::drawControl(), QMacStyle::drawControl(), QStyleSheetStyle::drawControl(), QDeclarativeTextPrivate::drawOutline(), QWin32PrintEngine::drawPixmap(), QCoreGraphicsPaintEngine::drawPixmap(), QGL2PaintEngineEx::drawPixmap(), QOpenGLPaintEngine::drawPixmap(), QPainter::drawPixmap(), QMacStylePrivate::drawTableHeader(), drawTextItemDecoration(), QPSPrintEngine::drawTiledPixmap(), QWin32PrintEngine::drawTiledPixmap(), QX11PaintEngine::drawTiledPixmap(), QOpenGLPaintEngine::drawTiledPixmap(), QPaintEngine::drawTiledPixmap(), QPainter::drawTiledPixmap(), QBlitterPaintEngine::fillRect(), QMacStylePrivate::generateBackgroundPattern(), getPixmapSize(), QDeclarativePixmap::height(), QMeeGoLivePixmapData::initializeThroughEGLImage(), QPixmapCache::insert(), QGLBlurTextureCache::insertBlurTextureInfo(), QStyle::itemPixmapRect(), QX11PixmapData::mask_to_bitmap(), menuItemEntry(), QColorWell::mouseMoveEvent(), QColorShowLabel::mouseMoveEvent(), QAxHostWidget::paintEvent(), QWizard::paintEvent(), QColorLuminancePicker::paintEvent(), QGLOverlayWidget::paintGL(), QMacStyle::polish(), QCursor::QCursor(), qDrawPlainRect(), qt_draw_tile(), qt_fill_tile(), qt_mac_cg_context(), qt_mac_draw_pattern(), QPixmapCache::replace(), scaled(), scaledToHeight(), setAlphaChannel(), QCursorData::setBitmap(), QShapedPixmapWidget::setPixmap(), QMacStyle::standardIconImplementation(), QWindowsMobileStyle::standardPixmap(), QGL2PaintEngineExPrivate::updateBrushTexture(), QGL2PaintEngineExPrivate::updateBrushUniforms(), QGLContextPrivate::updateFormatVersion(), QGLContext::updatePaintDevice(), and QGraphicsPixmapItemPrivate::updateShape().
|
private |
|
private |
Definition at line 135 of file qpixmap.cpp.
|
private |
bool QPixmap::isDetached | ( | ) | const |
Definition at line 1495 of file qpixmap.cpp.
Referenced by qIsDetached().
bool QPixmap::isNull | ( | ) | const |
Returns true if this is a null pixmap; otherwise returns false.
A null pixmap has zero width, zero height and no contents. You cannot draw in a null pixmap.
Definition at line 615 of file qpixmap.cpp.
Referenced by _q_paintIntoCache(), QMessageBox::aboutQt(), QSvgIconEngine::actualSize(), QSvgIconEngine::addFile(), QPixmapIconEngine::addFile(), QIcon::addPixmap(), QPixmapIconEngine::addPixmap(), QCoreGraphicsPaintEngine::begin(), QPainter::begin(), QX11WindowSurface::beginPaint(), QPixmapIconEngine::bestMatch(), bestSizeMatch(), QX11PixmapData::bitmap_to_mask(), cacheKey(), convertFromImage(), copy(), create32BitCursor(), QOleDropSource::createCursors(), QSystemTrayIconSys::createIcon(), createPixmapDataSync(), depth(), QDragManager::drag(), QVGPixmapConvolutionFilter::draw(), QVGPixmapColorizeFilter::draw(), QVGPixmapDropShadowFilter::draw(), QVGPixmapBlurFilter::draw(), QPixmapConvolutionFilter::draw(), QPixmapBlurFilter::draw(), QGraphicsColorizeEffect::draw(), QPixmapColorizeFilter::draw(), QPixmapDropShadowFilter::draw(), QGraphicsBlurEffect::draw(), QGraphicsDropShadowEffect::draw(), QGraphicsOpacityEffect::draw(), QRenderRule::drawBackgroundImage(), QPlastiqueStyle::drawComplexControl(), QCommonStyle::drawControl(), QWindowsCEStyle::drawControl(), QWindowsVistaStyle::drawControl(), QPlastiqueStyle::drawControl(), QWindowsXPStyle::drawControl(), QWindowsStyle::drawControl(), QStyleSheetStyle::drawControl(), QItemDelegate::drawDecoration(), QGraphicsScenePrivate::drawItemHelper(), QPdfEngine::drawPixmap(), QCoreGraphicsPaintEngine::drawPixmap(), QPainter::drawPixmap(), QPaintEngineEx::drawPixmapFragments(), QPainter::drawPixmapFragments(), QPlastiqueStyle::drawPrimitive(), QPainter::drawTiledPixmap(), fill(), QSystemTrayIconSys::findTrayGeometry(), QRenderRule::fixupBorder(), QX11GLWindowSurface::flush(), QX11WindowSurface::flush(), getPixmap(), getPixmapSize(), QFileIconProviderPrivate::getWinIcon(), QX11GLWindowSurface::grabWidget(), QX11WindowSurface::grabWidget(), handle(), QPixmapIconEngineEntry::isNull(), QFrameInfo::isValid(), QWizardPrivate::layoutInfoForCurrentPage(), QTextDocument::loadResource(), menuItemEntry(), operator<<(), QBitmap::operator=(), QBrush::operator==(), QDecorationWindows::paintButton(), QDecorationDefault::paintButton(), QWizard::paintEvent(), QSvgIconEngine::pixmap(), QGraphicsEffectSource::pixmap(), QPixmapIconEngine::pixmap(), QWizardPage::pixmap(), pixmapsAreEqual(), QStyleSheetStyle::polish(), qBrushDark(), qBrushLight(), qBrushSetAlphaF(), QCursor::QCursor(), QPixmapToIPicture(), QRegion::QRegion(), qstring_to_xtp(), qt_bitmapToRegion(), qt_createIcon(), qt_mac_create_iconref(), qt_mac_display_change_callbk(), qt_mac_set_app_icon(), qt_toRasterPixmap(), qt_toX11Pixmap(), save(), scaled(), scaledToHeight(), scaledToWidth(), QX11GLWindowSurface::scroll(), QX11WindowSurface::scroll(), scroll(), serialNumber(), setAlphaChannel(), QGL2PaintEngineExPrivate::setBrush(), QBrush::setColor(), QDrag::setDragCursor(), QX11WindowSurface::setGeometry(), QMacPixmapData::setMask(), QX11PixmapData::setMask(), setMask(), QDeclarativePixmap::setPixmap(), QShapedPixmapWidget::setPixmap(), QTexturedBrushData::setPixmap(), QBrush::setTexture(), QWizardHeader::setup(), QWorkspacePrivate::showMaximizeControls(), QSystemTrayIconPrivate::showMessage_sys(), QLabelPrivate::sizeForWidth(), QWindowsStyle::standardIconImplementation(), QCommonStyle::standardPixmap(), QWindowsStyle::standardPixmap(), toImage(), toWinHBITMAP(), toWinHICON(), transformed(), QCursorData::update(), QGraphicsPixmapItemPrivate::updateShape(), QPixmapIconEngine::virtual_hook(), and QPixmapIconEngine::write().
bool QPixmap::isQBitmap | ( | ) | const |
Returns true if this is a QBitmap; otherwise returns false.
Definition at line 599 of file qpixmap.cpp.
Referenced by QAlphaPaintEngine::drawPixmap(), QEmulationPaintEngine::drawPixmap(), QGL2PaintEngineEx::drawPixmap(), QPainter::drawPixmap(), QEmulationPaintEngine::drawPixmapFragments(), QGL2PaintEngineExPrivate::drawPixmapFragments(), QAlphaPaintEngine::drawTiledPixmap(), QEmulationPaintEngine::drawTiledPixmap(), QPainter::drawTiledPixmap(), is_brush_transparent(), QBrush::isOpaque(), QGL2PaintEngineExPrivate::setBrush(), QCoreGraphicsPaintEnginePrivate::setFillBrush(), QOpenGLPaintEnginePrivate::setGradientOps(), QSpanData::setup(), and QGL2PaintEngineExPrivate::updateBrushUniforms().
bool QPixmap::load | ( | const QString & | fileName, |
const char * | format = 0 , |
||
Qt::ImageConversionFlags | flags = Qt::AutoColor |
||
) |
Loads a pixmap from the file with the given fileName.
Returns true if the pixmap was successfully loaded; otherwise returns false.
The loader attempts to read the pixmap using the specified format. If the format is not specified (which is the default), the loader probes the file for a header to guess the file format.
The file name can either refer to an actual file on disk or to one of the application's embedded resources. See the Resource System overview for details on how to embed pixmaps and other resource files in the application's executable.
If the data needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the flags to control the conversion.
Note that QPixmaps are automatically added to the QPixmapCache when loaded from a file; the key used is internal and can not be acquired.
Definition at line 930 of file qpixmap.cpp.
Referenced by handle(), QBitmap::QBitmap(), and QPixmap().
bool QPixmap::loadFromData | ( | const uchar * | data, |
uint | len, | ||
const char * | format = 0 , |
||
Qt::ImageConversionFlags | flags = Qt::AutoColor |
||
) |
Loads a pixmap from the len first bytes of the given binary data.
Returns true if the pixmap was loaded successfully; otherwise returns false.
The loader attempts to read the pixmap using the specified format. If the format is not specified (which is the default), the loader probes the file for a header to guess the file format.
If the data needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the flags to control the conversion.
Definition at line 979 of file qpixmap.cpp.
Referenced by QTextHtmlParserNode::applyBackgroundImage(), getPixmap(), handle(), and QTextDocument::loadResource().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Loads a pixmap from the binary data using the specified format and conversion flags.
Definition at line 312 of file qpixmap.h.
QBitmap QPixmap::mask | ( | ) | const |
Extracts a bitmap mask from the pixmap's alpha channel.
Definition at line 2077 of file qpixmap.cpp.
Referenced by create32BitCursor(), fromWinHBITMAP(), fromWinHICON(), isServerProcess(), QCursor::QCursor(), qDrawPlainRect(), QShapedPixmapWidget::setPixmap(), toWinHICON(), and QGraphicsPixmapItemPrivate::updateShape().
|
protectedvirtual |
Reimplemented from QPaintDevice.
Definition at line 1973 of file qpixmap.cpp.
int QPixmap::numCols | ( | ) | const |
Definition at line 125 of file qpixmap_qws.cpp.
QPixmap::operator QVariant | ( | ) | const |
Returns the pixmap as a QVariant.
Definition at line 499 of file qpixmap.cpp.
|
inline |
Returns true if this is a null pixmap; otherwise returns false.
Definition at line 226 of file qpixmap.h.
Assigns the given pixmap to this pixmap and returns a reference to this pixmap.
Definition at line 471 of file qpixmap.cpp.
Referenced by QBitmap::clear(), handle(), QBitmap::operator=(), and QPixmap().
|
virtual |
Implements QPaintDevice.
Definition at line 2059 of file qpixmap.cpp.
QPixmapData * QPixmap::pixmapData | ( | ) | const |
Definition at line 2277 of file qpixmap.cpp.
Referenced by QRasterPaintEngine::begin(), CapabilitiesToStateMask::canBlitterDrawPixmap(), CapabilitiesToStateMask::canBlitterDrawPixmapOpacity(), QDirectFBCursor::changeCursor(), depth(), detach(), QVGPixmapConvolutionFilter::draw(), QVGPixmapColorizeFilter::draw(), QVGPixmapDropShadowFilter::draw(), QVGPixmapBlurFilter::draw(), QVGCompositionHelper::drawCursorPixmap(), QVolatileImagePaintEngine::drawPixmap(), QDirectFBPaintEngine::drawPixmap(), QVGPaintEngine::drawPixmap(), QRasterPaintEngine::drawPixmap(), QVGPaintEngine::drawPixmapFragments(), QDirectFbBlitter::drawPixmapOpacity(), QDirectFBPaintEngine::drawTiledPixmap(), QDirectFBPaintEnginePrivate::drawTiledPixmap(), QRasterPaintEngine::drawTiledPixmap(), QDirectFBPaintEngine::fillRect(), QX11GLWindowSurface::grabWidget(), handle(), hasAlpha(), qPixmapToVGImage(), qt_directfb_surface_for_pixmap(), QVGPaintEnginePrivate::setBrush(), QX11WindowSurface::setGeometry(), and QMeeGoGraphicsSystem::updateEGLSharedImagePixmap().
const uchar * QPixmap::qwsBits | ( | ) | const |
Definition at line 140 of file qpixmap_qws.cpp.
int QPixmap::qwsBytesPerLine | ( | ) | const |
Definition at line 150 of file qpixmap_qws.cpp.
QRect QPixmap::rect | ( | ) | const |
Returns the pixmap's enclosing rectangle.
Definition at line 676 of file qpixmap.cpp.
Referenced by QMoviePrivate::_q_loadNextFrame(), _q_paintIntoCache(), QOleDropSource::createCursors(), QGLPixmapFilter< QPixmapBlurFilter >::draw(), QPixmapConvolutionFilter::draw(), QPixmapBlurFilter::draw(), QPixmapColorizeFilter::draw(), QGraphicsOpacityEffect::draw(), QTextImageHandler::drawObject(), QBlitterPaintEngine::drawPixmap(), QDirectFBPaintEngine::drawPixmap(), QPdfEngine::drawPixmap(), QRasterPaintEngine::drawPixmap(), QPaintEngineEx::drawPixmap(), QPainter::drawPixmap(), QPaintEngineEx::drawPixmapFragments(), QPainter::drawPixmapFragments(), QGLPixmapBlurFilter::processGL(), QGLPixmapDropShadowFilter::processGL(), qDrawBorderPixmap(), qt_mac_draw_pattern(), QDeclarativePixmap::rect(), scroll(), and QLabelPrivate::sizeForWidth().
bool QPixmap::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 quality factor.
Returns true if successful; otherwise returns false.
The quality factor must be in the range [0,100] or -1. Specify 0 to obtain small compressed files, 100 for large uncompressed files, and -1 to use the default settings.
If format is 0, an image format will be chosen from fileName's suffix.
Definition at line 1016 of file qpixmap.cpp.
bool QPixmap::save | ( | QIODevice * | device, |
const char * | format = 0 , |
||
int | quality = -1 |
||
) | const |
This function writes a QPixmap to the given device using the specified image file format and quality factor.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This can be used, for example, to save a pixmap directly into a QByteArray:
Definition at line 1037 of file qpixmap.cpp.
|
inline |
Definition at line 132 of file qpixmap.h.
Referenced by QGL2PaintEngineEx::drawPixmap(), QOpenGLPaintEngine::drawPixmap(), QGL2PaintEngineEx::drawPixmapFragments(), QPixmapIconEngine::pixmap(), QWidgetPrivate::setWindowIcon_sys(), and QGL2PaintEngineExPrivate::updateBrushTexture().
QPixmap QPixmap::scaled | ( | const QSize & | s, |
Qt::AspectRatioMode | aspectMode = Qt::IgnoreAspectRatio , |
||
Qt::TransformationMode | mode = Qt::FastTransformation |
||
) | const |
Definition at line 1603 of file qpixmap.cpp.
QPixmap QPixmap::scaledToHeight | ( | int | h, |
Qt::TransformationMode | mode = Qt::FastTransformation |
||
) | const |
Definition at line 1673 of file qpixmap.cpp.
Referenced by QWindowsMobileStyle::standardPixmap().
QPixmap QPixmap::scaledToWidth | ( | int | width, |
Qt::TransformationMode | mode = Qt::FastTransformation |
||
) | const |
Returns a scaled copy of the image.
The returned image is scaled to the given width using the specified transformation mode. The height of the pixmap is automatically calculated so that the aspect ratio of the pixmap is preserved.
If width is 0 or negative, a null pixmap is returned.
Definition at line 1642 of file qpixmap.cpp.
Referenced by QUrlModel::setUrl().
|
inline |
This convenience function is equivalent to calling QPixmap::scroll(dx, dy, QRect(x, y, width, height), exposed).
Definition at line 307 of file qpixmap.h.
Referenced by QGraphicsItem::scroll().
Scrolls the area rect of this pixmap by (dx, dy).
The exposed region is left unchanged. You can optionally pass a pointer to an empty QRegion to get the region that is exposed by the scroll operation.
You cannot scroll while there is an active painter on the pixmap.
Definition at line 434 of file qpixmap.cpp.
int QPixmap::serialNumber | ( | ) | const |
Returns a number that identifies the contents of this QPixmap object.
Use cacheKey() instead.
Definition at line 1122 of file qpixmap.cpp.
void QPixmap::setAlphaChannel | ( | const QPixmap & | alphaChannel | ) |
Sets the alpha channel of this pixmap to the given alphaChannel by converting the alphaChannel into 32 bit and using the intensity of the RGB pixel values.
The effect of this function is undefined when the pixmap is being painted on.
Definition at line 1999 of file qpixmap.cpp.
void QPixmap::setMask | ( | const QBitmap & | mask | ) |
Sets a mask bitmap.
This function merges the mask with the pixmap's alpha channel. A pixel value of 1 on the mask means the pixmap's pixel is unchanged; a value of 0 means the pixel is transparent. The mask must have the same size as this pixmap.
Setting a null mask resets the mask, leaving the previously transparent pixels black. The effect of this function is undefined when the pixmap is being painted on.
Definition at line 822 of file qpixmap.cpp.
Referenced by QWindowsStyle::drawComplexControl(), QCursor::QCursor(), qDrawPlainRect(), and QX11PixmapData::transformed().
QSize QPixmap::size | ( | ) | const |
Returns the size of the pixmap.
Definition at line 661 of file qpixmap.cpp.
Referenced by QLabelPrivate::_q_movieUpdated(), QSvgIconEngine::actualSize(), QPixmapIconEngine::addFile(), QPixmapIconEngine::addPixmap(), QPixmapIconEngine::bestMatch(), bestSizeMatch(), QPaintBuffer::commandDescription(), QMdi::ControlLabel::ControlLabel(), create32BitCursor(), depth(), QPixmapDropShadowFilter::draw(), QRenderRule::drawBackgroundImage(), QRenderRule::drawBorderImage(), QStyleHelper::drawBorderPixmap(), QCommonStyle::drawControl(), QMacStyle::drawControl(), QItemDelegate::drawDecoration(), QPaintEngine::drawImage(), QGraphicsScenePrivate::drawItemHelper(), QStyle::drawItemPixmap(), QBlitterPaintEngine::drawPixmap(), QDirectFBPaintEngine::drawPixmap(), QWin32PrintEngine::drawPixmap(), QGL2PaintEngineEx::drawPixmap(), QOpenGLPaintEngine::drawPixmap(), QRasterPaintEngine::drawPixmap(), QPaintEngineEx::drawPixmap(), QPaintBufferEngine::drawPixmap(), QGL2PaintEngineEx::drawPixmapFragments(), QDirectFBPaintEngine::drawTiledPixmap(), QOpenGLPaintEngine::drawTiledPixmap(), QRasterPaintEngine::drawTiledPixmap(), QX11GLWindowSurface::flush(), QAccessibleDisplay::imageSize(), QStyledItemDelegate::initStyleOption(), QMoviePrivate::next(), QBitmap::operator=(), QItemDelegate::paint(), QGtkPainter::paintBox(), QGtkPainter::paintBoxGap(), QSvgIconEngine::pixmap(), QPixmapIconEngine::pixmap(), pixmapsAreEqual(), QGLPixmapConvolutionFilter::processGL(), QCursor::QCursor(), scaled(), QMacWindowSurface::scroll(), QCursorData::setBitmap(), QX11GLWindowSurface::setGeometry(), QMacWindowSurface::setGeometry(), QX11WindowSurface::setGeometry(), QRasterPixmapData::setMask(), QPixmapData::setMask(), setMask(), QCursor::setPos(), QWizardHeader::setup(), QMdi::ControlLabel::sizeHint(), toWinHICON(), QOpenGLPaintEnginePrivate::updateFragmentProgramData(), and QPixmapIconEngine::virtual_hook().
|
inline |
Swaps pixmap other with this pixmap.
This operation is very fast and never fails.
Definition at line 90 of file qpixmap.h.
Referenced by QBitmap::swap().
QImage QPixmap::toImage | ( | ) | const |
Converts the pixmap to a QImage.
Returns a null image if the conversion fails.
If the pixmap has 1-bit depth, the returned image will also be 1 bit deep. Images with more bits will be returned in a format closely represents the underlying system. Usually this will be QImage::Format_ARGB32_Premultiplied for pixmaps with an alpha and QImage::Format_RGB32 or QImage::Format_RGB16 for pixmaps without alpha.
Note that for the moment, alpha masks on monochrome images are ignored.
Definition at line 542 of file qpixmap.cpp.
Referenced by QPdfEnginePrivate::addBrushPattern(), QFontEngineXLFD::addOutlineToPath(), QFontEngineXLFD::alphaMapForGlyph(), QPlatformSoftwareCursor::changeCursor(), create32BitCursor(), QXlibCursor::createCursorBitmap(), createHeuristicMask(), createMaskFromColor(), darkenPixmap(), QWSDisplay::defineCursor(), doImageIO(), QPixmapConvolutionFilter::draw(), QPixmapBlurFilter::draw(), QPixmapColorizeFilter::draw(), QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QMacStylePrivate::drawColorlessButton(), QCommonStyle::drawControl(), QWindowsStyle::drawControl(), QMotifStyle::drawControl(), QVGCompositionHelper::drawCursorPixmap(), QPdfEngine::drawPixmap(), QOpenGLPaintEngine::drawPixmap(), QSvgPaintEngine::drawPixmap(), QRasterPaintEngine::drawPixmap(), QOpenGLPaintEngine::drawTiledPixmap(), QRasterPaintEngine::drawTiledPixmap(), QWindowsMobileStyle::generatedIconPixmap(), QCommonStyle::generatedIconPixmap(), QMacStyle::generatedIconPixmap(), QMoviePrivate::next(), operator<<(), QBitmap::operator=(), pixmapsAreEqual(), QGLPixmapBlurFilter::processGL(), QGLPixmapDropShadowFilter::processGL(), qBrushDark(), qBrushLight(), qBrushSetAlphaF(), QTest::qCompare(), QCursor::QCursor(), qstring_to_xtp(), qt_bitmapToRegion(), qt_createIconMask(), qt_mac_create_iconref(), qt_toRasterPixmap(), qt_toX11Pixmap(), QAlphaWidget::run(), QItemDelegate::selected(), QRasterPixmapData::setAlphaChannel(), QX11PixmapData::setAlphaChannel(), QVolatileImage::setAlphaChannel(), QPixmapData::setAlphaChannel(), QRasterPixmapData::setMask(), QPixmapData::setMask(), QCursor::setPos(), QSystemTrayIconPrivate::showMessage_sys(), QMacStyle::styleHint(), QX11PixmapData::toImage(), toWinHBITMAP(), QX11Data::xdndMimeConvertToFormat(), and QX11Data::xdndMimeDataForAtom().
CGImageRef QPixmap::toMacCGImageRef | ( | ) | const |
Creates a CGImageRef
equivalent to the QPixmap.
Returns the CGImageRef
handle.
It is the caller's responsibility to release the CGImageRef
data after use.
Definition at line 1254 of file qpixmap_mac.cpp.
Referenced by QCoreGraphicsPaintEngine::drawPixmap(), QMacWindowSurface::flush(), qt_mac_create_nsimage(), and QMacWindowSurface::scroll().
HBITMAP QPixmap::toWinHBITMAP | ( | HBitmapFormat | format = NoAlpha | ) | const |
It is the caller's responsibility to free the HBITMAP
data after use.
Win32 only: Creates a HBITMAP
equivalent to the QPixmap, based on the given format. Returns the HBITMAP
handle.
Definition at line 122 of file qpixmap_win.cpp.
Referenced by create32BitCursor(), QAxServerBase::Draw(), QWin32PrintEngine::drawPixmap(), QWin32PrintEngine::drawTiledPixmap(), QAxHostWidget::paintEvent(), QPixmapToIPicture(), and toWinHICON().
HICON QPixmap::toWinHICON | ( | ) | const |
Returns the HICON
handle.
Win32 only: Creates a HICON
equivalent to the QPixmap.
It is the caller's responsibility to free the HICON
data after use.
Definition at line 257 of file qpixmap_win.cpp.
Referenced by QSystemTrayIconSys::createIcon(), QVistaHelper::drawTitleBar(), QSystemTrayIconSys::findTrayGeometry(), and qt_createIcon().
QPixmap QPixmap::transformed | ( | const QMatrix & | matrix, |
Qt::TransformationMode | mode = Qt::FastTransformation |
||
) | const |
This convenience function loads the matrix into a QTransform and calls the overloaded function.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 1723 of file qpixmap.cpp.
Referenced by QBitmap::clear(), QWin32PrintEngine::drawPixmap(), scaled(), scaledToHeight(), scaledToWidth(), and QBitmap::transformed().
QPixmap QPixmap::transformed | ( | const QTransform & | transform, |
Qt::TransformationMode | mode = Qt::FastTransformation |
||
) | const |
Returns a copy of the pixmap that is transformed using the given transformation transform and transformation mode.
The original pixmap is not changed.
The transformation transform is internally adjusted to compensate for unwanted translation; i.e. the pixmap produced is the smallest pixmap that contains all the transformed points of the original pixmap. Use the trueMatrix() function to retrieve the actual matrix used for transforming the pixmap.
This function is slow because it involves transformation to a QImage, non-trivial computations and a transformation back to a QPixmap.
Definition at line 1705 of file qpixmap.cpp.
This convenience function loads the matrix m into a QTransform and calls the overloaded function with the QTransform and the width w and the height h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 584 of file qpixmap.cpp.
Referenced by QWin32PrintEngine::drawPixmap(), QMacPixmapData::macCreatePixels(), and QX11PixmapData::transformed().
|
static |
Returns the actual matrix used for transforming a pixmap with the given width, height and matrix.
When transforming a pixmap using the transformed() function, the transformation matrix is internally adjusted to compensate for unwanted translation, i.e. transformed() returns the smallest pixmap containing all transformed points of the original pixmap. This function returns the modified matrix, which maps points correctly from the original pixmap into the new pixmap.
Definition at line 569 of file qpixmap.cpp.
int QPixmap::width | ( | ) | const |
Returns the width of the pixmap.
Definition at line 630 of file qpixmap.cpp.
Referenced by QX11WindowSurface::beginPaint(), QX11PixmapData::bitmap_to_mask(), copy(), QXlibCursor::createCursorBitmap(), QOleDropSource::createCursors(), QWSDisplay::defineCursor(), depth(), QDragManager::drag(), QAxServerBase::Draw(), QTreeViewPrivate::drawAnimatedOperation(), QRenderRule::drawBackgroundImage(), QMacStylePrivate::drawCombobox(), QCommonStyle::drawControl(), QWindowsCEStyle::drawControl(), QWindowsVistaStyle::drawControl(), QPlastiqueStyle::drawControl(), QWindowsMobileStyle::drawControl(), QCleanlooksStyle::drawControl(), QWindowsXPStyle::drawControl(), QWindowsStyle::drawControl(), QGtkStyle::drawControl(), QMotifStyle::drawControl(), QMacStyle::drawControl(), QStyleSheetStyle::drawControl(), QDeclarativeTextPrivate::drawOutline(), QWin32PrintEngine::drawPixmap(), QCoreGraphicsPaintEngine::drawPixmap(), QGL2PaintEngineEx::drawPixmap(), QOpenGLPaintEngine::drawPixmap(), QPainter::drawPixmap(), QMacStylePrivate::drawTableHeader(), QPSPrintEngine::drawTiledPixmap(), QWin32PrintEngine::drawTiledPixmap(), QX11PaintEngine::drawTiledPixmap(), QOpenGLPaintEngine::drawTiledPixmap(), QPaintEngine::drawTiledPixmap(), QPainter::drawTiledPixmap(), QBlitterPaintEngine::fillRect(), QMacStylePrivate::generateBackgroundPattern(), getPixmapSize(), QMeeGoLivePixmapData::initializeThroughEGLImage(), QPixmapCache::insert(), QGLBlurTextureCache::insertBlurTextureInfo(), QStyle::itemPixmapRect(), QX11PixmapData::mask_to_bitmap(), menuItemEntry(), QColorWell::mouseMoveEvent(), QColorShowLabel::mouseMoveEvent(), QGtkPainter::paintBox(), QGtkPainter::paintBoxGap(), QAxHostWidget::paintEvent(), QColorLuminancePicker::paintEvent(), QGLOverlayWidget::paintGL(), QMacStyle::polish(), QCursor::QCursor(), qDrawPlainRect(), qt_draw_tile(), qt_fill_tile(), qt_mac_draw_pattern(), QPixmapCache::replace(), scaled(), scaledToWidth(), setAlphaChannel(), QCursorData::setBitmap(), QShapedPixmapWidget::setPixmap(), QMacStyle::standardIconImplementation(), QGL2PaintEngineExPrivate::updateBrushTexture(), QGL2PaintEngineExPrivate::updateBrushUniforms(), QGLContextPrivate::updateFormatVersion(), QGLContext::updatePaintDevice(), QGraphicsPixmapItemPrivate::updateShape(), and QDeclarativePixmap::width().
|
related |
Writes the given pixmap to the given stream as a PNG image.
Note that writing the stream to a file will not produce a valid image file.
Definition at line 1430 of file qpixmap.cpp.
|
friend |
Reads an image from the given stream into the given pixmap.
Definition at line 1446 of file qpixmap.cpp.
Definition at line 279 of file qpixmap.h.
Referenced by QBitmap::clear(), mask(), and toWinHICON().
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
Returns the CoreGraphics CGContextRef of the paint device.
0 is returned if it can't be obtained. It is the caller's responsiblity to CGContextRelease the context when finished using it.
Definition at line 118 of file qpaintdevice_mac.cpp.
Definition at line 1109 of file qpixmap_mac.cpp.
|
friend |
Definition at line 1077 of file qpixmap_mac.cpp.
Definition at line 75 of file qpixmap_mac.cpp.
|
friend |
Definition at line 83 of file qpixmap_mac.cpp.
|
friend |
Definition at line 94 of file qpixmap.cpp.
|
friend |
|
friend |
|
friend |
|
private |
Definition at line 252 of file qpixmap.h.
Referenced by alphaChannel(), QX11PaintEngine::begin(), cacheKey(), clut(), colorCount(), convertFromImage(), copy(), depth(), detach(), QX11PaintEngine::drawPixmap(), QX11PaintEngine::drawTiledPixmap(), fill(), QBitmap::fromImage(), fromImage(), fromImageReader(), fromWinHBITMAP(), handle(), hasAlpha(), hasAlphaChannel(), height(), init(), isDetached(), isNull(), isQBitmap(), load(), loadFromData(), mask(), metric(), operator=(), paintEngine(), pixmapData(), QPixmap(), qstring_to_xtp(), qt_mac_cg_context(), qt_mac_create_imagemask(), qt_mac_pixmap_get_base(), qt_mac_pixmap_get_bytes_per_line(), qwsBits(), qwsBytesPerLine(), rect(), scroll(), serialNumber(), QMacPixmapData::setAlphaChannel(), setAlphaChannel(), setMask(), size(), swap(), toImage(), toWinHBITMAP(), toWinHICON(), transformed(), width(), and ~QPixmap().