summaryrefslogtreecommitdiffstats
path: root/doc/html/qcanvaspixmaparray.html
blob: 5defc5ea0d6ee95d5f5daeb17135dfd0c3a83a6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/canvas/qcanvas.cpp:2930 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QCanvasPixmapArray Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QCanvasPixmapArray Class Reference<br><small>[<a href="canvas.html">canvas module</a>]</small></h1>

<p>The QCanvasPixmapArray class provides an array of QCanvasPixmaps.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qcanvas-h.html">qcanvas.h</a>&gt;</tt>
<p><a href="qcanvaspixmaparray-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#QCanvasPixmapArray"><b>QCanvasPixmapArray</b></a> ()</li>
<li class=fn><a href="#QCanvasPixmapArray-2"><b>QCanvasPixmapArray</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;datafilenamepattern, int&nbsp;fc = 0 )</li>
<li class=fn>QCanvasPixmapArray ( QPtrList&lt;QPixmap&gt;&nbsp;list, QPtrList&lt;QPoint&gt;&nbsp;hotspots ) &nbsp;<em>(obsolete)</em></li>
<li class=fn><a href="#QCanvasPixmapArray-4"><b>QCanvasPixmapArray</b></a> ( QValueList&lt;QPixmap&gt;&nbsp;list, QPointArray&nbsp;hotspots = QPointArray ( ) )</li>
<li class=fn><a href="#~QCanvasPixmapArray"><b>~QCanvasPixmapArray</b></a> ()</li>
<li class=fn>bool <a href="#readPixmaps"><b>readPixmaps</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;filenamepattern, int&nbsp;fc = 0 )</li>
<li class=fn>bool <a href="#readCollisionMasks"><b>readCollisionMasks</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;filename )</li>
<li class=fn>bool operator! () &nbsp;<em>(obsolete)</em></li>
<li class=fn>bool <a href="#isValid"><b>isValid</b></a> () const</li>
<li class=fn>QCanvasPixmap * <a href="#image"><b>image</b></a> ( int&nbsp;i ) const</li>
<li class=fn>void <a href="#setImage"><b>setImage</b></a> ( int&nbsp;i, QCanvasPixmap&nbsp;*&nbsp;p )</li>
<li class=fn>uint <a href="#count"><b>count</b></a> () const</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The QCanvasPixmapArray class provides an array of QCanvasPixmaps.

<p> 


<p> This class is used by <a href="qcanvassprite.html">QCanvasSprite</a> to hold an array of pixmaps.
It is used to implement animated sprites, i.e. images that change
over time, with each pixmap in the array holding one frame.
<p> Depending on the constructor you use you can load multiple pixmaps
into the array either from a directory (specifying a wildcard
pattern for the files), or from a list of QPixmaps. You can also
read in a set of pixmaps after construction using <a href="#readPixmaps">readPixmaps</a>().
<p> Individual pixmaps can be set with <a href="#setImage">setImage</a>() and retrieved with
<a href="#image">image</a>(). The number of pixmaps in the array is returned by
<a href="#count">count</a>().
<p> QCanvasSprite uses an image's mask for collision detection. You
can change this by reading in a separate set of image masks using
<a href="#readCollisionMasks">readCollisionMasks</a>().
<p> <p>See also <a href="graphics.html">Graphics Classes</a> and <a href="images.html">Image Processing Classes</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QCanvasPixmapArray"></a>QCanvasPixmapArray::QCanvasPixmapArray ()
</h3>
Constructs an invalid array (i.e. <a href="#isValid">isValid</a>() will return FALSE).
You must call <a href="#readPixmaps">readPixmaps</a>() before being able to use this
QCanvasPixmapArray.

<h3 class=fn><a name="QCanvasPixmapArray-2"></a>QCanvasPixmapArray::QCanvasPixmapArray ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;datafilenamepattern, int&nbsp;fc = 0 )
</h3>
Constructs a QCanvasPixmapArray from files.
<p> The <em>fc</em> parameter sets the number of frames to be loaded for
this image.
<p> If <em>fc</em> is not 0, <em>datafilenamepattern</em> should contain "%1",
e.g. "foo%1.png". The actual filenames are formed by replacing the
%1 with four-digit integers from 0 to (fc - 1), e.g. foo0000.png,
foo0001.png, foo0002.png, etc.
<p> If <em>fc</em> is 0, <em>datafilenamepattern</em> is asssumed to be a
filename, and the image contained in this file will be loaded as
the first (and only) frame.
<p> If <em>datafilenamepattern</em> does not exist, is not readable, isn't
an image, or some other error occurs, the array ends up empty and
<a href="#isValid">isValid</a>() returns FALSE.

<h3 class=fn><a name="QCanvasPixmapArray-3"></a>QCanvasPixmapArray::QCanvasPixmapArray ( <a href="qptrlist.html">QPtrList</a>&lt;QPixmap&gt;&nbsp;list, <a href="qptrlist.html">QPtrList</a>&lt;QPoint&gt;&nbsp;hotspots )
</h3>
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> Use <a href="#QCanvasPixmapArray">QCanvasPixmapArray::QCanvasPixmapArray</a>( <a href="qvaluelist.html">QValueList</a><QPixmap>, <a href="qpointarray.html">QPointArray</a> )
instead.
<p> Constructs a QCanvasPixmapArray from the list of QPixmaps <em>list</em>. The <em>hotspots</em> list has to be of the same size as <em>list</em>.

<h3 class=fn><a name="QCanvasPixmapArray-4"></a>QCanvasPixmapArray::QCanvasPixmapArray ( <a href="qvaluelist.html">QValueList</a>&lt;QPixmap&gt;&nbsp;list, <a href="qpointarray.html">QPointArray</a>&nbsp;hotspots = QPointArray ( ) )
</h3>
Constructs a QCanvasPixmapArray from the list of QPixmaps in the
<em>list</em>. Each pixmap will get a hotspot according to the <em>hotspots</em> array. If no hotspots are specified, each one is set to
be at position (0, 0).
<p> If an error occurs, <a href="#isValid">isValid</a>() will return FALSE.

<h3 class=fn><a name="~QCanvasPixmapArray"></a>QCanvasPixmapArray::~QCanvasPixmapArray ()
</h3>
Destroys the pixmap array and all the pixmaps it contains.

<h3 class=fn>uint <a name="count"></a>QCanvasPixmapArray::count () const
</h3>

<p> Returns the number of pixmaps in the array.

<h3 class=fn><a href="qcanvaspixmap.html">QCanvasPixmap</a>&nbsp;* <a name="image"></a>QCanvasPixmapArray::image ( int&nbsp;i ) const
</h3>

<p> Returns pixmap <em>i</em> in the array, if <em>i</em> is non-negative and less
than than <a href="#count">count</a>(), and returns an unspecified value otherwise.

<h3 class=fn>bool <a name="isValid"></a>QCanvasPixmapArray::isValid () const
</h3>
Returns TRUE if the pixmap array is valid; otherwise returns
FALSE.

<h3 class=fn>bool <a name="operator!"></a>QCanvasPixmapArray::operator! ()
</h3>
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> Use <a href="#isValid">isValid</a>() instead.
<p> This returns FALSE if the array is valid, and TRUE if it is not.

<h3 class=fn>bool <a name="readCollisionMasks"></a>QCanvasPixmapArray::readCollisionMasks ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filename )
</h3>
Reads new collision masks for the array.
<p> By default, <a href="qcanvassprite.html">QCanvasSprite</a> uses the image mask of a sprite to
detect collisions. Use this function to set your own collision
image masks.
<p> If <a href="#count">count</a>() is 1 <em>filename</em> must specify a real filename to read
the mask from. If count() is greater than 1, the <em>filename</em> must
contain a "%1" that will get replaced by the number of the mask to
be loaded, just like <a href="#readPixmaps">QCanvasPixmapArray::readPixmaps</a>().
<p> All collision masks must be 1-bit images or this function call
will fail.
<p> If the file isn't readable, contains the wrong number of images,
or there is some other error, this function will return FALSE, and
the array will be flagged as invalid; otherwise this function
returns TRUE.
<p> <p>See also <a href="#isValid">isValid</a>().

<h3 class=fn>bool <a name="readPixmaps"></a>QCanvasPixmapArray::readPixmaps ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filenamepattern, int&nbsp;fc = 0 )
</h3>
Reads one or more pixmaps into the pixmap array.
<p> If <em>fc</em> is not 0, <em>filenamepattern</em> should contain "%1", e.g.
"foo%1.png". The actual filenames are formed by replacing the %1
with four-digit integers from 0 to (fc - 1), e.g. foo0000.png,
foo0001.png, foo0002.png, etc.
<p> If <em>fc</em> is 0, <em>filenamepattern</em> is asssumed to be a filename,
and the image contained in this file will be loaded as the first
(and only) frame.
<p> If <em>filenamepattern</em> does not exist, is not readable, isn't an
image, or some other error occurs, this function will return
FALSE, and <a href="#isValid">isValid</a>() will return FALSE; otherwise this function
will return TRUE.
<p> <p>See also <a href="#isValid">isValid</a>().

<h3 class=fn>void <a name="setImage"></a>QCanvasPixmapArray::setImage ( int&nbsp;i, <a href="qcanvaspixmap.html">QCanvasPixmap</a>&nbsp;*&nbsp;p )
</h3>
Replaces the pixmap at index <em>i</em> with pixmap <em>p</em>.
<p> The array takes ownership of <em>p</em> and will delete <em>p</em> when the
array itself is deleted.
<p> If <em>i</em> is beyond the end of the array the array is extended to at
least i+1 elements, with elements <a href="#count">count</a>() to i-1 being initialized
to 0.

<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.8</div>
</table></div></address></body>
</html>