QBitmap Class Reference

[ QtGui module]

QBitmap 类提供单色 (1 位深度) 像素图。 更多...

继承 QPixmap .

方法

Static Methods


详细描述

QBitmap 类提供单色 (1 位深度) 像素图。

The QBitmap class is a monochrome off-screen paint device used mainly for creating custom QCursor and QBrush 对象,构造 QRegion objects, and for setting masks for pixmaps and widgets.

QBitmap 是 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.

使用 QColor 对象 Qt.color0 and Qt.color1 when drawing on a QBitmap object (or a QPixmap object with depth 1).

描绘采用 Qt.color0 将位图位设为 0,和描绘采用 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 () 函数以将所有位设为 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.

QBitmap 类提供 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 数据,而静态 fromImage () function returning a converted copy of a QImage 对象。

就像 QPixmap class, QBitmap is optimized by the use of implicit data sharing. For more information, see the Implicit Data Sharing 文档编制。


方法文档编制

QBitmap.__init__ ( self )

构造 null 位图。

另请参阅 QPixmap.isNull ().

QBitmap.__init__ ( self , QPixmap )

构造位图拷贝为给定 pixmap .

If the pixmap has a depth greater than 1, the resulting bitmap will be dithered automatically.

另请参阅 QPixmap.depth (), fromImage (),和 fromData ().

QBitmap.__init__ ( self , int  w , int  h )

构造位图,采用给定 width and height 。内部的像素未被初始化。

另请参阅 clear ().

QBitmap.__init__ ( self , QSize )

构造位图,采用给定 size . The pixels in the bitmap are uninitialized.

另请参阅 clear ().

QBitmap.__init__ ( self , QString  fileName , str  format  = None)

构造位图从文件指定通过给定 fileName . If the file does not exist, or has an unknown format, the bitmap becomes a null bitmap.

fileName and format parameters are passed on 到 QPixmap.load () function. If the file format uses more than 1 bit per pixel, the resulting bitmap will be dithered automatically.

另请参阅 QPixmap.isNull () 和 QImageReader.imageFormat ().

QBitmap.__init__ ( self , QVariant  variant )

QBitmap.__init__ ( self , QBitmap )

QBitmap.clear ( self )

清零位图,将其所有位设为 Qt.color0 .

QBitmap QBitmap.fromData ( QSize   size , str  bits , QImage.Format   format  = QImage.Format_MonoLSB)

构造位图,采用给定 size , and sets the contents to the bits 供给。

The bitmap data has to be byte aligned and provided in in the bit order specified by monoFormat . The mono format must be either QImage.Format_Mono or QImage.Format_MonoLSB 。使用 QImage.Format_Mono to specify data on the XBM format.

另请参阅 fromImage ().

QBitmap QBitmap.fromImage ( QImage   image , Qt.ImageConversionFlags   flags  = Qt.AutoColor)

返回拷贝为给定 image converted to a bitmap using the specified image conversion flags .

另请参阅 fromData ().

QBitmap.swap ( self , QBitmap   other )

交换位图 other with this bitmap. This operation is very fast and never fails.

该函数在 Qt 4.8 引入。

QBitmap QBitmap.transformed ( self , QMatrix )

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

另请参阅 QPixmap.transformed ().

QBitmap QBitmap.transformed ( self , QTransform   matrix )