返回介绍

QCanvasPixmap Class

发布于 2019-10-04 14:58:41 字数 3144 浏览 1008 评论 0 收藏 0

The QCanvasPixmap class provides pixmaps for QCanvasSprites. More...

#include <qcanvas.h>

Inherits QPixmap.

List of all member functions.

Public Members

  • QCanvasPixmap ( constQString&datafilename )
  • QCanvasPixmap ( constQImage&image )
  • QCanvasPixmap ( constQPixmap&pm, constQPoint&offset )
  • ~QCanvasPixmap ()
  • int offsetX () const
  • int offsetY () const
  • void setOffset ( intx, inty )

Detailed Description

The QCanvasPixmap class provides pixmaps for QCanvasSprites.

If you want to show a single pixmap on a QCanvas use a QCanvasSprite with just one pixmap.

When pixmaps are inserted into a QCanvasPixmapArray they are held as QCanvasPixmaps. QCanvasSprites are used to show pixmaps on QCanvases and hold their pixmaps in a QCanvasPixmapArray. If you retrieve a frame (pixmap) from a QCanvasSprite it will be returned as a QCanvasPixmap.

The pixmap is a QPixmap and can only be set in the constructor. There are three different constructors, one taking a QPixmap, one a QImage and one a file name that refers to a file in any supported file format (see QImageIO).

QCanvasPixmap can have a hotspot which is defined in terms of an (x, y) offset. When you create a QCanvasPixmap from a PNG file or from a QImage that has a QImage::offset(), the offset() is initialized appropriately, otherwise the constructor leaves it at (0, 0). You can set it later using setOffset(). When the QCanvasPixmap is used in a QCanvasSprite, the offset position is the point at QCanvasItem::x() and QCanvasItem::y(), not the top-left corner of the pixmap.

Note that for QCanvasPixmap objects created by a QCanvasSprite, the position of each QCanvasPixmap object is set so that the hotspot stays in the same position.

See also QCanvasPixmapArray, QCanvasItem, QCanvasSprite, Graphics Classes and Image Processing Classes.


Member Function Documentation

QCanvasPixmap::QCanvasPixmap ( constQString&datafilename )

Constructs a QCanvasPixmap that uses the image stored in datafilename.

QCanvasPixmap::QCanvasPixmap ( constQImage&image )

Constructs a QCanvasPixmap from the image image.

QCanvasPixmap::QCanvasPixmap ( constQPixmap&pm, constQPoint&offset )

Constructs a QCanvasPixmap from the pixmap pm using the offset offset.

QCanvasPixmap::~QCanvasPixmap ()

Destroys the pixmap.

int QCanvasPixmap::offsetX () const

Returns the x-offset of the pixmap's hotspot.

See also setOffset().

int QCanvasPixmap::offsetY () const

Returns the y-offset of the pixmap's hotspot.

See also setOffset().

void QCanvasPixmap::setOffset ( intx, inty )

Sets the offset of the pixmap's hotspot to (x, y).

Warning: Do not call this function if any QCanvasSprites are currently showing this pixmap.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文