PySide6.QtGui.QBitmap¶
- class QBitmap¶
- The - QBitmapclass provides monochrome (1-bit depth) pixmaps. More…- Synopsis¶- Methods¶- def - __init__()
- def - clear()
- def - swap()
- def - transformed()
 - Static functions¶- def - fromData()
- def - fromPixmap()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- The - QBitmapclass is a monochrome off-screen paint device used mainly for creating custom- QCursorand- QBrushobjects, constructing- QRegionobjects, and for setting masks for pixmaps and widgets.- QBitmapis a- QPixmapsubclass 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 - QColorobjects Qt::color0 and Qt::color1 when drawing on a- QBitmapobject (or a- QPixmapobject 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 - QBitmapclass provides the- transformed()function returning a transformed copy of the bitmap; use the- QTransformargument to translate, scale, shear, and rotate the bitmap. In addition,- QBitmapprovides the static- fromData()function which returns a bitmap constructed from the given- uchardata, and the static- fromImage()function returning a converted copy of a- QImageobject.- Just like the - QPixmapclass,- QBitmapis optimized by the use of implicit data sharing. For more information, see the Implicit Data Sharing documentation.- See also - __init__()¶
 - Constructs a null bitmap. - See also - __init__(pixmap)
- Parameters:
- pixmap – - QPixmap
 - Note - This function is deprecated. 
 - Use - fromPixmapinstead. 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()- __init__(size)
- Parameters:
- size – - QSize
 
 - Constructs a bitmap with the given - size. The pixels in the bitmap are uninitialized.- See also - __init__(fileName[, format=None])
- Parameters:
- fileName – str 
- format – str 
 
 
 - 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 - fileNameand- formatparameters 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.- See also - __init__(w, h)
- Parameters:
- w – int 
- h – int 
 
 
 - Constructs a bitmap with the given - widthand- height. The pixels inside are uninitialized.- See also - clear()¶
 - Clears the bitmap, setting all its bits to Qt::color0. - static fromData(size, bits[, monoFormat=QImage.Format_MonoLSB])¶
 - Constructs a bitmap with the given - size, and sets the contents to the- bitssupplied.- The bitmap data has to be byte aligned and provided in the bit order specified by - monoFormat. The mono format must be either- Format_Monoor- Format_MonoLSB. Use- Format_Monoto specify data on the XBM format.- See also - fromImage()- Returns a copy of the given - pixmapconverted to a bitmap.- If the pixmap has a depth greater than 1, the resulting bitmap will be dithered automatically. - See also - depth()- Swaps this bitmap with - other. This operation is very fast and never fails.- transformed(matrix)¶
- Parameters:
- matrix – - QTransform
- Return type:
 
 - Returns a copy of this bitmap, transformed according to the given - matrix.- See also