QtCanvasPixmap Class Reference

The QtCanvasPixmap class provides pixmaps for QtCanvasSprites. More...

#include <QtCanvasPixmap>

Inherits QPixmap.

Public Functions

Additional Inherited Members


Detailed Description

The QtCanvasPixmap class provides pixmaps for QtCanvasSprites.

If you want to show a single pixmap on a QtCanvas use a QtCanvasSprite with just one pixmap.

When pixmaps are inserted into a QtCanvasPixmapArray they are held as QtCanvasPixmaps. QtCanvasSprites are used to show pixmaps on QtCanvases and hold their pixmaps in a QtCanvasPixmapArray. If you retrieve a frame (pixmap) from a QtCanvasSprite it will be returned as a QtCanvasPixmap.

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 QImageReader).

QtCanvasPixmap can have a hotspot which is defined in terms of an (x, y) offset. When you create a QtCanvasPixmap 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 QtCanvasPixmap is used in a QtCanvasSprite, the offset position is the point at QtCanvasItem::x() and QtCanvasItem::y(), not the top-left corner of the pixmap.

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

See also QtCanvasPixmapArray, QtCanvasItem, and QtCanvasSprite.


Member Function Documentation

QtCanvasPixmap::QtCanvasPixmap ( const QString & datafilename )

Constructs a QtCanvasPixmap that uses the image stored in datafilename.

QtCanvasPixmap::QtCanvasPixmap ( const QImage & image )

Constructs a QtCanvasPixmap from the image image.

QtCanvasPixmap::QtCanvasPixmap ( const QPixmap & pm, const QPoint & offset )

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

QtCanvasPixmap::~QtCanvasPixmap ()

Destroys the pixmap.

int QtCanvasPixmap::offsetX () const

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

See also setOffset().

int QtCanvasPixmap::offsetY () const

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

See also setOffset().

void QtCanvasPixmap::setOffset ( int x, int y )

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

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


Copyright © 2005 Trolltech Trademarks