QBitmap

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

Inheritance diagram of PySide6.QtGui.QBitmap

Synopsis

Functions

Static functions

Detailed Description

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 color0 and color1 when drawing on a QBitmap object (or a QPixmap object with depth 1).

Painting with color0 sets the bitmap bits to 0, and painting with 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 color0 . Note that using the black and 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.

class PySide6.QtGui.QBitmap

PySide6.QtGui.QBitmap(QBitmap)

PySide6.QtGui.QBitmap(arg__1)

Note

This constructor is deprecated.

PySide6.QtGui.QBitmap(arg__1)

PySide6.QtGui.QBitmap(fileName[, format=None])

PySide6.QtGui.QBitmap(w, h)

Parameters

Constructs a null bitmap.

See also

isNull()

Use fromPixmap instead. 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.

See also

depth() fromImage() fromData()

Use fromPixmap instead.

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

See also

clear()

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 load() function. If the file format uses more than 1 bit per pixel, the resulting bitmap will be dithered automatically.

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

See also

clear()

PySide6.QtGui.QBitmap.clear()

Clears the bitmap, setting all its bits to color0 .

static PySide6.QtGui.QBitmap.fromData(size, bits[, monoFormat=QImage.Format_MonoLSB])
Parameters
Return type

PySide6.QtGui.QBitmap

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 Format_Mono or Format_MonoLSB . Use Format_Mono to specify data on the XBM format.

See also

fromImage()

static PySide6.QtGui.QBitmap.fromPixmap(pixmap)
Parameters

pixmapPySide6.QtGui.QPixmap

Return type

PySide6.QtGui.QBitmap

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.

See also

depth()

PySide6.QtGui.QBitmap.swap(other)
Parameters

otherPySide6.QtGui.QBitmap

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

PySide6.QtGui.QBitmap.transformed(matrix)
Parameters

matrixPySide6.QtGui.QTransform

Return type

PySide6.QtGui.QBitmap

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

See also

transformed()