source: trunk/doc/html/qpixmap-h.html

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

reference documentation added

File size: 12.3 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/include/qpixmap.h:1 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>qpixmap.h Include File</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.h</h1>
33
34<p>This is the verbatim text of the qpixmap.h include file. It is provided only for illustration; the copyright remains with Trolltech.
35<hr>
36<pre>
37/****************************************************************************
38** $Id: qpixmap-h.html 2051 2007-02-21 10:04:20Z chehrlic $
39**
40** Definition of QPixmap class
41**
42** Created : 940501
43**
44** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
45**
46** This file is part of the kernel module of the Qt GUI Toolkit.
47**
48** This file may be distributed under the terms of the Q Public License
49** as defined by Trolltech ASA of Norway and appearing in the file
50** LICENSE.QPL included in the packaging of this file.
51**
52** This file may be distributed and/or modified under the terms of the
53** GNU General Public License version 2 as published by the Free Software
54** Foundation and appearing in the file LICENSE.GPL included in the
55** packaging of this file.
56**
57** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
58** licenses may use this file in accordance with the Qt Commercial License
59** Agreement provided with the Software.
60**
61** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
62** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
63**
64** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
65** information about Qt Commercial License Agreements.
66** See http://www.trolltech.com/qpl/ for QPL licensing information.
67** See http://www.trolltech.com/gpl/ for GPL licensing information.
68**
69** Contact info@trolltech.com if any conditions of this licensing are
70** not clear to you.
71**
72**********************************************************************/
73
74#ifndef QPIXMAP_H
75#define QPIXMAP_H
76
77#ifndef QT_H
78#include "qpaintdevice.h"
79#include "qcolor.h" // char*-&gt;QColor conversion
80#include "qstring.h" // char*-&gt;QString conversion
81#include "qnamespace.h"
82#endif // QT_H
83
84class QGfx;
85class QPixmapPrivate;
86
87#if defined(Q_WS_WIN)
88// Internal pixmap memory optimization class for Windows 9x
89class QMultiCellPixmap;
90#endif
91
92
93class Q_EXPORT QPixmap : public QPaintDevice, public Qt
94{
95public:
96 enum ColorMode { Auto, Color, Mono };
97 enum Optimization { DefaultOptim, NoOptim, MemoryOptim=NoOptim,
98 NormalOptim, BestOptim };
99
100 QPixmap();
101 QPixmap( const QImage&amp; image );
102 QPixmap( int w, int h, int depth = -1, Optimization = DefaultOptim );
103 QPixmap( const QSize &amp;, int depth = -1, Optimization = DefaultOptim );
104#ifndef QT_NO_IMAGEIO
105 QPixmap( const QString&amp; fileName, const char *format=0,
106 ColorMode mode=Auto );
107 QPixmap( const QString&amp; fileName, const char *format,
108 int conversion_flags );
109 QPixmap( const char *xpm[] ); // ### in 4.0, 'const char * const xpm[]'?
110 QPixmap( const QByteArray &amp;data );
111#endif
112 QPixmap( const QPixmap &amp; );
113 ~QPixmap();
114
115 QPixmap &amp;operator=( const QPixmap &amp; );
116 QPixmap &amp;operator=( const QImage &amp; );
117
118 bool isNull() const;
119
120 int width() const { return data-&gt;w; }
121 int height() const { return data-&gt;h; }
122 QSize size() const { return QSize(data-&gt;w,data-&gt;h); }
123 QRect rect() const { return QRect(0,0,data-&gt;w,data-&gt;h); }
124 int depth() const { return data-&gt;d; }
125 static int defaultDepth();
126
127 void fill( const QColor &amp;fillColor = Qt::white );
128 void fill( const QWidget *, int xofs, int yofs );
129 void fill( const QWidget *, const QPoint &amp;ofs );
130 void resize( int width, int height );
131 void resize( const QSize &amp; );
132
133 const QBitmap *mask() const;
134 void setMask( const QBitmap &amp; );
135 bool selfMask() const;
136 bool hasAlpha() const;
137 bool hasAlphaChannel() const;
138#ifndef QT_NO_IMAGE_HEURISTIC_MASK
139 QBitmap createHeuristicMask( bool clipTight = TRUE ) const;
140#endif
141#ifndef QT_NO_MIME
142 static QPixmap fromMimeSource( const QString&amp; abs_name );
143#endif
144 static QPixmap grabWindow( WId, int x=0, int y=0, int w=-1, int h=-1 );
145 static QPixmap grabWidget( QWidget * widget,
146 int x=0, int y=0, int w=-1, int h=-1 );
147
148#ifndef QT_NO_PIXMAP_TRANSFORMATION
149 QPixmap xForm( const QWMatrix &amp; ) const;
150 static QWMatrix trueMatrix( const QWMatrix &amp;, int w, int h );
151#endif
152
153 QImage convertToImage() const;
154 bool convertFromImage( const QImage &amp;, ColorMode mode=Auto );
155 bool convertFromImage( const QImage &amp;, int conversion_flags );
156#ifndef QT_NO_IMAGEIO
157 static const char* imageFormat( const QString &amp;fileName );
158 bool load( const QString&amp; fileName, const char *format=0,
159 ColorMode mode=Auto );
160 bool load( const QString&amp; fileName, const char *format,
161 int conversion_flags );
162 bool loadFromData( const uchar *buf, uint len,
163 const char* format=0,
164 ColorMode mode=Auto );
165 bool loadFromData( const uchar *buf, uint len,
166 const char* format,
167 int conversion_flags );
168 bool loadFromData( const QByteArray &amp;data,
169 const char* format=0,
170 int conversion_flags=0 );
171 bool save( const QString&amp; fileName, const char* format, int quality = -1 ) const;
172 bool save( QIODevice* device, const char* format, int quality = -1 ) const;
173#endif
174
175#if defined(Q_WS_WIN)
176 HBITMAP hbm() const;
177#endif
178
179 int serialNumber() const;
180
181 Optimization optimization() const;
182 void setOptimization( Optimization );
183 static Optimization defaultOptimization();
184 static void setDefaultOptimization( Optimization );
185
186 virtual void detach();
187
188 bool isQBitmap() const;
189
190#if defined(Q_WS_WIN)
191 // These functions are internal and used by Windows 9x only
192 bool isMultiCellPixmap() const;
193 HDC multiCellHandle() const;
194 HBITMAP multiCellBitmap() const;
195 int multiCellOffset() const;
196 int allocCell();
197 void freeCell( bool = FALSE );
198#endif
199
200#if defined(Q_WS_QWS)
201 virtual QGfx * graphicsContext(bool clip_children=TRUE) const;
202 virtual unsigned char * scanLine(int) const;
203 virtual int bytesPerLine() const;
204 QRgb * clut() const;
205 int numCols() const;
206#elif defined(Q_WS_X11)
207 static int x11SetDefaultScreen( int screen );
208 void x11SetScreen( int screen );
209#endif
210
211#ifndef Q_QDOC
212 Q_DUMMY_COMPARISON_OPERATOR(QPixmap)
213#endif
214
215protected:
216 QPixmap( int w, int h, const uchar *data, bool isXbitmap );
217 int metric( int ) const;
218
219#if defined(Q_WS_WIN)
220 struct QMCPI { // mem optim for win9x
221 QMultiCellPixmap *mcp;
222 int offset;
223 };
224#endif
225
226 struct QPixmapData : public QShared { // internal pixmap data
227 QCOORD w, h;
228 short d;
229 uint uninit : 1;
230 uint bitmap : 1;
231 uint selfmask : 1;
232#if defined(Q_WS_WIN)
233 uint mcp : 1;
234#endif
235 int ser_no;
236 QBitmap *mask;
237#if defined(Q_WS_WIN)
238 QPixmap *maskpm;
239 union {
240 HBITMAP hbm; // if mcp == FALSE
241 QMCPI *mcpi; // if mcp == TRUE
242 } hbm_or_mcpi;
243 uchar *realAlphaBits;
244#ifdef Q_OS_TEMP
245 uchar* ppvBits; // Pointer to DIBSection bits
246#endif
247#elif defined(Q_WS_X11)
248 void *ximage;
249 void *maskgc;
250 QPixmap *alphapm;
251#elif defined(Q_WS_MAC)
252 ColorTable *clut;
253 QPixmap *alphapm;
254#elif defined(Q_WS_QWS)
255 int id; // ### should use QPaintDevice::hd, since it is there
256 QRgb * clut;
257 int numcols;
258 int rw;
259 int rh;
260 bool hasAlpha;
261#endif
262 Optimization optim;
263#if defined(Q_WS_WIN)
264 HBITMAP old_hbm;
265#endif
266 } *data;
267private:
268#ifndef QT_NO_IMAGEIO
269 bool doImageIO( QImageIO* io, int quality ) const;
270#endif
271 QPixmap( int w, int h, int depth, bool, Optimization );
272 void init( int, int, int, bool, Optimization );
273 void deref();
274 QPixmap copy( bool ignoreMask = FALSE ) const;
275#if defined(Q_WS_WIN)
276 void initAlphaPixmap( uchar *bytes, int length, struct tagBITMAPINFO *bmi );
277 void convertToAlphaPixmap( bool initAlpha=TRUE );
278 static void bitBltAlphaPixmap( QPixmap *dst, int dx, int dy,
279 const QPixmap *src, int sx, int sy,
280 int sw, int sh, bool useDstAlpha );
281#endif
282 static Optimization defOptim;
283 friend Q_EXPORT void bitBlt( QPaintDevice *, int, int,
284 const QPaintDevice *,
285 int, int, int, int, RasterOp, bool );
286 friend Q_EXPORT void bitBlt( QPaintDevice *, int, int,
287 const QImage* src,
288 int, int, int, int, int conversion_flags );
289 friend Q_EXPORT void copyBlt( QPixmap *dst, int dx, int dy,
290 const QPixmap *src, int sx, int sy,
291 int sw, int sh );
292
293#if defined(Q_WS_MAC)
294 friend void unclippedScaledBitBlt(QPaintDevice *, int, int, int, int,
295 const QPaintDevice *, int, int, int, int,
296 Qt::RasterOp, bool, bool);
297#endif
298
299 friend class QBitmap;
300 friend class QPaintDevice;
301 friend class QPainter;
302 friend class QGLWidget;
303};
304
305
306inline bool QPixmap::isNull() const
307{
308 return data-&gt;w == 0;
309}
310
311inline void QPixmap::fill( const QWidget *w, const QPoint &amp;ofs )
312{
313 fill( w, ofs.x(), ofs.y() );
314}
315
316inline void QPixmap::resize( const QSize &amp;s )
317{
318 resize( s.width(), s.height() );
319}
320
321inline const QBitmap *QPixmap::mask() const
322{
323 return data-&gt;mask;
324}
325
326inline bool QPixmap::selfMask() const
327{
328 return data-&gt;selfmask;
329}
330
331#if defined(Q_WS_WIN)
332inline HBITMAP QPixmap::hbm() const
333{
334 return data-&gt;mcp ? 0 : data-&gt;hbm_or_mcpi.hbm;
335}
336#endif
337
338inline int QPixmap::serialNumber() const
339{
340 return data-&gt;ser_no;
341}
342
343inline QPixmap::Optimization QPixmap::optimization() const
344{
345 return data-&gt;optim;
346}
347
348inline bool QPixmap::isQBitmap() const
349{
350 return data-&gt;bitmap;
351}
352
353#if defined(Q_WS_WIN)
354inline bool QPixmap::isMultiCellPixmap() const
355{
356 return data-&gt;mcp;
357}
358#endif
359
360
361/*****************************************************************************
362 QPixmap stream functions
363 *****************************************************************************/
364
365#if !defined(QT_NO_DATASTREAM) &amp;&amp; !defined(QT_NO_IMAGEIO)
366Q_EXPORT QDataStream &amp;operator&lt;&lt;( QDataStream &amp;, const QPixmap &amp; );
367Q_EXPORT QDataStream &amp;operator&gt;&gt;( QDataStream &amp;, QPixmap &amp; );
368#endif
369
370/*****************************************************************************
371 QPixmap (and QImage) helper functions
372 *****************************************************************************/
373
374#ifndef QT_NO_PIXMAP_TRANSFORMATION
375# define QT_XFORM_TYPE_MSBFIRST 0
376# define QT_XFORM_TYPE_LSBFIRST 1
377# if defined(Q_WS_WIN)
378# define QT_XFORM_TYPE_WINDOWSPIXMAP 2
379# endif
380bool qt_xForm_helper( const QWMatrix&amp;, int, int, int, uchar*, int, int, int, uchar*, int, int, int );
381#endif
382
383Q_EXPORT void copyBlt( QPixmap *dst, int dx, int dy,
384 const QPixmap *src, int sx = 0, int sy = 0,
385 int sw = -1, int sh = -1 );
386
387#endif // QPIXMAP_H
388</pre>
389<!-- eof -->
390<p><address><hr><div align=center>
391<table width=100% cellspacing=0 border=0><tr>
392<td>Copyright &copy; 2007
393<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
394<td align=right><div align=right>Qt 3.3.8</div>
395</table></div></address></body>
396</html>
Note: See TracBrowser for help on using the repository browser.