source: trunk/doc/html/qpicture.html@ 208

Last change on this file since 208 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 13.7 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qpicture.cpp:53 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QPicture Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QPicture Class Reference</h1>
33
34<p>The QPicture class is a paint device that records and
35replays QPainter commands.
36<a href="#details">More...</a>
37<p><tt>#include &lt;<a href="qpicture-h.html">qpicture.h</a>&gt;</tt>
38<p>Inherits <a href="qpaintdevice.html">QPaintDevice</a>.
39<p><a href="qpicture-members.html">List of all member functions.</a>
40<h2>Public Members</h2>
41<ul>
42<li class=fn><a href="#QPicture"><b>QPicture</b></a> ( int&nbsp;formatVersion = -1 )</li>
43<li class=fn><a href="#QPicture-2"><b>QPicture</b></a> ( const&nbsp;QPicture&nbsp;&amp;&nbsp;pic )</li>
44<li class=fn><a href="#~QPicture"><b>~QPicture</b></a> ()</li>
45<li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li>
46<li class=fn>uint <a href="#size"><b>size</b></a> () const</li>
47<li class=fn>const char * <a href="#data"><b>data</b></a> () const</li>
48<li class=fn>virtual void <a href="#setData"><b>setData</b></a> ( const&nbsp;char&nbsp;*&nbsp;data, uint&nbsp;size )</li>
49<li class=fn>bool <a href="#play"><b>play</b></a> ( QPainter&nbsp;*&nbsp;painter )</li>
50<li class=fn>bool <a href="#load-2"><b>load</b></a> ( QIODevice&nbsp;*&nbsp;dev, const&nbsp;char&nbsp;*&nbsp;format = 0 )</li>
51<li class=fn>bool <a href="#load"><b>load</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format = 0 )</li>
52<li class=fn>bool <a href="#save-2"><b>save</b></a> ( QIODevice&nbsp;*&nbsp;dev, const&nbsp;char&nbsp;*&nbsp;format = 0 )</li>
53<li class=fn>bool <a href="#save"><b>save</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format = 0 )</li>
54<li class=fn>QRect <a href="#boundingRect"><b>boundingRect</b></a> () const</li>
55<li class=fn>void <a href="#setBoundingRect"><b>setBoundingRect</b></a> ( const&nbsp;QRect&nbsp;&amp;&nbsp;r )</li>
56<li class=fn>QPicture &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QPicture&nbsp;&amp;&nbsp;p )</li>
57</ul>
58<h2>Protected Members</h2>
59<ul>
60<li class=fn>virtual int <a href="#metric"><b>metric</b></a> ( int&nbsp;m ) const</li>
61<li class=fn>void <a href="#detach"><b>detach</b></a> ()</li>
62<li class=fn>QPicture <a href="#copy"><b>copy</b></a> () const</li>
63</ul>
64<h2>Related Functions</h2>
65<ul>
66<li class=fn>QDataStream &amp; <a href="#operator-lt-lt"><b>operator&lt;&lt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, const&nbsp;QPicture&nbsp;&amp;&nbsp;r )</li>
67<li class=fn>QDataStream &amp; <a href="#operator-gt-gt"><b>operator&gt;&gt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, QPicture&nbsp;&amp;&nbsp;r )</li>
68</ul>
69<hr><a name="details"></a><h2>Detailed Description</h2>
70
71
72The QPicture class is a paint device that records and
73replays <a href="qpainter.html">QPainter</a> commands.
74<p>
75
76
77<p> A picture serializes painter commands to an IO device in a
78platform-independent format. For example, a picture created under
79Windows can be read on a Sun SPARC.
80<p> Pictures are called meta-files on some platforms.
81<p> Qt pictures use a proprietary binary format. Unlike native picture
82(meta-file) formats on many window systems, Qt pictures have no
83limitations regarding their contents. Everything that can be
84painted can also be stored in a picture, e.g. fonts, pixmaps,
85regions, transformed graphics, etc.
86<p> QPicture is an <a href="shclass.html">implicitly shared</a> class.
87<p> Example of how to record a picture:
88<pre>
89 QPicture pic;
90 <a href="qpainter.html">QPainter</a> p;
91 p.<a href="qpainter.html#begin">begin</a>( &amp;pic ); // paint in picture
92 p.<a href="qpainter.html#drawEllipse">drawEllipse</a>( 10,20, 80,70 ); // draw an ellipse
93 p.<a href="qpainter.html#end">end</a>(); // painting done
94 pic.<a href="#save">save</a>( "drawing.pic" ); // save picture
95 </pre>
96
97<p> Example of how to replay a picture:
98<pre>
99 QPicture pic;
100 pic.<a href="#load">load</a>( "drawing.pic" ); // load picture
101 <a href="qpainter.html">QPainter</a> p;
102 p.<a href="qpainter.html#begin">begin</a>( &amp;myWidget ); // paint in myWidget
103 p.<a href="qpainter.html#drawPicture">drawPicture</a>( pic ); // draw the picture
104 p.<a href="qpainter.html#end">end</a>(); // painting done
105 </pre>
106
107<p> Pictures can also be drawn using <a href="#play">play</a>(). Some basic data about a
108picture is available, for example, <a href="#size">size</a>(), <a href="#isNull">isNull</a>() and
109<a href="#boundingRect">boundingRect</a>().
110<p> <p>See also <a href="graphics.html">Graphics Classes</a>, <a href="images.html">Image Processing Classes</a>, and <a href="shared.html">Implicitly and Explicitly Shared Classes</a>.
111
112<hr><h2>Member Function Documentation</h2>
113<h3 class=fn><a name="QPicture"></a>QPicture::QPicture ( int&nbsp;formatVersion = -1 )
114</h3>
115Constructs an empty picture.
116<p> The <em>formatVersion</em> parameter may be used to <em>create</em> a QPicture
117that can be read by applications that are compiled with earlier
118versions of Qt.
119<ul>
120<li> <em>formatVersion</em> == 1 is binary compatible with Qt 1.x and later.
121<li> <em>formatVersion</em> == 2 is binary compatible with Qt 2.0.x and later.
122<li> <em>formatVersion</em> == 3 is binary compatible with Qt 2.1.x and later.
123<li> <em>formatVersion</em> == 4 is binary compatible with Qt 3.0.x and later.
124<li> <em>formatVersion</em> == 5 is binary compatible with Qt 3.1.
125</ul>
126<p> Note that the default formatVersion is -1 which signifies the
127current release, i.e. for Qt 3.1 a formatVersion of 5 is the same
128as the default formatVersion of -1.
129<p> Reading pictures generated by earlier versions of Qt is supported
130and needs no special coding; the format is automatically detected.
131
132<h3 class=fn><a name="QPicture-2"></a>QPicture::QPicture ( const&nbsp;<a href="qpicture.html">QPicture</a>&nbsp;&amp;&nbsp;pic )
133</h3>
134Constructs a <a href="shclass.html">shallow copy</a> of <em>pic</em>.
135
136<h3 class=fn><a name="~QPicture"></a>QPicture::~QPicture ()
137</h3>
138Destroys the picture.
139
140<h3 class=fn><a href="qrect.html">QRect</a> <a name="boundingRect"></a>QPicture::boundingRect () const
141</h3>
142Returns the picture's bounding rectangle or an invalid rectangle
143if the picture contains no data.
144
145<h3 class=fn><a href="qpicture.html">QPicture</a> <a name="copy"></a>QPicture::copy () const<tt> [protected]</tt>
146</h3>
147Returns a <a href="shclass.html">deep copy</a> of the picture.
148
149<h3 class=fn>const char * <a name="data"></a>QPicture::data () const
150</h3>
151
152<p> Returns a pointer to the picture data. The pointer is only valid
153until the next non-const function is called on this picture. The
154returned pointer is 0 if the picture contains no data.
155<p> <p>See also <a href="#size">size</a>() and <a href="#isNull">isNull</a>().
156
157<h3 class=fn>void <a name="detach"></a>QPicture::detach ()<tt> [protected]</tt>
158</h3>
159Detaches from shared picture data and makes sure that this picture
160is the only one referring to the data.
161<p> If multiple pictures share common data, this picture makes a copy
162of the data and detaches itself from the sharing mechanism.
163Nothing is done if there is just a single reference.
164
165<h3 class=fn>bool <a name="isNull"></a>QPicture::isNull () const
166</h3>
167
168<p> Returns TRUE if the picture contains no data; otherwise returns
169FALSE.
170
171<h3 class=fn>bool <a name="load"></a>QPicture::load ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format = 0 )
172</h3>
173Loads a picture from the file specified by <em>fileName</em> and returns
174TRUE if successful; otherwise returns FALSE.
175<p> By default, the file will be interpreted as being in the native
176QPicture format. Specifying the <em>format</em> string is optional and
177is only needed for importing picture data stored in a different
178format.
179<p> Currently, the only external format supported is the <a href="http://www.w3.org/Graphics/SVG/">W3C SVG</a> format which
180requires the <a href="xml.html">Qt XML module</a>. The
181corresponding <em>format</em> string is "svg".
182<p> <p>See also <a href="#save">save</a>().
183
184<p>Examples: <a href="picture-example.html#x122">picture/picture.cpp</a> and <a href="xform-example.html#x1244">xform/xform.cpp</a>.
185<h3 class=fn>bool <a name="load-2"></a>QPicture::load ( <a href="qiodevice.html">QIODevice</a>&nbsp;*&nbsp;dev, const&nbsp;char&nbsp;*&nbsp;format = 0 )
186</h3>
187This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
188<p> <em>dev</em> is the device to use for loading.
189
190<h3 class=fn>int <a name="metric"></a>QPicture::metric ( int&nbsp;m ) const<tt> [virtual protected]</tt>
191</h3>
192Internal implementation of the virtual QPaintDevice::metric()
193function.
194<p> Use the <a href="qpaintdevicemetrics.html">QPaintDeviceMetrics</a> class instead.
195<p> A picture has the following hard-coded values: dpi=72,
196numcolors=16777216 and depth=24.
197<p> <em>m</em> is the metric to get.
198
199<h3 class=fn><a href="qpicture.html">QPicture</a>&nbsp;&amp; <a name="operator-eq"></a>QPicture::operator= ( const&nbsp;<a href="qpicture.html">QPicture</a>&nbsp;&amp;&nbsp;p )
200</h3>
201Assigns a <a href="shclass.html">shallow copy</a> of <em>p</em> to this
202picture and returns a reference to this picture.
203
204<h3 class=fn>bool <a name="play"></a>QPicture::play ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;painter )
205</h3>
206Replays the picture using <em>painter</em>, and returns TRUE if
207successful; otherwise returns FALSE.
208<p> This function does exactly the same as <a href="qpainter.html#drawPicture">QPainter::drawPicture</a>()
209with (x, y) = (0, 0).
210
211<h3 class=fn>bool <a name="save"></a>QPicture::save ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format = 0 )
212</h3>
213Saves a picture to the file specified by <em>fileName</em> and returns
214TRUE if successful; otherwise returns FALSE.
215<p> Specifying the file <em>format</em> string is optional. It's not
216recommended unless you intend to export the picture data for
217use by a third party reader. By default the data will be saved in
218the native QPicture file format.
219<p> Currently, the only external format supported is the <a href="http://www.w3.org/Graphics/SVG/">W3C SVG</a> format which
220requires the <a href="xml.html">Qt XML module</a>. The
221corresponding <em>format</em> string is "svg".
222<p> <p>See also <a href="#load">load</a>().
223
224<p>Example: <a href="picture-example.html#x123">picture/picture.cpp</a>.
225<h3 class=fn>bool <a name="save-2"></a>QPicture::save ( <a href="qiodevice.html">QIODevice</a>&nbsp;*&nbsp;dev, const&nbsp;char&nbsp;*&nbsp;format = 0 )
226</h3>
227This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
228<p> <em>dev</em> is the device to use for saving.
229
230<h3 class=fn>void <a name="setBoundingRect"></a>QPicture::setBoundingRect ( const&nbsp;<a href="qrect.html">QRect</a>&nbsp;&amp;&nbsp;r )
231</h3>
232Sets the picture's bounding rectangle to <em>r</em>. The automatically
233calculated value is overriden.
234
235<h3 class=fn>void <a name="setData"></a>QPicture::setData ( const&nbsp;char&nbsp;*&nbsp;data, uint&nbsp;size )<tt> [virtual]</tt>
236</h3>
237Sets the picture data directly from <em>data</em> and <em>size</em>. This
238function copies the input data.
239<p> <p>See also <a href="#data">data</a>() and <a href="#size">size</a>().
240
241<h3 class=fn>uint <a name="size"></a>QPicture::size () const
242</h3>
243
244<p> Returns the size of the picture data.
245<p> <p>See also <a href="#data">data</a>().
246
247<hr><h2>Related Functions</h2>
248<h3 class=fn><a href="qdatastream.html">QDataStream</a>&nbsp;&amp; <a name="operator-lt-lt"></a>operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, const&nbsp;<a href="qpicture.html">QPicture</a>&nbsp;&amp;&nbsp;r )
249</h3>
250
251<p> Writes picture <em>r</em> to the stream <em>s</em> and returns a reference to
252the stream.
253
254<h3 class=fn><a href="qdatastream.html">QDataStream</a>&nbsp;&amp; <a name="operator-gt-gt"></a>operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, <a href="qpicture.html">QPicture</a>&nbsp;&amp;&nbsp;r )
255</h3>
256
257<p> Reads a picture from the stream <em>s</em> into picture <em>r</em> and returns
258a reference to the stream.
259
260<!-- eof -->
261<hr><p>
262This file is part of the <a href="index.html">Qt toolkit</a>.
263Copyright &copy; 1995-2007
264<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
265<table width=100% cellspacing=0 border=0><tr>
266<td>Copyright &copy; 2007
267<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
268<td align=right><div align=right>Qt 3.3.8</div>
269</table></div></address></body>
270</html>
Note: See TracBrowser for help on using the repository browser.