Bitmap of Qt

The QBitmap class provides a monochrome (monochrome, 1 bit depth) pixel map.

QBitmap class is a monochrome off-screen drawing device, which is mainly used to create custom QCursor and QBrush objects, construct QRegion objects, and set masks for pixmaps and widgets.

QBitmap is a subclass of QPixmap, which ensures that the depth is 1, except for empty objects with a depth of 0. If you assign a pixel map with a depth greater than 1 to the bitmap, the bitmap will automatically shake.

Use QColor objects color0 and color 1 when drawing on a QBitmap object (or a QPixmap object with a depth of1). Drawing with color0 will set the bitmap bit to 0, and drawing with color 1 will set the bitmap bit to 1. For bitmaps, bit 0 represents the background (or transparent pixel), and bit 1 represents the foreground (or opaque pixel). Use the clear () function to set all bits to color0. Note that it is meaningless to use black and white, because the value of QColor::pixel () is not necessarily 0 for black and 1 for white.

The QBitmap class provides the transformd () function, which returns a transformed copy of the bitmap; Use QTransform parameters to translate, scale, cut, and rotate bitmaps. In addition, QBitmap also provides a static fromData () function, which returns a bitmap constructed from the given uchar data, and a static fromImage () function, which returns a copy of the transformed QImage object.

Just like the QPixmap class, QBitmap is optimized by using implicit data sharing. For more information, see the implicit data sharing document.