CopperSpice API  1.9.1
QBitmap Class Reference

The QBitmap class provides monochrome (1-bit depth) pixmaps. More...

Inheritance diagram for QBitmap:
QPixmap QPaintDevice

Public Methods

 QBitmap ()
 
 QBitmap (const QPixmap &pixmap)
 
 QBitmap (const QSize &size)
 
 QBitmap (const QString &fileName, const QString &format=QString ())
 
 QBitmap (int width, int height)
 
 ~QBitmap ()
 
void clear ()
 
 operator QVariant () const
 
QBitmap & operator= (const QPixmap &pixmap)
 
void swap (QBitmap &other)
 
QBitmap transformed (const QMatrix &matrix) const
 
QBitmap transformed (const QTransform &matrix) const
 
- Public Methods inherited from QPixmap
 QPixmap ()
 
 QPixmap (const char *const xpm[])
 
 QPixmap (const QPixmap &pixmap)
 
 QPixmap (const QSize &size)
 
 QPixmap (const QString &fileName, const QString &format=QString (), Qt::ImageConversionFlags flags=Qt::AutoColor)
 
 QPixmap (int width, int height)
 
 ~QPixmap ()
 
qint64 cacheKey () const
 
bool convertFromImage (const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
 
QPixmap copy (const QRect &rect=QRect ()) const
 
QPixmap copy (int x, int y, int width, int height) const
 
QBitmap createHeuristicMask (bool clipTight=true) const
 
QBitmap createMaskFromColor (const QColor &maskColor, Qt::MaskMode mode=Qt::MaskInColor) const
 
int depth () const
 
void detach ()
 
qreal devicePixelRatio () const
 
void fill (const QColor &fillColor=Qt::white)
 
void fill (const QPaintDevice *device, const QPoint &offset)
 
void fill (const QPaintDevice *device, int xOffset, int yOffset)
 
QPlatformPixmaphandle () const
 
bool hasAlpha () const
 
bool hasAlphaChannel () const
 
int height () const
 
bool isNull () const
 
bool isQBitmap () const
 
bool load (const QString &fileName, const QString &format=QString (), Qt::ImageConversionFlags flags=Qt::AutoColor)
 
bool loadFromData (const QByteArray &data, const QString &format=QString (), Qt::ImageConversionFlags flags=Qt::AutoColor)
 
bool loadFromData (const uchar *data, uint len, const QString &format=QString (), Qt::ImageConversionFlags flags=Qt::AutoColor)
 
QBitmap mask () const
 
 operator QVariant () const
 
bool operator! () const
 
QPixmap & operator= (const QPixmap &other)
 
QPixmap & operator= (QPixmap &&other)
 
QPaintEnginepaintEngine () const override
 
QRect rect () const
 
bool save (const QString &fileName, const QString &format=QString (), int quality=-1) const
 
bool save (QIODevice *device, const QString &format=QString (), int quality=-1) const
 
QPixmap scaled (const QSize &size, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode transformMode=Qt::FastTransformation) const
 
QPixmap scaled (int width, int height, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode transformMode=Qt::FastTransformation) const
 
QPixmap scaledToHeight (int height, Qt::TransformationMode transformMode=Qt::FastTransformation) const
 
QPixmap scaledToWidth (int width, Qt::TransformationMode transformMode=Qt::FastTransformation) const
 
void scroll (int dx, int dy, const QRect &rect, QRegion *exposed=nullptr)
 
void scroll (int dx, int dy, int x, int y, int width, int height, QRegion *exposed=nullptr)
 
void setDevicePixelRatio (qreal scaleFactor)
 
void setMask (const QBitmap &mask)
 
QSize size () const
 
void swap (QPixmap &other)
 
QImage toImage () const
 
QPixmap transformed (const QMatrix &matrix, Qt::TransformationMode transformMode=Qt::FastTransformation) const
 
QPixmap transformed (const QTransform &transform, Qt::TransformationMode transformMode=Qt::FastTransformation) const
 
int width () const
 
- Public Methods inherited from QPaintDevice
virtual ~QPaintDevice ()
 
int colorCount () const
 
int depth () const
 
int devicePixelRatio () const
 
qreal devicePixelRatioF () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 

Static Public Methods

static QBitmap fromData (const QSize &size, const uchar *bits, QImage::Format monoFormat=QImage::Format_MonoLSB)
 
static QBitmap fromImage (const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
 
- Static Public Methods inherited from QPixmap
static int defaultDepth ()
 
static QPixmap fromImage (const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
 
static QPixmap fromImage (QImage &&image, Qt::ImageConversionFlags flags=Qt::AutoColor)
 
static QPixmap fromImageReader (QImageReader *imageReader, Qt::ImageConversionFlags flags=Qt::AutoColor)
 
static QPixmap grabWidget (QObject *widget, const QRect &rect)
 
static QPixmap grabWidget (QObject *widget, int x=0, int y=0, int width=-1, int height=-1)
 
static QPixmap grabWindow (WId window, int x=0, int y=0, int width=-1, int height=-1)
 
static QMatrix trueMatrix (const QMatrix &matrix, int width, int height)
 
static QTransform trueMatrix (const QTransform &transform, int width, int height)
 

Additional Inherited Members

- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric
 
- Protected Methods inherited from QPixmap
int metric (PaintDeviceMetric) const override
 
- Protected Methods inherited from QPaintDevice
 QPaintDevice ()
 

Detailed Description

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::color 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. 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, refer to the Implicit Data Sharing documentation.

See also
QPixmap, QImage, QImageReader, QImageWriter

Constructor & Destructor Documentation

QBitmap::QBitmap ( )

Constructs a null bitmap.

See also
QPixmap::isNull()
QBitmap::QBitmap ( const QPixmap pixmap)

Constructs a bitmap which is a copy of the given pixmap. If the pixmap has a depth greater than 1, the resulting bitmap will be dithered automatically.

See also
QPixmap::depth(), fromImage(), fromData()
QBitmap::QBitmap ( int  width,
int  height 
)

Constructs a bitmap with the given width and height. The pixels inside are uninitialized.

See also
clear()
QBitmap::QBitmap ( const QSize size)
explicit

Constructs a bitmap with the given size. The pixels in the bitmap are uninitialized.

See also
clear()
QBitmap::QBitmap ( const QString fileName,
const QString format = QString() 
)
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.

See also
QPixmap::isNull(), QImageReader::imageFormat()
QBitmap::~QBitmap ( )

Destroys the bitmap.

Method Documentation

void QBitmap::clear ( )
inline

Clears the bitmap, setting all its bits to Qt::color0.

QBitmap QBitmap::fromData ( const QSize size,
const uchar bits,
QImage::Format  monoFormat = QImage::Format_MonoLSB 
)
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.

See also
fromImage()
QBitmap QBitmap::fromImage ( const QImage image,
Qt::ImageConversionFlags  flags = Qt::AutoColor 
)
static

Returns a copy of the given image converted to a bitmap using the specified image conversion flags.

See also
fromData()
QBitmap::operator QVariant ( ) const

Returns the bitmap as a QVariant.

QBitmap & QBitmap::operator= ( const QPixmap pixmap)

Copy assigns from other and returns a reference to this object. If the pixmap has a depth greater than 1 the resulting bitmap will be dithered automatically.

See also
QPixmap::depth()
void QBitmap::swap ( QBitmap &  other)
inline

Swaps bitmap other with this bitmap. This operation is very fast and never fails.

QBitmap QBitmap::transformed ( const QMatrix matrix) const
deprecated
Deprecated:
This method converts the matrix to a QTransform and calls the overloaded method.
QBitmap QBitmap::transformed ( const QTransform matrix) const

Returns a copy of this bitmap, transformed according to the given matrix.

See also
QPixmap::transformed()