您的位置:首页 > 编程语言 > Qt开发

QImage, QPixmap 的官方解释摘录

2014-06-05 11:50 591 查看
Qt provides four classes for handling image data: QImage, QPixmap, QBitmap and QPictureQImage is
designed and optimized for I/O, and for direct pixel access and manipulation, while QPixmap is designed and optimized for showing images on screen
QBitmap is
only a convenience class that inherits QPixmap
, ensuring a depth of 1. The isQBitmap() function returns true if a QPixmap
object is really a bitmap, otherwise returns false. Finally, the QPicture class is a paint device
that records and replays 
QPainter commands.

A QPixmap can easily be displayed on the screen using QLabel or one of QAbstractButton's
subclasses (such as QPushButton and QToolButton). QLabelhas
a pixmap property, whereas QAbstractButton has an icon property.

In addition to the ordinary constructors, a QPixmap can be constructed using the static grabWidget() and grabWindow()
functions which creates a QPixmap and paints the given widget, or window, into it.

QPixmap objects can be passed around by value since the QPixmap class uses implicit data sharing. For more information, see the Implicit
Data Sharingdocumentation. QPixmap objects can also be streamed.

Depending on the system, QPixmap is stored using a RGB32 or a premultiplied alpha format. If the image has an alpha channel, and if the system allows, the preferred format is premultiplied alpha. Note also that QPixmap, unlike QImage,
may be hardware dependent
. On X11, Mac and Symbian, a QPixmap is stored on the server side while a QImage is stored on the client
side (on Windows, these two classes have an equivalent internal representation, i.e. both QImage and QPixmap are stored on the client side
and don't use any GDI resources).

Note that the pixel data in a pixmap is internal and is managed by the underlying window system. Because QPixmap is a QPaintDevice subclass, QPaintercan
be used to draw directly onto pixmaps. Pixels can only be accessed through QPainter functions or by converting the QPixmap to a QImage.
However, the fill() function is available for initializing the entire pixmap with a given color.

There are functions to convert between QImage and QPixmap. Typically, the QImage class
is used to load an image file, optionally manipulating the image data, before the 
QImage object is converted
into a QPixmap to be shown on screen. 
Alternatively, if no manipulation is desired, the image file can be loaded directly into a QPixmap. On Windows, the QPixmap class also supports conversion between HBITMAP and
QPixmap. On Symbian, the QPixmap class also supports conversion between CFbsBitmap and QPixmap.

QPixmap provides a collection of functions that can be used to obtain a variety of information about the pixmap. In addition, there are several functions that enables transformation of the pixmap.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  qt qimage qpixmap