QBitmap 类

QBitmap class provides monochrome (1-bit depth) pixmaps. 更多...

头: #include <QBitmap>
qmake: QT += gui
继承: QPixmap

公共函数

QBitmap ()
QBitmap (const QPixmap & pixmap )
QBitmap (int width , int height )
QBitmap (const QSize & size )
QBitmap (const QString & fileName , const char * format = Q_NULLPTR)
QBitmap (const QBitmap & other )
~QBitmap ()
void clear ()
void swap (QBitmap & other )
QBitmap transformed (const QTransform & matrix ) const
operator QVariant () const
QBitmap & operator= (const QBitmap & other )
QBitmap & operator= (QBitmap && other )
QBitmap & operator= (const QPixmap & pixmap )

静态公共成员

QBitmap fromData (const QSize & size , const uchar * bits , QImage::Format monoFormat = QImage::Format_MonoLSB)
QBitmap fromImage (const QImage & image , Qt::ImageConversionFlags flags = Qt::AutoColor)
  • 6 static public members inherited from QPixmap

额外继承成员

详细描述

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

QBitmap class is a monochrome off-screen paint device used mainly for creating custom QCursor and QBrush 对象,构造 QRegion 对象,及为像素图和 Widget 设置遮罩。

QBitmap QPixmap 子类确保 1 深度,除 0 深度的 null 对象外。若将深度大于 1 的像素图赋值给位图,位图会自动抖动。

使用 QColor 对象 Qt::color0 and Qt::color1 when drawing on a QBitmap object (or a QPixmap 对象采用 1 深度)。

描绘采用 Qt::color0 将位图位设为 0,和描绘采用 Qt::color1 将位图位设为 1。对于位图而言,0 位指示背景 (或透明像素),而 1 位指示前景 (或不透明像素)。使用 clear () 函数以将所有位设为 Qt::color0 。注意,使用 Qt::black and Qt::white 颜色没有意义,因为 QColor::pixel() 值并不一定是黑色为 0,而白色为 1。

QBitmap class provides the transformed () 函数返回位图的变换拷贝;使用 QTransform argument to translate, scale, shear, and rotate the bitmap. In addition, QBitmap provides the static fromData () 函数,返回构造位图从给定 uchar 数据,而静态 fromImage () 函数返回转换拷贝为 QImage 对象。

就像 QPixmap class, QBitmap is optimized by the use of implicit data sharing. For more information, see the 隐式数据共享 文档编制。

另请参阅 QPixmap , QImage , QImageReader ,和 QImageWriter .

成员函数文档编制

QBitmap:: QBitmap ()

构造 null 位图。

另请参阅 QPixmap::isNull ().

QBitmap:: QBitmap (const QPixmap & pixmap )

构造位图拷贝为给定 pixmap .

若像素图深度大于 1,则结果位图会自动抖动。

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

QBitmap:: QBitmap ( int width , int height )

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

另请参阅 clear ().

QBitmap:: QBitmap (const QSize & size )

构造位图采用给定 size 。位图中的像素未被初始化。

另请参阅 clear ().

QBitmap:: QBitmap (const QString & fileName , const char * format = Q_NULLPTR)

构造位图从指定文件通过给定 fileName 。若文件不存在或格式未知,则位图变为 null 位图。

fileName and format 参数被传递给 QPixmap::load () 函数。若文件格式使用 1 位以上每像素,则结果位图会自动抖动。

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

QBitmap:: QBitmap (const QBitmap & other )

Copy constructor.

QBitmap:: ~QBitmap ()

销毁位图。

void QBitmap:: clear ()

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

[static] QBitmap QBitmap:: fromData (const QSize & size , const uchar * bits , QImage::Format monoFormat = QImage::Format_MonoLSB)

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

位图数据必须按字节对齐,并按指定位次序提供通过 monoFormat 。单色格式必须是 QImage::Format_Mono or QImage::Format_MonoLSB 。使用 QImage::Format_Mono 指定 XBM 格式数据。

另请参阅 fromImage ().

[static] QBitmap QBitmap:: fromImage (const QImage & image , Qt::ImageConversionFlags flags = Qt::AutoColor)

返回副本为给定 image 转换为位图,使用指定图像转换 flags .

另请参阅 fromData ().

void QBitmap:: swap ( QBitmap & other )

交换位图 other 与此位图。此操作非常快且从不失败。

该函数在 Qt 4.8 引入。

QBitmap QBitmap:: transformed (const QTransform & matrix ) const

返回此位图的拷贝,变换根据给定 matrix .

另请参阅 QPixmap::transformed ().

QBitmap:: operator QVariant () const

将位图返回为 QVariant .

QBitmap &QBitmap:: operator= (const QBitmap & other )

Copy-assignment operator.

QBitmap &QBitmap:: operator= ( QBitmap && other )

移动赋值运算符。

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

这是重载函数。

赋值给定 pixmap 到此位图并返回此位图的引用。

若像素图深度大于 1,则结果位图会自动抖动。

另请参阅 QPixmap::depth ().