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

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

reference documentation added

File size: 53.6 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/qpixmap.cpp:53 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QPixmap 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>QPixmap Class Reference</h1>
33
34<p>The QPixmap class is an off-screen, pixel-based paint device.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qpixmap-h.html">qpixmap.h</a>&gt;</tt>
37<p>Inherits <a href="qpaintdevice.html">QPaintDevice</a> and <a href="qt.html">Qt</a>.
38<p>Inherited by <a href="qbitmap.html">QBitmap</a> and <a href="qcanvaspixmap.html">QCanvasPixmap</a>.
39<p><a href="qpixmap-members.html">List of all member functions.</a>
40<h2>Public Members</h2>
41<ul>
42<li class=fn>enum <a href="#ColorMode-enum"><b>ColorMode</b></a> { Auto, Color, Mono }</li>
43<li class=fn>enum <a href="#Optimization-enum"><b>Optimization</b></a> { DefaultOptim, NoOptim, MemoryOptim = NoOptim, NormalOptim, BestOptim }</li>
44<li class=fn><a href="#QPixmap"><b>QPixmap</b></a> ()</li>
45<li class=fn><a href="#QPixmap-2"><b>QPixmap</b></a> ( const&nbsp;QImage&nbsp;&amp;&nbsp;image )</li>
46<li class=fn><a href="#QPixmap-3"><b>QPixmap</b></a> ( int&nbsp;w, int&nbsp;h, int&nbsp;depth = -1, Optimization&nbsp;optimization = DefaultOptim )</li>
47<li class=fn><a href="#QPixmap-4"><b>QPixmap</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;size, int&nbsp;depth = -1, Optimization&nbsp;optimization = DefaultOptim )</li>
48<li class=fn><a href="#QPixmap-5"><b>QPixmap</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format = 0, ColorMode&nbsp;mode = Auto )</li>
49<li class=fn><a href="#QPixmap-6"><b>QPixmap</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format, int&nbsp;conversion_flags )</li>
50<li class=fn><a href="#QPixmap-7"><b>QPixmap</b></a> ( const&nbsp;char&nbsp;*&nbsp;xpm[] )</li>
51<li class=fn><a href="#QPixmap-8"><b>QPixmap</b></a> ( const&nbsp;QByteArray&nbsp;&amp;&nbsp;img_data )</li>
52<li class=fn><a href="#QPixmap-9"><b>QPixmap</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap )</li>
53<li class=fn><a href="#~QPixmap"><b>~QPixmap</b></a> ()</li>
54<li class=fn>QPixmap &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap )</li>
55<li class=fn>QPixmap &amp; <a href="#operator-eq-2"><b>operator=</b></a> ( const&nbsp;QImage&nbsp;&amp;&nbsp;image )</li>
56<li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li>
57<li class=fn>int <a href="#width"><b>width</b></a> () const</li>
58<li class=fn>int <a href="#height"><b>height</b></a> () const</li>
59<li class=fn>QSize <a href="#size"><b>size</b></a> () const</li>
60<li class=fn>QRect <a href="#rect"><b>rect</b></a> () const</li>
61<li class=fn>int <a href="#depth"><b>depth</b></a> () const</li>
62<li class=fn>void <a href="#fill"><b>fill</b></a> ( const&nbsp;QColor&nbsp;&amp;&nbsp;fillColor = Qt::white )</li>
63<li class=fn>void <a href="#fill-2"><b>fill</b></a> ( const&nbsp;QWidget&nbsp;*&nbsp;widget, int&nbsp;xofs, int&nbsp;yofs )</li>
64<li class=fn>void <a href="#fill-3"><b>fill</b></a> ( const&nbsp;QWidget&nbsp;*&nbsp;widget, const&nbsp;QPoint&nbsp;&amp;&nbsp;ofs )</li>
65<li class=fn>void <a href="#resize"><b>resize</b></a> ( int&nbsp;w, int&nbsp;h )</li>
66<li class=fn>void <a href="#resize-2"><b>resize</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;size )</li>
67<li class=fn>const QBitmap * <a href="#mask"><b>mask</b></a> () const</li>
68<li class=fn>void <a href="#setMask"><b>setMask</b></a> ( const&nbsp;QBitmap&nbsp;&amp;&nbsp;newmask )</li>
69<li class=fn>bool <a href="#selfMask"><b>selfMask</b></a> () const</li>
70<li class=fn>bool <a href="#hasAlpha"><b>hasAlpha</b></a> () const</li>
71<li class=fn>bool <a href="#hasAlphaChannel"><b>hasAlphaChannel</b></a> () const</li>
72<li class=fn>QBitmap <a href="#createHeuristicMask"><b>createHeuristicMask</b></a> ( bool&nbsp;clipTight = TRUE ) const</li>
73<li class=fn>QPixmap <a href="#xForm"><b>xForm</b></a> ( const&nbsp;QWMatrix&nbsp;&amp;&nbsp;matrix ) const</li>
74<li class=fn>QImage <a href="#convertToImage"><b>convertToImage</b></a> () const</li>
75<li class=fn>bool <a href="#convertFromImage-2"><b>convertFromImage</b></a> ( const&nbsp;QImage&nbsp;&amp;&nbsp;image, ColorMode&nbsp;mode = Auto )</li>
76<li class=fn>bool <a href="#convertFromImage"><b>convertFromImage</b></a> ( const&nbsp;QImage&nbsp;&amp;&nbsp;img, int&nbsp;conversion_flags )</li>
77<li class=fn>bool <a href="#load-2"><b>load</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format = 0, ColorMode&nbsp;mode = Auto )</li>
78<li class=fn>bool <a href="#load"><b>load</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format, int&nbsp;conversion_flags )</li>
79<li class=fn>bool <a href="#loadFromData-2"><b>loadFromData</b></a> ( const&nbsp;uchar&nbsp;*&nbsp;buf, uint&nbsp;len, const&nbsp;char&nbsp;*&nbsp;format = 0, ColorMode&nbsp;mode = Auto )</li>
80<li class=fn>bool <a href="#loadFromData"><b>loadFromData</b></a> ( const&nbsp;uchar&nbsp;*&nbsp;buf, uint&nbsp;len, const&nbsp;char&nbsp;*&nbsp;format, int&nbsp;conversion_flags )</li>
81<li class=fn>bool <a href="#loadFromData-3"><b>loadFromData</b></a> ( const&nbsp;QByteArray&nbsp;&amp;&nbsp;buf, const&nbsp;char&nbsp;*&nbsp;format = 0, int&nbsp;conversion_flags = 0 )</li>
82<li class=fn>bool <a href="#save"><b>save</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format, int&nbsp;quality = -1 ) const</li>
83<li class=fn>bool <a href="#save-2"><b>save</b></a> ( QIODevice&nbsp;*&nbsp;device, const&nbsp;char&nbsp;*&nbsp;format, int&nbsp;quality = -1 ) const</li>
84<li class=fn>int <a href="#serialNumber"><b>serialNumber</b></a> () const</li>
85<li class=fn>Optimization <a href="#optimization"><b>optimization</b></a> () const</li>
86<li class=fn>void <a href="#setOptimization"><b>setOptimization</b></a> ( Optimization&nbsp;optimization )</li>
87<li class=fn>virtual void <a href="#detach"><b>detach</b></a> ()</li>
88<li class=fn>bool <a href="#isQBitmap"><b>isQBitmap</b></a> () const</li>
89</ul>
90<h2>Static Public Members</h2>
91<ul>
92<li class=fn>int <a href="#defaultDepth"><b>defaultDepth</b></a> ()</li>
93<li class=fn>QPixmap <a href="#fromMimeSource"><b>fromMimeSource</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;abs_name )</li>
94<li class=fn>QPixmap <a href="#grabWindow"><b>grabWindow</b></a> ( WId&nbsp;window, int&nbsp;x = 0, int&nbsp;y = 0, int&nbsp;w = -1, int&nbsp;h = -1 )</li>
95<li class=fn>QPixmap <a href="#grabWidget"><b>grabWidget</b></a> ( QWidget&nbsp;*&nbsp;widget, int&nbsp;x = 0, int&nbsp;y = 0, int&nbsp;w = -1, int&nbsp;h = -1 )</li>
96<li class=fn>QWMatrix <a href="#trueMatrix"><b>trueMatrix</b></a> ( const&nbsp;QWMatrix&nbsp;&amp;&nbsp;matrix, int&nbsp;w, int&nbsp;h )</li>
97<li class=fn>const char * <a href="#imageFormat"><b>imageFormat</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName )</li>
98<li class=fn>Optimization <a href="#defaultOptimization"><b>defaultOptimization</b></a> ()</li>
99<li class=fn>void <a href="#setDefaultOptimization"><b>setDefaultOptimization</b></a> ( Optimization&nbsp;optimization )</li>
100</ul>
101<h2>Protected Members</h2>
102<ul>
103<li class=fn><a href="#QPixmap-a"><b>QPixmap</b></a> ( int&nbsp;w, int&nbsp;h, const&nbsp;uchar&nbsp;*&nbsp;bits, bool&nbsp;isXbitmap )</li>
104<li class=fn>virtual int <a href="#metric"><b>metric</b></a> ( int&nbsp;m ) const</li>
105</ul>
106<h2>Related Functions</h2>
107<ul>
108<li class=fn>QDataStream &amp; <a href="#operator-lt-lt"><b>operator&lt;&lt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap )</li>
109<li class=fn>QDataStream &amp; <a href="#operator-gt-gt"><b>operator&gt;&gt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, QPixmap&nbsp;&amp;&nbsp;pixmap )</li>
110<li class=fn>void <a href="#copyBlt"><b>copyBlt</b></a> ( QPixmap&nbsp;*&nbsp;dst, int&nbsp;dx, int&nbsp;dy, const&nbsp;QPixmap&nbsp;*&nbsp;src, int&nbsp;sx, int&nbsp;sy, int&nbsp;sw, int&nbsp;sh )</li>
111</ul>
112<hr><a name="details"></a><h2>Detailed Description</h2>
113
114
115The QPixmap class is an off-screen, pixel-based paint device.
116<p>
117
118
119
120<p> QPixmap is one of the two classes Qt provides for dealing with
121images; the other is <a href="qimage.html">QImage</a>. QPixmap is designed and optimized
122for drawing; QImage is designed and optimized for I/O and for
123direct pixel access/manipulation. There are (slow) functions to
124convert between QImage and QPixmap: <a href="#convertToImage">convertToImage</a>() and
125<a href="#convertFromImage">convertFromImage</a>().
126<p> One common use of the QPixmap class is to enable smooth updating
127of widgets. Whenever something complex needs to be drawn, you can
128use a pixmap to obtain flicker-free drawing, like this:
129<p> <ol type=1>
130<li> Create a pixmap with the same size as the widget.
131<li> Fill the pixmap with the widget background color.
132<li> Paint the pixmap.
133<li> <a href="qpaintdevice.html#bitBlt">bitBlt</a>() the pixmap contents onto the widget.
134</ol>
135<p> Pixel data in a pixmap is internal and is managed by the
136underlying window system. Pixels can be accessed only through
137<a href="qpainter.html">QPainter</a> functions, through bitBlt(), and by converting the
138QPixmap to a QImage.
139<p> You can easily display a QPixmap on the screen using
140<a href="qlabel.html#setPixmap">QLabel::setPixmap</a>(). For example, all the <a href="qbutton.html">QButton</a> subclasses
141support pixmap use.
142<p> The QPixmap class uses <a href="shclass.html">copy-on-write</a>,
143so it is practical to pass QPixmap objects by value.
144<p> You can retrieve the <a href="#width">width</a>(), <a href="#height">height</a>(), <a href="#depth">depth</a>() and <a href="#size">size</a>() of a
145pixmap. The enclosing rectangle is given by <a href="#rect">rect</a>(). Pixmaps can be
146filled with <a href="#fill">fill</a>() and resized with <a href="#resize">resize</a>(). You can create and
147set a mask with <a href="#createHeuristicMask">createHeuristicMask</a>() and <a href="#setMask">setMask</a>(). Use
148<a href="#selfMask">selfMask</a>() to see if the pixmap is identical to its mask.
149<p> In addition to loading a pixmap from file using <a href="#load">load</a>() you can
150also <a href="#loadFromData">loadFromData</a>(). You can control optimization with
151<a href="#setOptimization">setOptimization</a>() and obtain a transformed version of the pixmap
152using <a href="#xForm">xForm</a>()
153<p> Note regarding Windows 95 and 98: on Windows 9x the system crashes
154if you create more than about 1000 pixmaps, independent of the
155size of the pixmaps or installed RAM. Windows NT-systems (including
1562000, XP and following versions) do not have the same limitation,
157but depending on the graphics equipment the system will fail to
158allocate pixmap objects at some point (due to system running out of
159GDI resources).
160<p> Qt tries to work around the resource limitation. If you set the
161pixmap optimization to <a href="#Optimization-enum">QPixmap::MemoryOptim</a> and the width of
162your pixmap is less than or equal to 128 pixels, Qt stores the
163pixmap in a way that is very memory-efficient when there are many
164pixmaps.
165<p> If your application uses dozens or hundreds of pixmaps (for
166example on tool bar buttons and in popup menus), and you plan to
167run it on Windows 95 or Windows 98, we recommend using code like
168this:
169<p> <pre>
170 QPixmap::<a href="#setDefaultOptimization">setDefaultOptimization</a>( QPixmap::<a href="#Optimization-enum">MemoryOptim</a> );
171 while ( ... ) {
172 // load tool bar pixmaps etc.
173 QPixmap *pixmap = new QPixmap(fileName);
174 }
175 QPixmap::<a href="#setDefaultOptimization">setDefaultOptimization</a>( QPixmap::<a href="#Optimization-enum">NormalOptim</a> );
176 </pre>
177
178<p> In general it is recommended to make as much use of QPixmap's
179<a href="shclass.html#implicit-sharing">implicit sharing</a> and the <a href="qpixmapcache.html">QPixmapCache</a> as possible.
180<p> <p>See also <a href="qbitmap.html">QBitmap</a>, <a href="qimage.html">QImage</a>, <a href="qimageio.html">QImageIO</a>, <a href="shclass.html">Shared Classes</a>, <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>.
181
182<hr><h2>Member Type Documentation</h2>
183<h3 class=fn><a name="ColorMode-enum"></a>QPixmap::ColorMode</h3>
184
185<p> This enum type defines the color modes that exist for converting
186<a href="qimage.html">QImage</a> objects to QPixmap.
187<ul>
188<li><tt>QPixmap::Auto</tt> - Select <a href="#ColorMode-enum">Color</a> or <a href="#ColorMode-enum">Mono</a> on a case-by-case basis.
189<li><tt>QPixmap::Color</tt> - Always create colored pixmaps.
190<li><tt>QPixmap::Mono</tt> - Always create bitmaps.
191</ul>
192<h3 class=fn><a name="Optimization-enum"></a>QPixmap::Optimization</h3>
193
194<p> QPixmap has the choice of optimizing for speed or memory in a few
195places; the best choice varies from pixmap to pixmap but can
196generally be derived heuristically. This enum type defines a
197number of optimization modes that you can set for any pixmap to
198tweak the speed/memory tradeoffs:
199<ul>
200<li><tt>QPixmap::DefaultOptim</tt> - Whatever <a href="#defaultOptimization">QPixmap::defaultOptimization</a>()
201returns. A pixmap with this optimization will have whatever
202the current default optimization is. If the default
203optimization is changed using <a href="#setDefaultOptimization">setDefaultOptimization</a>(), then
204this will not effect any pixmaps that have already been
205created.
206<li><tt>QPixmap::NoOptim</tt> - No optimization (currently the same as <a href="#Optimization-enum">MemoryOptim</a>).
207<li><tt>QPixmap::MemoryOptim</tt> - Optimize for minimal memory use on Windows
2089x and X11 systems.
209<li><tt>QPixmap::NormalOptim</tt> - Optimize for typical usage. Often uses more
210memory than <a href="#Optimization-enum">MemoryOptim</a>, and is often faster.
211<li><tt>QPixmap::BestOptim</tt> - Optimize for pixmaps that are drawn very often
212and where performance is critical. Generally uses more memory
213than <a href="#Optimization-enum">NormalOptim</a> and may provide a little more speed.
214</ul><p> We recommend using <a href="#Optimization-enum">DefaultOptim</a>.
215<p>
216<hr><h2>Member Function Documentation</h2>
217<h3 class=fn><a name="QPixmap"></a>QPixmap::QPixmap ()
218</h3>
219Constructs a null pixmap.
220<p> <p>See also <a href="#isNull">isNull</a>().
221
222<h3 class=fn><a name="QPixmap-2"></a>QPixmap::QPixmap ( const&nbsp;<a href="qimage.html">QImage</a>&nbsp;&amp;&nbsp;image )
223</h3>
224Constructs a pixmap from the <a href="qimage.html">QImage</a> <em>image</em>.
225<p> <p>See also <a href="#convertFromImage">convertFromImage</a>().
226
227<h3 class=fn><a name="QPixmap-3"></a>QPixmap::QPixmap ( int&nbsp;w, int&nbsp;h, int&nbsp;depth = -1, <a href="qpixmap.html#Optimization-enum">Optimization</a>&nbsp;optimization = DefaultOptim )
228</h3>
229Constructs a pixmap with <em>w</em> width, <em>h</em> height and <em>depth</em> bits
230per pixel. The pixmap is optimized in accordance with the <em>optimization</em> value.
231<p> The contents of the pixmap is uninitialized.
232<p> The <em>depth</em> can be either 1 (monochrome) or the depth of the
233current video mode. If <em>depth</em> is negative, then the hardware
234depth of the current video mode will be used.
235<p> If either <em>w</em> or <em>h</em> is zero, a null pixmap is constructed.
236<p> <p>See also <a href="#isNull">isNull</a>() and <a href="#Optimization-enum">QPixmap::Optimization</a>.
237
238<h3 class=fn><a name="QPixmap-4"></a>QPixmap::QPixmap ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;size, int&nbsp;depth = -1, <a href="qpixmap.html#Optimization-enum">Optimization</a>&nbsp;optimization = DefaultOptim )
239</h3>
240This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
241<p> Constructs a pixmap of size <em>size</em>, <em>depth</em> bits per pixel,
242optimized in accordance with the <em>optimization</em> value.
243
244<h3 class=fn><a name="QPixmap-5"></a>QPixmap::QPixmap ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format = 0, <a href="qpixmap.html#ColorMode-enum">ColorMode</a>&nbsp;mode = Auto )
245</h3>
246Constructs a pixmap from the file <em>fileName</em>. If the file does
247not exist or is of an unknown format, the pixmap becomes a null
248pixmap.
249<p> The <em>fileName</em>, <em>format</em> and <em>mode</em> parameters are passed on to
250<a href="#load">load</a>(). This means that the data in <em>fileName</em> is not compiled
251into the binary. If <em>fileName</em> contains a relative path (e.g. the
252filename only) the relevant file must be found relative to the
253runtime working directory.
254<p> <p>See also <a href="#ColorMode-enum">QPixmap::ColorMode</a>, <a href="#isNull">isNull</a>(), <a href="#load">load</a>(), <a href="#loadFromData">loadFromData</a>(), <a href="#save">save</a>(), and <a href="#imageFormat">imageFormat</a>().
255
256<h3 class=fn><a name="QPixmap-6"></a>QPixmap::QPixmap ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format, int&nbsp;conversion_flags )
257</h3>
258Constructs a pixmap from the file <em>fileName</em>. If the file does
259not exist or is of an unknown format, the pixmap becomes a null
260pixmap.
261<p> The <em>fileName</em>, <em>format</em> and <em>conversion_flags</em> parameters are
262passed on to <a href="#load">load</a>(). This means that the data in <em>fileName</em> is
263not compiled into the binary. If <em>fileName</em> contains a relative
264path (e.g. the filename only) the relevant file must be found
265relative to the runtime working directory.
266<p> If the image needs to be modified to fit in a lower-resolution
267result (e.g. converting from 32-bit to 8-bit), use the <em>conversion_flags</em> to specify how you'd prefer this to happen.
268<p> <p>See also <a href="qt.html#ImageConversionFlags-enum">Qt::ImageConversionFlags</a>, <a href="#isNull">isNull</a>(), <a href="#load">load</a>(), <a href="#loadFromData">loadFromData</a>(), <a href="#save">save</a>(), and <a href="#imageFormat">imageFormat</a>().
269
270<h3 class=fn><a name="QPixmap-7"></a>QPixmap::QPixmap ( const&nbsp;char&nbsp;*&nbsp;xpm[] )
271</h3>
272Constructs a pixmap from <em>xpm</em>, which must be a valid XPM image.
273<p> Errors are silently ignored.
274<p> Note that it's possible to squeeze the XPM variable a little bit
275by using an unusual declaration:
276<p> <pre>
277 static const char * const start_xpm[]={
278 "16 15 8 1",
279 "a c #cec6bd",
280 ....
281 </pre>
282
283<p> The extra <tt>const</tt> makes the entire definition read-only, which is
284slightly more efficient (for example, when the code is in a shared
285library) and ROMable when the application is to be stored in ROM.
286<p> In order to use that sort of declaration you must cast the
287variable back to <tt>const char **</tt> when you create the QPixmap.
288
289<h3 class=fn><a name="QPixmap-8"></a>QPixmap::QPixmap ( const&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;img_data )
290</h3>
291Constructs a pixmaps by loading from <em>img_data</em>. The data can be
292in any image format supported by Qt.
293<p> <p>See also <a href="#loadFromData">loadFromData</a>().
294
295<h3 class=fn><a name="QPixmap-9"></a>QPixmap::QPixmap ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap )
296</h3>
297Constructs a pixmap that is a copy of <em>pixmap</em>.
298
299<h3 class=fn><a name="QPixmap-a"></a>QPixmap::QPixmap ( int&nbsp;w, int&nbsp;h, const&nbsp;uchar&nbsp;*&nbsp;bits, bool&nbsp;isXbitmap )<tt> [protected]</tt>
300</h3>
301Constructs a monochrome pixmap, with width <em>w</em> and height <em>h</em>,
302that is initialized with the data in <em>bits</em>. The <em>isXbitmap</em>
303indicates whether the data is an X bitmap and defaults to FALSE.
304This constructor is protected and used by the <a href="qbitmap.html">QBitmap</a> class.
305
306<h3 class=fn><a name="~QPixmap"></a>QPixmap::~QPixmap ()
307</h3>
308Destroys the pixmap.
309
310<h3 class=fn>bool <a name="convertFromImage"></a>QPixmap::convertFromImage ( const&nbsp;<a href="qimage.html">QImage</a>&nbsp;&amp;&nbsp;img, int&nbsp;conversion_flags )
311</h3>
312Converts image <em>img</em> and sets this pixmap. Returns TRUE if
313successful; otherwise returns FALSE.
314<p> The <em>conversion_flags</em> argument is a bitwise-OR of the
315<a href="qt.html#ImageConversionFlags-enum">Qt::ImageConversionFlags</a>. Passing 0 for <em>conversion_flags</em>
316sets all the default options.
317<p> Note that even though a QPixmap with depth 1 behaves much like a
318<a href="qbitmap.html">QBitmap</a>, <a href="#isQBitmap">isQBitmap</a>() returns FALSE.
319<p> If a pixmap with depth 1 is painted with color0 and color1 and
320converted to an image, the pixels painted with color0 will produce
321pixel index 0 in the image and those painted with color1 will
322produce pixel index 1.
323<p> <p>See also <a href="#convertToImage">convertToImage</a>(), <a href="#isQBitmap">isQBitmap</a>(), <a href="qimage.html#convertDepth">QImage::convertDepth</a>(), <a href="#defaultDepth">defaultDepth</a>(), and <a href="qimage.html#hasAlphaBuffer">QImage::hasAlphaBuffer</a>().
324
325<p>Examples: <a href="canvas-example.html#x2943">canvas/canvas.cpp</a> and <a href="themes-example.html#x228">themes/wood.cpp</a>.
326<h3 class=fn>bool <a name="convertFromImage-2"></a>QPixmap::convertFromImage ( const&nbsp;<a href="qimage.html">QImage</a>&nbsp;&amp;&nbsp;image, <a href="qpixmap.html#ColorMode-enum">ColorMode</a>&nbsp;mode = Auto )
327</h3>
328This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
329<p> Converts <em>image</em> and sets this pixmap using color mode <em>mode</em>.
330Returns TRUE if successful; otherwise returns FALSE.
331<p> <p>See also <a href="#ColorMode-enum">QPixmap::ColorMode</a>.
332
333<h3 class=fn><a href="qimage.html">QImage</a> <a name="convertToImage"></a>QPixmap::convertToImage () const
334</h3>
335Converts the pixmap to a <a href="qimage.html">QImage</a>. Returns a null image if it fails.
336<p> If the pixmap has 1-bit depth, the returned image will also be 1
337bit deep. If the pixmap has 2- to 8-bit depth, the returned image
338has 8-bit depth. If the pixmap has greater than 8-bit depth, the
339returned image has 32-bit depth.
340<p> Note that for the moment, alpha masks on monochrome images are
341ignored.
342<p> <p>See also <a href="#convertFromImage">convertFromImage</a>().
343
344<p>Example: <a href="qmag-example.html#x1783">qmag/qmag.cpp</a>.
345<h3 class=fn><a href="qbitmap.html">QBitmap</a> <a name="createHeuristicMask"></a>QPixmap::createHeuristicMask ( bool&nbsp;clipTight = TRUE ) const
346</h3>
347Creates and returns a heuristic mask for this pixmap. It works by
348selecting a color from one of the corners and then chipping away
349pixels of that color, starting at all the edges.
350<p> The mask may not be perfect but it should be reasonable, so you
351can do things such as the following:
352<pre>
353 pm-&gt;setMask( pm-&gt;createHeuristicMask() );
354 </pre>
355
356<p> This function is slow because it involves transformation to a
357<a href="qimage.html">QImage</a>, non-trivial computations and a transformation back to a
358<a href="qbitmap.html">QBitmap</a>.
359<p> If <em>clipTight</em> is TRUE the mask is just large enough to cover the
360pixels; otherwise, the mask is larger than the data pixels.
361<p> <p>See also <a href="qimage.html#createHeuristicMask">QImage::createHeuristicMask</a>().
362
363<h3 class=fn>int <a name="defaultDepth"></a>QPixmap::defaultDepth ()<tt> [static]</tt>
364</h3>
365Returns the default pixmap depth, i.e. the depth a pixmap gets if
366-1 is specified.
367<p> <p>See also <a href="#depth">depth</a>().
368
369<h3 class=fn><a href="qpixmap.html#Optimization-enum">Optimization</a> <a name="defaultOptimization"></a>QPixmap::defaultOptimization ()<tt> [static]</tt>
370</h3>
371Returns the default pixmap optimization setting.
372<p> <p>See also <a href="#setDefaultOptimization">setDefaultOptimization</a>(), <a href="#setOptimization">setOptimization</a>(), and <a href="#optimization">optimization</a>().
373
374<h3 class=fn>int <a name="depth"></a>QPixmap::depth () const
375</h3>
376
377<p> Returns the depth of the pixmap.
378<p> The pixmap depth is also called bits per pixel (bpp) or bit planes
379of a pixmap. A null pixmap has depth 0.
380<p> <p>See also <a href="#defaultDepth">defaultDepth</a>(), <a href="#isNull">isNull</a>(), and <a href="qimage.html#convertDepth">QImage::convertDepth</a>().
381
382<h3 class=fn>void <a name="detach"></a>QPixmap::detach ()<tt> [virtual]</tt>
383</h3>
384This is a special-purpose function that detaches the pixmap from
385shared pixmap data.
386<p> A pixmap is automatically detached by Qt whenever its contents is
387about to change. This is done in all QPixmap member functions
388that modify the pixmap (<a href="#fill">fill</a>(), <a href="#resize">resize</a>(), <a href="#convertFromImage">convertFromImage</a>(),
389<a href="#load">load</a>(), etc.), in <a href="qpaintdevice.html#bitBlt">bitBlt</a>() for the destination pixmap and in
390<a href="qpainter.html#begin">QPainter::begin</a>() on a pixmap.
391<p> It is possible to modify a pixmap without letting Qt know. You can
392first obtain the system-dependent <a href="qpaintdevice.html#handle">handle</a>() and then call
393system-specific functions (for instance, BitBlt under Windows)
394that modify the pixmap contents. In such cases, you can call
395<a href="#detach">detach</a>() to cut the pixmap loose from other pixmaps that share
396data with this one.
397<p> detach() returns immediately if there is just a single reference
398or if the pixmap has not been initialized yet.
399
400<h3 class=fn>void <a name="fill"></a>QPixmap::fill ( const&nbsp;<a href="qcolor.html">QColor</a>&nbsp;&amp;&nbsp;fillColor = Qt::white )
401</h3>
402Fills the pixmap with the color <em>fillColor</em>.
403
404<p>Examples: <a href="tutorial2-08.html#x2606">chart/setdataform.cpp</a>, <a href="desktop-example.html#x1742">desktop/desktop.cpp</a>, <a href="grapher-nsplugin-example.html#x2765">grapher/grapher.cpp</a>, <a href="hello-example.html#x1638">hello/hello.cpp</a>, <a href="tutorial1-10.html#x2358">t10/cannon.cpp</a>, <a href="themes-example.html#x292">themes/metal.cpp</a>, and <a href="xform-example.html#x1245">xform/xform.cpp</a>.
405<h3 class=fn>void <a name="fill-2"></a>QPixmap::fill ( const&nbsp;<a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;widget, int&nbsp;xofs, int&nbsp;yofs )
406</h3>
407This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
408<p> Fills the pixmap with the <em>widget</em>'s background color or pixmap.
409If the background is empty, nothing is done. <em>xofs</em>, <em>yofs</em> is
410an offset in the widget.
411
412<h3 class=fn>void <a name="fill-3"></a>QPixmap::fill ( const&nbsp;<a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;widget, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;ofs )
413</h3>
414This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
415<p> Fills the pixmap with the <em>widget</em>'s background color or pixmap.
416If the background is empty, nothing is done.
417<p> The <em>ofs</em> point is an offset in the widget.
418<p> The point <em>ofs</em> is a point in the widget's coordinate system. The
419pixmap's top-left pixel will be mapped to the point <em>ofs</em> in the
420widget. This is significant if the widget has a background pixmap;
421otherwise the pixmap will simply be filled with the background
422color of the widget.
423<p> Example:
424<pre>
425 void CuteWidget::paintEvent( <a href="qpaintevent.html">QPaintEvent</a> *e )
426 {
427 <a href="qrect.html">QRect</a> ur = e-&gt;<a href="qpaintevent.html#rect">rect</a>(); // rectangle to update
428 QPixmap pix( ur.<a href="qrect.html#size">size</a>() ); // Pixmap for double-buffering
429 pix.<a href="#fill">fill</a>( this, ur.<a href="qrect.html#topLeft">topLeft</a>() ); // fill with widget background
430
431 <a href="qpainter.html">QPainter</a> p( &amp;pix );
432 p.<a href="qpainter.html#translate">translate</a>( -ur.<a href="qrect.html#x">x</a>(), -ur.<a href="qrect.html#y">y</a>() ); // use widget coordinate system
433 // when drawing on pixmap
434 // ... draw on pixmap ...
435
436 p.<a href="qpainter.html#end">end</a>();
437
438 <a href="qpaintdevice.html#bitBlt">bitBlt</a>( this, ur.<a href="qrect.html#topLeft">topLeft</a>(), &amp;pix );
439 }
440 </pre>
441
442
443<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="fromMimeSource"></a>QPixmap::fromMimeSource ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;abs_name )<tt> [static]</tt>
444</h3> Convenience function. Gets the data associated with the absolute
445name <em>abs_name</em> from the default mime source factory and decodes it
446to a pixmap.
447<p> <p>See also <a href="qmimesourcefactory.html">QMimeSourceFactory</a>, <a href="qimage.html#fromMimeSource">QImage::fromMimeSource</a>(), and <a href="qimagedrag.html#decode">QImageDrag::decode</a>().
448
449<p>Example: <a href="qactiongroup.html#x2113">textedit/textedit.cpp</a>.
450<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="grabWidget"></a>QPixmap::grabWidget ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;widget, int&nbsp;x = 0, int&nbsp;y = 0, int&nbsp;w = -1, int&nbsp;h = -1 )<tt> [static]</tt>
451</h3>
452Creates a pixmap and paints <em>widget</em> in it.
453<p> If the <em>widget</em> has any children, then they are also painted in
454the appropriate positions.
455<p> If you specify <em>x</em>, <em>y</em>, <em>w</em> or <em>h</em>, only the rectangle you
456specify is painted. The defaults are 0, 0 (top-left corner) and
457-1,-1 (which means the entire widget).
458<p> (If <em>w</em> is negative, the function copies everything to the right
459border of the window. If <em>h</em> is negative, the function copies
460everything to the bottom of the window.)
461<p> If <em>widget</em> is 0, or if the rectangle defined by <em>x</em>, <em>y</em>, the
462modified <em>w</em> and the modified <em>h</em> does not overlap the <em>widget</em>->rect(), this function will return a null QPixmap.
463<p> This function actually asks <em>widget</em> to paint itself (and its
464children to paint themselves). <a href="#grabWindow">QPixmap::grabWindow</a>() grabs pixels
465off the screen, which is a bit faster and picks up <em>exactly</em>
466what's on-screen. This function works by calling paintEvent() with
467painter redirection turned on. If there are overlaying windows,
468<a href="#grabWindow">grabWindow</a>() will see them, but not this function.
469<p> If there is overlap, it returns a pixmap of the size you want,
470containing a rendering of <em>widget</em>. If the rectangle you ask for
471is a superset of <em>widget</em>, the areas outside <em>widget</em> are
472covered with the widget's background.
473<p> If an error occurs when trying to grab the widget, such as the
474size of the widget being too large to fit in memory, an <a href="#isNull">isNull</a>()
475pixmap is returned.
476<p> <p>See also <a href="#grabWindow">grabWindow</a>(), <a href="qpainter.html#redirect">QPainter::redirect</a>(), and <a href="qwidget.html#paintEvent">QWidget::paintEvent</a>().
477
478<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="grabWindow"></a>QPixmap::grabWindow ( WId&nbsp;window, int&nbsp;x = 0, int&nbsp;y = 0, int&nbsp;w = -1, int&nbsp;h = -1 )<tt> [static]</tt>
479</h3>
480Grabs the contents of the window <em>window</em> and makes a pixmap out
481of it. Returns the pixmap.
482<p> The arguments <em>(x, y)</em> specify the offset in the window, whereas
483<em>(w, h)</em> specify the width and height of the area to be copied.
484<p> If <em>w</em> is negative, the function copies everything to the right
485border of the window. If <em>h</em> is negative, the function copies
486everything to the bottom of the window.
487<p> Note that <a href="#grabWindow">grabWindow</a>() grabs pixels from the screen, not from the
488window. If there is another window partially or entirely over the
489one you grab, you get pixels from the overlying window, too.
490<p> Note also that the mouse cursor is generally not grabbed.
491<p> The reason we use a window identifier and not a <a href="qwidget.html">QWidget</a> is to
492enable grabbing of windows that are not part of the application,
493window system frames, and so on.
494<p> <b>Warning:</b> Grabbing an area outside the screen is not safe in
495general. This depends on the underlying window system.
496<p> <b>Warning:</b> X11 only: If <em>window</em> is not the same depth as the root
497window and another window partially or entirely obscures the one
498you grab, you will <em>not</em> get pixels from the overlying window.
499The contests of the obscured areas in the pixmap are undefined and
500uninitialized.
501<p> <p>See also <a href="#grabWidget">grabWidget</a>().
502
503<p>Example: <a href="qmag-example.html#x1784">qmag/qmag.cpp</a>.
504<h3 class=fn>bool <a name="hasAlpha"></a>QPixmap::hasAlpha () const
505</h3>
506Returns TRUE this pixmap has an alpha channel or a mask.
507<p> <p>See also <a href="#hasAlphaChannel">hasAlphaChannel</a>() and <a href="#mask">mask</a>().
508
509<h3 class=fn>bool <a name="hasAlphaChannel"></a>QPixmap::hasAlphaChannel () const
510</h3>
511Returns TRUE if the pixmap has an alpha channel; otherwise it
512returns FALSE.
513<p> NOTE: If the pixmap has a mask but not alpha channel, this
514function returns FALSE.
515<p> <p>See also <a href="#hasAlpha">hasAlpha</a>() and <a href="#mask">mask</a>().
516
517<h3 class=fn>int <a name="height"></a>QPixmap::height () const
518</h3>
519
520<p> Returns the height of the pixmap.
521<p> <p>See also <a href="#width">width</a>(), <a href="#size">size</a>(), and <a href="#rect">rect</a>().
522
523<p>Examples: <a href="desktop-example.html#x1743">desktop/desktop.cpp</a>, <a href="movies-example.html#x510">movies/main.cpp</a>, <a href="scribble-example.html#x921">scribble/scribble.cpp</a>, <a href="scrollview-example.html#x638">scrollview/scrollview.cpp</a>, <a href="tutorial1-10.html#x2359">t10/cannon.cpp</a>, and <a href="xform-example.html#x1246">xform/xform.cpp</a>.
524<h3 class=fn>const char * <a name="imageFormat"></a>QPixmap::imageFormat ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName )<tt> [static]</tt>
525</h3>
526Returns a string that specifies the image format of the file <em>fileName</em>, or 0 if the file cannot be read or if the format cannot
527be recognized.
528<p> The <a href="qimageio.html">QImageIO</a> documentation lists the supported image formats.
529<p> <p>See also <a href="#load">load</a>() and <a href="#save">save</a>().
530
531<h3 class=fn>bool <a name="isNull"></a>QPixmap::isNull () const
532</h3>
533
534<p> Returns TRUE if this is a null pixmap; otherwise returns FALSE.
535<p> A null pixmap has zero width, zero height and no contents. You
536cannot draw in a null pixmap or <a href="qpaintdevice.html#bitBlt">bitBlt</a>() anything to it.
537<p> Resizing an existing pixmap to (0, 0) makes a pixmap into a null
538pixmap.
539<p> <p>See also <a href="#resize">resize</a>().
540
541<p>Examples: <a href="movies-example.html#x511">movies/main.cpp</a>, <a href="qdir-example.html#x1834">qdir/qdir.cpp</a>, <a href="qmag-example.html#x1785">qmag/qmag.cpp</a>, and <a href="scrollview-example.html#x639">scrollview/scrollview.cpp</a>.
542<h3 class=fn>bool <a name="isQBitmap"></a>QPixmap::isQBitmap () const
543</h3>
544
545<p> Returns TRUE if this is a <a href="qbitmap.html">QBitmap</a>; otherwise returns FALSE.
546
547<h3 class=fn>bool <a name="load"></a>QPixmap::load ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format, int&nbsp;conversion_flags )
548</h3>
549Loads a pixmap from the file <em>fileName</em> at runtime. Returns TRUE
550if successful; otherwise returns FALSE.
551<p> If <em>format</em> is specified, the loader attempts to read the pixmap
552using the specified format. If <em>format</em> is not specified
553(default), the loader reads a few bytes from the header to guess
554the file's format.
555<p> See the <a href="#convertFromImage">convertFromImage</a>() documentation for a description of the
556<em>conversion_flags</em> argument.
557<p> The <a href="qimageio.html">QImageIO</a> documentation lists the supported image formats and
558explains how to add extra formats.
559<p> <p>See also <a href="#loadFromData">loadFromData</a>(), <a href="#save">save</a>(), <a href="#imageFormat">imageFormat</a>(), <a href="qimage.html#load">QImage::load</a>(), and <a href="qimageio.html">QImageIO</a>.
560
561<p>Examples: <a href="picture-example.html#x124">picture/picture.cpp</a>, <a href="scrollview-example.html#x640">scrollview/scrollview.cpp</a>, and <a href="xform-example.html#x1247">xform/xform.cpp</a>.
562<h3 class=fn>bool <a name="load-2"></a>QPixmap::load ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format = 0, <a href="qpixmap.html#ColorMode-enum">ColorMode</a>&nbsp;mode = Auto )
563</h3>
564This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
565<p> Loads a pixmap from the file <em>fileName</em> at runtime.
566<p> If <em>format</em> is specified, the loader attempts to read the pixmap
567using the specified format. If <em>format</em> is not specified
568(default), the loader reads a few bytes from the header to guess
569the file's format.
570<p> The <em>mode</em> is used to specify the color mode of the pixmap.
571<p> <p>See also <a href="#ColorMode-enum">QPixmap::ColorMode</a>.
572
573<h3 class=fn>bool <a name="loadFromData"></a>QPixmap::loadFromData ( const&nbsp;uchar&nbsp;*&nbsp;buf, uint&nbsp;len, const&nbsp;char&nbsp;*&nbsp;format, int&nbsp;conversion_flags )
574</h3>
575Loads a pixmap from the binary data in <em>buf</em> (<em>len</em> bytes).
576Returns TRUE if successful; otherwise returns FALSE.
577<p> If <em>format</em> is specified, the loader attempts to read the pixmap
578using the specified format. If <em>format</em> is not specified
579(default), the loader reads a few bytes from the header to guess
580the file's format.
581<p> See the <a href="#convertFromImage">convertFromImage</a>() documentation for a description of the
582<em>conversion_flags</em> argument.
583<p> The <a href="qimageio.html">QImageIO</a> documentation lists the supported image formats and
584explains how to add extra formats.
585<p> <p>See also <a href="#load">load</a>(), <a href="#save">save</a>(), <a href="#imageFormat">imageFormat</a>(), <a href="qimage.html#loadFromData">QImage::loadFromData</a>(), and <a href="qimageio.html">QImageIO</a>.
586
587<h3 class=fn>bool <a name="loadFromData-2"></a>QPixmap::loadFromData ( const&nbsp;uchar&nbsp;*&nbsp;buf, uint&nbsp;len, const&nbsp;char&nbsp;*&nbsp;format = 0, <a href="qpixmap.html#ColorMode-enum">ColorMode</a>&nbsp;mode = Auto )
588</h3>
589This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
590<p> Loads a pixmap from the binary data in <em>buf</em> (<em>len</em> bytes) using
591color mode <em>mode</em>. Returns TRUE if successful; otherwise returns
592FALSE.
593<p> If <em>format</em> is specified, the loader attempts to read the pixmap
594using the specified format. If <em>format</em> is not specified
595(default), the loader reads a few bytes from the header to guess
596the file's format.
597<p> <p>See also <a href="#ColorMode-enum">QPixmap::ColorMode</a>.
598
599<h3 class=fn>bool <a name="loadFromData-3"></a>QPixmap::loadFromData ( const&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;buf, const&nbsp;char&nbsp;*&nbsp;format = 0, int&nbsp;conversion_flags = 0 )
600</h3>
601This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
602<p>
603<h3 class=fn>const&nbsp;<a href="qbitmap.html">QBitmap</a>&nbsp;* <a name="mask"></a>QPixmap::mask () const
604</h3>
605
606<p> Returns the mask bitmap, or 0 if no mask has been set.
607<p> <p>See also <a href="#setMask">setMask</a>(), <a href="qbitmap.html">QBitmap</a>, and <a href="#hasAlpha">hasAlpha</a>().
608
609<h3 class=fn>int <a name="metric"></a>QPixmap::metric ( int&nbsp;m ) const<tt> [virtual protected]</tt>
610</h3>
611Internal implementation of the virtual QPaintDevice::metric() function.
612<p> Use the <a href="qpaintdevicemetrics.html">QPaintDeviceMetrics</a> class instead.
613<p> <em>m</em> is the metric to get.
614
615<h3 class=fn><a href="qpixmap.html">QPixmap</a>&nbsp;&amp; <a name="operator-eq"></a>QPixmap::operator= ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap )
616</h3>
617Assigns the pixmap <em>pixmap</em> to this pixmap and returns a
618reference to this pixmap.
619
620<h3 class=fn><a href="qpixmap.html">QPixmap</a>&nbsp;&amp; <a name="operator-eq-2"></a>QPixmap::operator= ( const&nbsp;<a href="qimage.html">QImage</a>&nbsp;&amp;&nbsp;image )
621</h3>
622This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
623<p> Converts the image <em>image</em> to a pixmap that is assigned to this
624pixmap. Returns a reference to the pixmap.
625<p> <p>See also <a href="#convertFromImage">convertFromImage</a>().
626
627<h3 class=fn><a href="qpixmap.html#Optimization-enum">Optimization</a> <a name="optimization"></a>QPixmap::optimization () const
628</h3>
629
630<p> Returns the optimization setting for this pixmap.
631<p> The default optimization setting is <a href="#Optimization-enum">QPixmap::NormalOptim</a>. You
632can change this setting in two ways:
633<ul>
634<li> Call <a href="#setDefaultOptimization">setDefaultOptimization</a>() to set the default optimization
635for all new pixmaps.
636<li> Call <a href="#setOptimization">setOptimization</a>() to set the optimization for individual
637pixmaps.
638</ul>
639<p> <p>See also <a href="#setOptimization">setOptimization</a>(), <a href="#setDefaultOptimization">setDefaultOptimization</a>(), and <a href="#defaultOptimization">defaultOptimization</a>().
640
641<h3 class=fn><a href="qrect.html">QRect</a> <a name="rect"></a>QPixmap::rect () const
642</h3>
643
644<p> Returns the enclosing rectangle (0,0,width(),height()) of the pixmap.
645<p> <p>See also <a href="#width">width</a>(), <a href="#height">height</a>(), and <a href="#size">size</a>().
646
647<h3 class=fn>void <a name="resize"></a>QPixmap::resize ( int&nbsp;w, int&nbsp;h )
648</h3>
649Resizes the pixmap to <em>w</em> width and <em>h</em> height. If either <em>w</em>
650or <em>h</em> is 0, the pixmap becomes a null pixmap.
651<p> If both <em>w</em> and <em>h</em> are greater than 0, a valid pixmap is
652created. New pixels will be uninitialized (random) if the pixmap
653is expanded.
654
655<p>Examples: <a href="desktop-example.html#x1744">desktop/desktop.cpp</a> and <a href="grapher-nsplugin-example.html#x2766">grapher/grapher.cpp</a>.
656<h3 class=fn>void <a name="resize-2"></a>QPixmap::resize ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;size )
657</h3>
658This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
659<p> Resizes the pixmap to size <em>size</em>.
660
661<h3 class=fn>bool <a name="save"></a>QPixmap::save ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format, int&nbsp;quality = -1 ) const
662</h3>
663Saves the pixmap to the file <em>fileName</em> using the image file
664format <em>format</em> and a quality factor <em>quality</em>. <em>quality</em> must
665be in the range [0,100] or -1. Specify 0 to obtain small
666compressed files, 100 for large uncompressed files, and -1 to use
667the default settings. Returns TRUE if successful; otherwise
668returns FALSE.
669<p> <p>See also <a href="#load">load</a>(), <a href="#loadFromData">loadFromData</a>(), <a href="#imageFormat">imageFormat</a>(), <a href="qimage.html#save">QImage::save</a>(), and <a href="qimageio.html">QImageIO</a>.
670
671<p>Example: <a href="qmag-example.html#x1786">qmag/qmag.cpp</a>.
672<h3 class=fn>bool <a name="save-2"></a>QPixmap::save ( <a href="qiodevice.html">QIODevice</a>&nbsp;*&nbsp;device, const&nbsp;char&nbsp;*&nbsp;format, int&nbsp;quality = -1 ) const
673</h3>
674This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
675<p> This function writes a QPixmap to the <a href="qiodevice.html">QIODevice</a>, <em>device</em>. This
676can be used, for example, to save a pixmap directly into a
677QByteArray:
678<pre>
679 QPixmap pixmap;
680 <a href="qbytearray.html">QByteArray</a> ba;
681 <a href="qbuffer.html">QBuffer</a> buffer( ba );
682 buffer.<a href="qiodevice.html#open">open</a>( <a href="qfile.html#open">IO_WriteOnly</a> );
683 pixmap.<a href="#save">save</a>( &amp;buffer, "PNG" ); // writes pixmap into ba in PNG format
684 </pre>
685
686
687<h3 class=fn>bool <a name="selfMask"></a>QPixmap::selfMask () const
688</h3>
689
690<p> Returns TRUE if the pixmap's mask is identical to the pixmap
691itself; otherwise returns FALSE.
692<p> <p>See also <a href="#mask">mask</a>().
693
694<h3 class=fn>int <a name="serialNumber"></a>QPixmap::serialNumber () const
695</h3>
696
697<p> Returns a number that uniquely identifies the contents of this
698QPixmap object. This means that multiple QPixmap objects can have
699the same serial number as long as they refer to the same contents.
700<p> An example of where this is useful is for caching QPixmaps.
701<p> <p>See also <a href="qpixmapcache.html">QPixmapCache</a>.
702
703<h3 class=fn>void <a name="setDefaultOptimization"></a>QPixmap::setDefaultOptimization ( <a href="qpixmap.html#Optimization-enum">Optimization</a>&nbsp;optimization )<tt> [static]</tt>
704</h3>
705Sets the default pixmap optimization.
706<p> All <em>new</em> pixmaps that are created will use this default
707optimization. You may also set optimization for individual pixmaps
708using the <a href="#setOptimization">setOptimization</a>() function.
709<p> The initial default <em>optimization</em> setting is <tt>QPixmap::Normal</tt>.
710<p> <p>See also <a href="#defaultOptimization">defaultOptimization</a>(), <a href="#setOptimization">setOptimization</a>(), and <a href="#optimization">optimization</a>().
711
712<h3 class=fn>void <a name="setMask"></a>QPixmap::setMask ( const&nbsp;<a href="qbitmap.html">QBitmap</a>&nbsp;&amp;&nbsp;newmask )
713</h3>
714Sets a mask bitmap.
715<p> The <em>newmask</em> bitmap defines the clip mask for this pixmap. Every
716pixel in <em>newmask</em> corresponds to a pixel in this pixmap. Pixel
717value 1 means opaque and pixel value 0 means transparent. The mask
718must have the same size as this pixmap.
719<p> <b>Warning:</b> Setting the mask on a pixmap will cause any alpha channel
720data to be cleared. For example:
721<pre>
722 QPixmap alpha( "image-with-alpha.png" );
723 QPixmap alphacopy = alpha;
724 alphacopy.<a href="#setMask">setMask</a>( *alphacopy.<a href="#mask">mask</a>() );
725 </pre>
726
727Now, alpha and alphacopy are visually different.
728<p> Setting a <a href="#isNull">null</a> mask resets the mask.
729<p> <p>See also <a href="#mask">mask</a>(), <a href="#createHeuristicMask">createHeuristicMask</a>(), and <a href="qbitmap.html">QBitmap</a>.
730
731<h3 class=fn>void <a name="setOptimization"></a>QPixmap::setOptimization ( <a href="qpixmap.html#Optimization-enum">Optimization</a>&nbsp;optimization )
732</h3>
733Sets pixmap drawing optimization for this pixmap.
734<p> The <em>optimization</em> setting affects pixmap operations, in
735particular drawing of transparent pixmaps (<a href="qpaintdevice.html#bitBlt">bitBlt</a>() a pixmap with
736a mask set) and pixmap transformations (the <a href="#xForm">xForm</a>() function).
737<p> Pixmap optimization involves keeping intermediate results in a
738cache buffer and using the cache to speed up bitBlt() and xForm().
739The cost is more memory consumption, up to twice as much as an
740unoptimized pixmap.
741<p> Use the <a href="#setDefaultOptimization">setDefaultOptimization</a>() to change the default
742optimization for all new pixmaps.
743<p> <p>See also <a href="#optimization">optimization</a>(), <a href="#setDefaultOptimization">setDefaultOptimization</a>(), and <a href="#defaultOptimization">defaultOptimization</a>().
744
745<p>Example: <a href="desktop-example.html#x1745">desktop/desktop.cpp</a>.
746<h3 class=fn><a href="qsize.html">QSize</a> <a name="size"></a>QPixmap::size () const
747</h3>
748
749<p> Returns the size of the pixmap.
750<p> <p>See also <a href="#width">width</a>(), <a href="#height">height</a>(), and <a href="#rect">rect</a>().
751
752<p>Example: <a href="movies-example.html#x512">movies/main.cpp</a>.
753<h3 class=fn><a href="qwmatrix.html">QWMatrix</a> <a name="trueMatrix"></a>QPixmap::trueMatrix ( const&nbsp;<a href="qwmatrix.html">QWMatrix</a>&nbsp;&amp;&nbsp;matrix, int&nbsp;w, int&nbsp;h )<tt> [static]</tt>
754</h3>
755Returns the actual matrix used for transforming a pixmap with <em>w</em>
756width and <em>h</em> height and matrix <em>matrix</em>.
757<p> When transforming a pixmap with <a href="#xForm">xForm</a>(), the <a href="qwmatrix.html#TransformationMode">transformation matrix</a>
758is internally adjusted to compensate for unwanted translation,
759i.e. xForm() returns the smallest pixmap containing all
760transformed points of the original pixmap.
761<p> This function returns the modified matrix, which maps points
762correctly from the original pixmap into the new pixmap.
763<p> <p>See also <a href="#xForm">xForm</a>() and <a href="qwmatrix.html">QWMatrix</a>.
764
765<h3 class=fn>int <a name="width"></a>QPixmap::width () const
766</h3>
767
768<p> Returns the width of the pixmap.
769<p> <p>See also <a href="#height">height</a>(), <a href="#size">size</a>(), and <a href="#rect">rect</a>().
770
771<p>Examples: <a href="desktop-example.html#x1746">desktop/desktop.cpp</a>, <a href="movies-example.html#x513">movies/main.cpp</a>, <a href="scribble-example.html#x922">scribble/scribble.cpp</a>, <a href="scrollview-example.html#x641">scrollview/scrollview.cpp</a>, and <a href="xform-example.html#x1248">xform/xform.cpp</a>.
772<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="xForm"></a>QPixmap::xForm ( const&nbsp;<a href="qwmatrix.html">QWMatrix</a>&nbsp;&amp;&nbsp;matrix ) const
773</h3>
774Returns a copy of the pixmap that is transformed using <em>matrix</em>.
775The original pixmap is not changed.
776<p> The transformation <em>matrix</em> is internally adjusted to compensate
777for unwanted translation, i.e. <a href="#xForm">xForm</a>() returns the smallest image
778that contains all the transformed points of the original image.
779<p> This function is slow because it involves transformation to a
780<a href="qimage.html">QImage</a>, non-trivial computations and a transformation back to a
781QPixmap.
782<p> <p>See also <a href="#trueMatrix">trueMatrix</a>(), <a href="qwmatrix.html">QWMatrix</a>, <a href="qpainter.html#setWorldMatrix">QPainter::setWorldMatrix</a>(), and <a href="qimage.html#xForm">QImage::xForm</a>().
783
784<p>Examples: <a href="desktop-example.html#x1747">desktop/desktop.cpp</a>, <a href="fileiconview-example.html#x863">fileiconview/qfileiconview.cpp</a>, <a href="movies-example.html#x514">movies/main.cpp</a>, and <a href="qmag-example.html#x1787">qmag/qmag.cpp</a>.
785<hr><h2>Related Functions</h2>
786<h3 class=fn>void <a name="copyBlt"></a>copyBlt ( <a href="qpixmap.html">QPixmap</a>&nbsp;*&nbsp;dst, int&nbsp;dx, int&nbsp;dy, const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;*&nbsp;src, int&nbsp;sx, int&nbsp;sy, int&nbsp;sw, int&nbsp;sh )
787</h3>
788
789<p> Copies a block of pixels from <em>src</em> to <em>dst</em>. The alpha channel
790and mask data (if any) is also copied from <em>src</em>. NOTE: <em>src</em>
791is <em>not</em> alpha blended or masked when copied to <em>dst</em>. Use
792<a href="qpaintdevice.html#bitBlt">bitBlt</a>() or <a href="qpainter.html#drawPixmap">QPainter::drawPixmap</a>() to perform alpha blending or
793masked drawing.
794<p> <em>sx</em>, <em>sy</em> is the top-left pixel in <em>src</em> (0, 0 by default), <em>dx</em>, <em>dy</em> is the top-left position in <em>dst</em> and <em>sw</em>, \sh is the
795size of the copied block (all of <em>src</em> by default).
796<p> If <em>src</em>, <em>dst</em>, <em>sw</em> or <em>sh</em> is 0 (zero), <a href="#copyBlt">copyBlt</a>() does
797nothing. If <em>sw</em> or <em>sh</em> is negative, copyBlt() copies starting
798at <em>sx</em> (and respectively, <em>sy</em>) and ending at the right edge
799(and respectively, the bottom edge) of <em>src</em>.
800<p> copyBlt() does nothing if <em>src</em> and <em>dst</em> have different depths.
801
802<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="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap )
803</h3>
804
805<p> Writes the pixmap <em>pixmap</em> to the stream <em>s</em> as a PNG image.
806<p> Note that writing the stream to a file will not produce a valid image file.
807<p> <p>See also <a href="#save">QPixmap::save</a>() and <a href="datastreamformat.html">Format of the QDataStream operators</a>.
808
809<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="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap )
810</h3>
811
812<p> Reads a pixmap from the stream <em>s</em> into the pixmap <em>pixmap</em>.
813<p> <p>See also <a href="#load">QPixmap::load</a>() and <a href="datastreamformat.html">Format of the QDataStream operators</a>.
814
815<!-- eof -->
816<hr><p>
817This file is part of the <a href="index.html">Qt toolkit</a>.
818Copyright &copy; 1995-2007
819<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
820<table width=100% cellspacing=0 border=0><tr>
821<td>Copyright &copy; 2007
822<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
823<td align=right><div align=right>Qt 3.3.8</div>
824</table></div></address></body>
825</html>
Note: See TracBrowser for help on using the repository browser.