Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtGui More...
#include <qbitmap.h>
Public Types | |
typedef QExplicitlySharedDataPointer< QPlatformPixmap > | DataPtr |
Public Types inherited from QPixmap | |
typedef QExplicitlySharedDataPointer< QPlatformPixmap > | DataPtr |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric { PdmWidth = 1 , PdmHeight , PdmWidthMM , PdmHeightMM , PdmNumColors , PdmDepth , PdmDpiX , PdmDpiY , PdmPhysicalDpiX , PdmPhysicalDpiY , PdmDevicePixelRatio , PdmDevicePixelRatioScaled , PdmDevicePixelRatioF_EncodedA , PdmDevicePixelRatioF_EncodedB } |
Public Member Functions | |
QBitmap () | |
Constructs a null bitmap. | |
QBitmap (int w, int h) | |
Constructs a bitmap with the given width and height. | |
QBitmap (const QSize &) | |
QBitmap (const QString &fileName, const char *format=nullptr) | |
Constructs a bitmap from the file specified by the given fileName. | |
~QBitmap () override | |
void | swap (QBitmap &other) |
\memberswap{bitmap} | |
operator QVariant () const | |
Returns the bitmap as a QVariant. | |
void | clear () |
Clears the bitmap, setting all its bits to Qt::color0. | |
QBitmap | transformed (const QTransform &matrix) const |
Returns a copy of this bitmap, transformed according to the given matrix. | |
Public Member Functions inherited from QPixmap | |
QPixmap () | |
Constructs a null pixmap. | |
QPixmap (QPlatformPixmap *data) | |
QPixmap (int w, int h) | |
Constructs a pixmap with the given width and height. | |
QPixmap (const QSize &) | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Constructs a pixmap of the given size. | |
QPixmap (const QString &fileName, const char *format=nullptr, Qt::ImageConversionFlags flags=Qt::AutoColor) | |
Constructs a pixmap from the file with the given fileName. | |
QPixmap (const char *const xpm[]) | |
Constructs a pixmap from the given xpm data, which must be a valid XPM image. | |
QPixmap (const QPixmap &) | |
Constructs a pixmap that is a copy of the given pixmap. | |
QPixmap (QPixmap &&other) noexcept | |
Move-constructs a QPixmap instance from other. | |
~QPixmap () | |
Destroys the pixmap. | |
QPixmap & | operator= (const QPixmap &) |
Assigns the given pixmap to this pixmap and returns a reference to this pixmap. | |
void | swap (QPixmap &other) noexcept |
\memberswap{pixmap} | |
bool | operator== (const QPixmap &) const =delete |
bool | operator!= (const QPixmap &) const =delete |
operator QVariant () const | |
Returns the pixmap as a QVariant. | |
bool | isNull () const |
Returns true if this is a null pixmap; otherwise returns false . | |
int | devType () const override |
int | width () const |
Returns the width of the pixmap. | |
int | height () const |
Returns the height of the pixmap. | |
QSize | size () const |
Returns the size of the pixmap. | |
QRect | rect () const |
Returns the pixmap's enclosing rectangle. | |
int | depth () const |
Returns the depth of the pixmap. | |
void | fill (const QColor &fillColor=Qt::white) |
Fills the pixmap with the given color. | |
QBitmap | mask () const |
Returns true if this pixmap has an alpha channel, or has a mask, otherwise returns false . | |
void | setMask (const QBitmap &) |
Sets a mask bitmap. | |
qreal | devicePixelRatio () const |
Returns the device pixel ratio for the pixmap. | |
void | setDevicePixelRatio (qreal scaleFactor) |
Sets the device pixel ratio for the pixmap. | |
QSizeF | deviceIndependentSize () const |
Returns the size of the pixmap in device independent pixels. | |
bool | hasAlpha () const |
bool | hasAlphaChannel () const |
QBitmap | createHeuristicMask (bool clipTight=true) const |
Creates and returns a heuristic mask for this pixmap. | |
QBitmap | createMaskFromColor (const QColor &maskColor, Qt::MaskMode mode=Qt::MaskInColor) const |
Creates and returns a mask for this pixmap based on the given maskColor. | |
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 | scaledToWidth (int w, Qt::TransformationMode mode=Qt::FastTransformation) const |
Returns a scaled copy of the image. | |
QPixmap | scaledToHeight (int h, Qt::TransformationMode mode=Qt::FastTransformation) const |
Returns a scaled copy of the image. | |
QPixmap | transformed (const QTransform &, Qt::TransformationMode mode=Qt::FastTransformation) const |
QImage | toImage () const |
Converts the pixmap to a QImage. | |
bool | load (const QString &fileName, const char *format=nullptr, Qt::ImageConversionFlags flags=Qt::AutoColor) |
Loads a pixmap from the file with the given fileName. | |
bool | loadFromData (const uchar *buf, uint len, const char *format=nullptr, Qt::ImageConversionFlags flags=Qt::AutoColor) |
Loads a pixmap from the len first bytes of the given binary data. | |
bool | loadFromData (const QByteArray &data, const char *format=nullptr, 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. | |
bool | save (const QString &fileName, const char *format=nullptr, int quality=-1) const |
Saves the pixmap to the file with the given fileName using the specified image file format and quality factor. | |
bool | save (QIODevice *device, const char *format=nullptr, int quality=-1) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This function writes a QPixmap to the given device using the specified image file format and quality factor. | |
bool | convertFromImage (const QImage &img, Qt::ImageConversionFlags flags=Qt::AutoColor) |
Replaces this pixmap's data with the given image using the specified flags to control the conversion. | |
QPixmap | copy (int x, int y, int width, int height) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a deep copy of the subset of the pixmap that is specified by the rectangle QRect( x, y, width, height). | |
QPixmap | copy (const QRect &rect=QRect()) const |
Returns a deep copy of the subset of the pixmap that is specified by the given rectangle. | |
void | scroll (int dx, int dy, int x, int y, int width, int height, QRegion *exposed=nullptr) |
This convenience function is equivalent to calling QPixmap::scroll(dx, dy, QRect(x, y, width, height), exposed). | |
void | scroll (int dx, int dy, const QRect &rect, QRegion *exposed=nullptr) |
Scrolls the area rect of this pixmap by (dx, dy). | |
qint64 | cacheKey () const |
Returns a number that identifies this QPixmap. | |
bool | isDetached () const |
void | detach () |
Detaches the pixmap from shared pixmap data. | |
bool | isQBitmap () const |
Returns true if this is a QBitmap; otherwise returns false . | |
QPaintEngine * | paintEngine () const override |
bool | operator! () const |
Returns true if this is a null pixmap; otherwise returns false . | |
QPlatformPixmap * | handle () const |
DataPtr & | data_ptr () |
Public Member Functions inherited from QPaintDevice | |
virtual | ~QPaintDevice () |
bool | paintingActive () const |
int | width () const |
int | height () const |
int | widthMM () const |
int | heightMM () const |
int | logicalDpiX () const |
int | logicalDpiY () const |
int | physicalDpiX () const |
int | physicalDpiY () const |
qreal | devicePixelRatio () const |
qreal | devicePixelRatioF () const |
int | colorCount () const |
int | depth () const |
Static Public Member Functions | |
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. | |
static QBitmap | fromImage (QImage &&image, Qt::ImageConversionFlags flags=Qt::AutoColor) |
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. | |
static QBitmap | fromPixmap (const QPixmap &pixmap) |
Returns a copy of the given pixmap converted to a bitmap. | |
Static Public Member Functions inherited from QPixmap | |
static int | defaultDepth () |
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. | |
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. | |
static QPixmap | fromImageReader (QImageReader *imageReader, Qt::ImageConversionFlags flags=Qt::AutoColor) |
Create a QPixmap from an image read directly from an imageReader. | |
static QPixmap | fromImage (QImage &&image, Qt::ImageConversionFlags flags=Qt::AutoColor) |
Static Public Member Functions inherited from QPaintDevice | |
static qreal | devicePixelRatioFScale () |
static int | encodeMetricF (PaintDeviceMetric metric, double value) |
Additional Inherited Members | |
Protected Member Functions inherited from QPixmap | |
int | metric (PaintDeviceMetric) const override |
Protected Member Functions inherited from QPaintDevice | |
QPaintDevice () noexcept | |
virtual void | initPainter (QPainter *painter) const |
virtual QPaintDevice * | redirected (QPoint *offset) const |
virtual QPainter * | sharedPainter () const |
double | getDecodedMetricF (PaintDeviceMetric metricA, PaintDeviceMetric metricB) const |
Static Protected Member Functions inherited from QPixmap | |
static QPixmap | fromImageInPlace (QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor) |
Protected Attributes inherited from QPaintDevice | |
ushort | painters |
Related Symbols inherited from QPixmap | |
QDataStream & | operator<< (QDataStream &stream, const QPixmap &pixmap) |
Writes the given pixmap to the given stream as a PNG image. | |
\inmodule QtGui
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 \l {Implicit Data Sharing} documentation.
QBitmap::QBitmap | ( | ) |
QBitmap::QBitmap | ( | int | width, |
int | height ) |
Constructs a bitmap with the given width and height.
The pixels inside are uninitialized.
Definition at line 83 of file qbitmap.cpp.
|
explicit |
Constructs a bitmap with the given size. The pixels in the bitmap are uninitialized.
Constructs a bitmap with the given size. The pixels in the bitmap are uninitialized.
Definition at line 96 of file qbitmap.cpp.
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 124 of file qbitmap.cpp.
|
overridedefault |
This dtor must stay empty until Qt 7 (was inline until 6.2).
|
inline |
Clears the bitmap, setting all its bits to Qt::color0.
|
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 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 204 of file qbitmap.cpp.
|
static |
Returns a copy of the given image converted to a bitmap using the specified image conversion flags.
Definition at line 167 of file qbitmap.cpp.
|
static |
Returns a copy of the given image converted to a bitmap using the specified image conversion flags.
Definition at line 184 of file qbitmap.cpp.
Returns a copy of the given pixmap converted to a bitmap.
If the pixmap has a depth greater than 1, the resulting bitmap will be dithered automatically.
Definition at line 231 of file qbitmap.cpp.
QBitmap::operator QVariant | ( | ) | const |
Returns the bitmap as a QVariant.
Definition at line 138 of file qbitmap.cpp.
QBitmap QBitmap::transformed | ( | const QTransform & | matrix | ) | const |
Returns a copy of this bitmap, transformed according to the given matrix.
Definition at line 288 of file qbitmap.cpp.