Qt 4.8
|
The QBitmap class provides monochrome (1-bit depth) pixmaps. More...
#include <qbitmap.h>
Public Types | |
typedef QExplicitlySharedDataPointer< QPixmapData > | DataPtr |
Public Types inherited from QPixmap | |
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 | |
void | clear () |
Clears the bitmap, setting all its bits to Qt::color0. More... | |
operator QVariant () const | |
Returns the bitmap as a QVariant. More... | |
QBitmap & | operator= (const QPixmap &) |
Assigns the given pixmap to this bitmap and returns a reference to this bitmap. More... | |
QBitmap () | |
Constructs a null bitmap. More... | |
QBitmap (const QPixmap &) | |
Constructs a bitmap that is a copy of the given pixmap. More... | |
QBitmap (int w, int h) | |
Constructs a bitmap with the given width and height. More... | |
QBitmap (const QSize &) | |
Constructs a bitmap with the given size. More... | |
QBitmap (const QString &fileName, const char *format=0) | |
Constructs a bitmap from the file specified by the given fileName. More... | |
void | swap (QBitmap &other) |
Swaps bitmap other with this bitmap. More... | |
QBitmap | transformed (const QMatrix &) const |
This convenience function converts the matrix to a QTransform and calls the overloaded function. More... | |
QBitmap | transformed (const QTransform &matrix) const |
Returns a copy of this bitmap, transformed according to the given matrix. More... | |
~QBitmap () | |
Destroys the bitmap. More... | |
Public Functions inherited from QPixmap | |
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 QBitmap | fromData (const QSize &size, const uchar *bits, QImage::Format monoFormat=QImage::Format_MonoLSB) |
Constructs a bitmap with the given size, and sets the contents to the bits supplied. More... | |
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. More... | |
Static Public Functions inherited from QPixmap | |
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 () |
Additional Inherited Members | |
Protected Functions inherited from QPixmap | |
int | metric (PaintDeviceMetric) const |
Protected Functions inherited from QPaintDevice | |
QPaintDevice () | |
Protected Variables inherited from QPaintDevice | |
ushort | painters |
Related Functions inherited from QPixmap | |
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... | |
The QBitmap class provides monochrome (1-bit depth) pixmaps.
The QBitmap class is a monochrome off-screen paint device used mainly for creating custom QCursor and QBrush objects, constructing QRegion objects, and for setting masks for pixmaps and widgets.
QBitmap is a QPixmap subclass ensuring a depth of 1, except for null objects which have a depth of 0. If a pixmap with a depth greater than 1 is assigned to a bitmap, the bitmap will be dithered automatically.
Use the QColor objects Qt::color0 and Qt::color1 when drawing on a QBitmap object (or a QPixmap object with depth 1).
Painting with Qt::color0 sets the bitmap bits to 0, and painting with Qt::color1 sets the bits to 1. For a bitmap, 0-bits indicate background (or transparent pixels) and 1-bits indicate foreground (or opaque pixels). Use the clear() function to set all the bits to Qt::color0. Note that using the Qt::black and Qt::white colors make no sense because the QColor::pixel() value is not necessarily 0 for black and 1 for white.
The QBitmap class provides the transformed() function returning a transformed copy of the bitmap; use the QTransform argument to translate, scale, shear, and rotate the bitmap. In addition, QBitmap provides the static fromData() function which returns a bitmap constructed from the given uchar
data, and the static fromImage() function returning a converted copy of a QImage object.
Just like the QPixmap class, QBitmap is optimized by the use of implicit data sharing. For more information, see the Implicit Data Sharing documentation.
QBitmap::QBitmap | ( | ) |
Constructs a null bitmap.
Definition at line 106 of file qbitmap.cpp.
Referenced by fromImage(), and operator=().
QBitmap::QBitmap | ( | const QPixmap & | pixmap | ) |
Constructs a bitmap that is a copy of the given pixmap.
If the pixmap has a depth greater than 1, the resulting bitmap will be dithered automatically.
Definition at line 158 of file qbitmap.cpp.
QBitmap::QBitmap | ( | int | width, |
int | height | ||
) |
Constructs a bitmap with the given width and height.
The pixels inside are uninitialized.
Definition at line 123 of file qbitmap.cpp.
|
explicit |
Constructs a bitmap with the given size.
The pixels in the bitmap are uninitialized.
Definition at line 135 of file qbitmap.cpp.
|
explicit |
Constructs a bitmap from the file specified by the given fileName.
If the file does not exist, or has an unknown format, the bitmap becomes a null bitmap.
The fileName and format parameters are passed on to the QPixmap::load() function. If the file format uses more than 1 bit per pixel, the resulting bitmap will be dithered automatically.
Definition at line 186 of file qbitmap.cpp.
QBitmap::~QBitmap | ( | ) |
|
inline |
Clears the bitmap, setting all its bits to Qt::color0.
Definition at line 69 of file qbitmap.h.
Referenced by QWindowsStyle::drawComplexControl().
|
static |
Constructs a bitmap with the given size, and sets the contents to the bits supplied.
The bitmap data has to be byte aligned and provided in in the bit order specified by monoFormat. The mono format must be either QImage::Format_Mono or QImage::Format_MonoLSB. Use QImage::Format_Mono to specify data on the XBM format.
Definition at line 318 of file qbitmap.cpp.
Referenced by create32BitCursor(), operator=(), qt_pixmapForBrush(), QX11PixmapData::transformed(), and QCursorData::update().
|
static |
Returns a copy of the given image converted to a bitmap using the specified image conversion flags.
Definition at line 281 of file qbitmap.cpp.
Referenced by QGraphicsItem::boundingRegion(), convert(), QMacPixmapData::copy(), QPixmap::createHeuristicMask(), QPixmap::createMaskFromColor(), fromData(), QX11PixmapData::fromImage(), QPixmap::handle(), QX11PixmapData::mask(), QPixmapData::mask(), operator=(), QCursor::QCursor(), QPixmap::QPixmap(), qt_patternForAlpha(), and QMacStyle::styleHint().
QBitmap::operator QVariant | ( | ) | const |
Returns the bitmap as a QVariant.
Definition at line 257 of file qbitmap.cpp.
Assigns the given pixmap to this bitmap and returns a reference to this bitmap.
Converts the given image to a bitmap, and assigns the result to this bitmap.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
If the pixmap has a depth greater than 1, the resulting bitmap will be dithered automatically.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns a reference to the bitmap.
Use the static fromImage() function instead.
Definition at line 207 of file qbitmap.cpp.
Referenced by QBitmap().
|
inline |
This convenience function converts the matrix to 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 356 of file qbitmap.cpp.
Referenced by QX11PixmapData::transformed().
QBitmap QBitmap::transformed | ( | const QTransform & | matrix | ) | const |
Returns a copy of this bitmap, transformed according to the given matrix.
Definition at line 340 of file qbitmap.cpp.