source: trunk/doc/html/qimage-h.html@ 203

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

reference documentation added

File size: 14.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/qimage.h:1 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>qimage.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>qimage.h</h1>
33
34<p>This is the verbatim text of the qimage.h include file. It is provided only for illustration; the copyright remains with Trolltech.
35<hr>
36<pre>
37/****************************************************************************
38** $Id: qimage-h.html 2051 2007-02-21 10:04:20Z chehrlic $
39**
40** Definition of QImage and QImageIO classes
41**
42** Created : 950207
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 QIMAGE_H
75#define QIMAGE_H
76
77#ifndef QT_H
78#include "qpixmap.h"
79#include "qstrlist.h"
80#include "qstringlist.h"
81#endif // QT_H
82
83class QImageDataMisc; // internal
84#ifndef QT_NO_IMAGE_TEXT
85class Q_EXPORT QImageTextKeyLang {
86public:
87 QImageTextKeyLang(const char* k, const char* l) : key(k), lang(l) { }
88 QImageTextKeyLang() { }
89
90 QCString key;
91 QCString lang;
92
93 bool operator&lt; (const QImageTextKeyLang&amp; other) const
94 { return key &lt; other.key || key==other.key &amp;&amp; lang &lt; other.lang; }
95 bool operator== (const QImageTextKeyLang&amp; other) const
96 { return key==other.key &amp;&amp; lang==other.lang; }
97};
98#endif //QT_NO_IMAGE_TEXT
99
100
101class Q_EXPORT QImage
102{
103public:
104 enum Endian { IgnoreEndian, BigEndian, LittleEndian };
105
106 QImage();
107 QImage( int width, int height, int depth, int numColors=0,
108 Endian bitOrder=IgnoreEndian );
109 QImage( const QSize&amp;, int depth, int numColors=0,
110 Endian bitOrder=IgnoreEndian );
111#ifndef QT_NO_IMAGEIO
112 QImage( const QString &amp;fileName, const char* format=0 );
113 QImage( const char * const xpm[] );
114 QImage( const QByteArray &amp;data );
115#endif
116 QImage( uchar* data, int w, int h, int depth,
117 QRgb* colortable, int numColors,
118 Endian bitOrder );
119#ifdef Q_WS_QWS
120 QImage( uchar* data, int w, int h, int depth, int pbl,
121 QRgb* colortable, int numColors,
122 Endian bitOrder );
123#endif
124 QImage( const QImage &amp; );
125 ~QImage();
126
127 QImage &amp;operator=( const QImage &amp; );
128 QImage &amp;operator=( const QPixmap &amp; );
129 bool operator==( const QImage &amp; ) const;
130 bool operator!=( const QImage &amp; ) const;
131 void detach();
132 QImage copy() const;
133 QImage copy(int x, int y, int w, int h, int conversion_flags=0) const;
134 QImage copy(const QRect&amp;) const;
135#ifndef QT_NO_MIME
136 static QImage fromMimeSource( const QString&amp; abs_name );
137#endif
138 bool isNull() const { return data-&gt;bits == 0; }
139
140 int width() const { return data-&gt;w; }
141 int height() const { return data-&gt;h; }
142 QSize size() const { return QSize(data-&gt;w,data-&gt;h); }
143 QRect rect() const { return QRect(0,0,data-&gt;w,data-&gt;h); }
144 int depth() const { return data-&gt;d; }
145 int numColors() const { return data-&gt;ncols; }
146 Endian bitOrder() const { return (Endian) data-&gt;bitordr; }
147
148 QRgb color( int i ) const;
149 void setColor( int i, QRgb c );
150 void setNumColors( int );
151
152 bool hasAlphaBuffer() const;
153 void setAlphaBuffer( bool );
154
155 bool allGray() const;
156 bool isGrayscale() const;
157
158 uchar *bits() const;
159 uchar *scanLine( int ) const;
160 uchar **jumpTable() const;
161 QRgb *colorTable() const;
162 int numBytes() const;
163 int bytesPerLine() const;
164
165#ifdef Q_WS_QWS
166 QGfx * graphicsContext();
167#endif
168
169 bool create( int width, int height, int depth, int numColors=0,
170 Endian bitOrder=IgnoreEndian );
171 bool create( const QSize&amp;, int depth, int numColors=0,
172 Endian bitOrder=IgnoreEndian );
173 void reset();
174
175 void fill( uint pixel );
176 void invertPixels( bool invertAlpha = TRUE );
177
178 QImage convertDepth( int ) const;
179#ifndef QT_NO_IMAGE_TRUECOLOR
180 QImage convertDepthWithPalette( int, QRgb* p, int pc, int cf=0 ) const;
181#endif
182 QImage convertDepth( int, int conversion_flags ) const;
183 QImage convertBitOrder( Endian ) const;
184
185 enum ScaleMode {
186 ScaleFree,
187 ScaleMin,
188 ScaleMax
189 };
190#ifndef QT_NO_IMAGE_SMOOTHSCALE
191 QImage smoothScale( int w, int h, ScaleMode mode=ScaleFree ) const;
192 QImage smoothScale( const QSize&amp; s, ScaleMode mode=ScaleFree ) const;
193#endif
194#ifndef QT_NO_IMAGE_TRANSFORMATION
195 QImage scale( int w, int h, ScaleMode mode=ScaleFree ) const;
196 QImage scale( const QSize&amp; s, ScaleMode mode=ScaleFree ) const;
197 QImage scaleWidth( int w ) const;
198 QImage scaleHeight( int h ) const;
199 QImage xForm( const QWMatrix &amp;matrix ) const;
200#endif
201
202#ifndef QT_NO_IMAGE_DITHER_TO_1
203 QImage createAlphaMask( int conversion_flags=0 ) const;
204#endif
205#ifndef QT_NO_IMAGE_HEURISTIC_MASK
206 QImage createHeuristicMask( bool clipTight=TRUE ) const;
207#endif
208#ifndef QT_NO_IMAGE_MIRROR
209 QImage mirror() const;
210 QImage mirror(bool horizontally, bool vertically) const;
211#endif
212 QImage swapRGB() const;
213
214 static Endian systemBitOrder();
215 static Endian systemByteOrder();
216
217#ifndef QT_NO_IMAGEIO
218 static const char* imageFormat( const QString &amp;fileName );
219 static QStrList inputFormats();
220 static QStrList outputFormats();
221#ifndef QT_NO_STRINGLIST
222 static QStringList inputFormatList();
223 static QStringList outputFormatList();
224#endif
225 bool load( const QString &amp;fileName, const char* format=0 );
226 bool loadFromData( const uchar *buf, uint len,
227 const char *format=0 );
228 bool loadFromData( QByteArray data, const char* format=0 );
229 bool save( const QString &amp;fileName, const char* format,
230 int quality=-1 ) const;
231 bool save( QIODevice * device, const char* format,
232 int quality=-1 ) const;
233#endif //QT_NO_IMAGEIO
234
235 bool valid( int x, int y ) const;
236 int pixelIndex( int x, int y ) const;
237 QRgb pixel( int x, int y ) const;
238 void setPixel( int x, int y, uint index_or_rgb );
239
240 // Auxiliary data
241 int dotsPerMeterX() const;
242 int dotsPerMeterY() const;
243 void setDotsPerMeterX(int);
244 void setDotsPerMeterY(int);
245 QPoint offset() const;
246 void setOffset(const QPoint&amp;);
247#ifndef QT_NO_IMAGE_TEXT
248 QValueList&lt;QImageTextKeyLang&gt; textList() const;
249 QStringList textLanguages() const;
250 QStringList textKeys() const;
251 QString text(const char* key, const char* lang=0) const;
252 QString text(const QImageTextKeyLang&amp;) const;
253 void setText(const char* key, const char* lang, const QString&amp;);
254#endif
255private:
256 void init();
257 void reinit();
258 void freeBits();
259 static void warningIndexRange( const char *, int );
260
261 struct QImageData : public QShared { // internal image data
262 int w; // image width
263 int h; // image height
264 int d; // image depth
265 int ncols; // number of colors
266 int nbytes; // number of bytes data
267 int bitordr; // bit order (1 bit depth)
268 QRgb *ctbl; // color table
269 uchar **bits; // image data
270 bool alpha; // alpha buffer
271 int dpmx; // dots per meter X (or 0)
272 int dpmy; // dots per meter Y (or 0)
273 QPoint offset; // offset in pixels
274#ifndef QT_NO_IMAGE_TEXT
275 QImageDataMisc* misc; // less common stuff
276#endif
277 bool ctbl_mine; // this allocated ctbl
278 } *data;
279#ifndef QT_NO_IMAGE_TEXT
280 QImageDataMisc&amp; misc() const;
281#endif
282#ifndef QT_NO_IMAGEIO
283 bool doImageIO( QImageIO* io, int quality ) const;
284#endif
285 friend Q_EXPORT void bitBlt( QImage* dst, int dx, int dy,
286 const QImage* src, int sx, int sy,
287 int sw, int sh, int conversion_flags );
288};
289
290
291// QImage stream functions
292
293#if !defined(QT_NO_DATASTREAM) &amp;&amp; !defined(QT_NO_IMAGEIO)
294Q_EXPORT QDataStream &amp;operator&lt;&lt;( QDataStream &amp;, const QImage &amp; );
295Q_EXPORT QDataStream &amp;operator&gt;&gt;( QDataStream &amp;, QImage &amp; );
296#endif
297
298#ifndef QT_NO_IMAGEIO
299class QIODevice;
300typedef void (*image_io_handler)( QImageIO * ); // image IO handler
301
302
303struct QImageIOData;
304
305
306class Q_EXPORT QImageIO
307{
308public:
309 QImageIO();
310 QImageIO( QIODevice *ioDevice, const char *format );
311 QImageIO( const QString &amp;fileName, const char* format );
312 ~QImageIO();
313
314
315 const QImage &amp;image() const { return im; }
316 int status() const { return iostat; }
317 const char *format() const { return frmt; }
318 QIODevice *ioDevice() const { return iodev; }
319 QString fileName() const { return fname; }
320 int quality() const;
321 QString description() const { return descr; }
322 const char *parameters() const;
323 float gamma() const;
324
325 void setImage( const QImage &amp; );
326 void setStatus( int );
327 void setFormat( const char * );
328 void setIODevice( QIODevice * );
329 void setFileName( const QString &amp; );
330 void setQuality( int );
331 void setDescription( const QString &amp; );
332 void setParameters( const char * );
333 void setGamma( float );
334
335 bool read();
336 bool write();
337
338 static const char* imageFormat( const QString &amp;fileName );
339 static const char *imageFormat( QIODevice * );
340 static QStrList inputFormats();
341 static QStrList outputFormats();
342
343 static void defineIOHandler( const char *format,
344 const char *header,
345 const char *flags,
346 image_io_handler read_image,
347 image_io_handler write_image );
348
349private:
350 void init();
351
352 QImage im; // image
353 int iostat; // IO status
354 QCString frmt; // image format
355 QIODevice *iodev; // IO device
356 QString fname; // file name
357 char *params; // image parameters //### change to QImageIOData *d in 3.0
358 QString descr; // image description
359 QImageIOData *d;
360
361private: // Disabled copy constructor and operator=
362#if defined(Q_DISABLE_COPY)
363 QImageIO( const QImageIO &amp; );
364 QImageIO &amp;operator=( const QImageIO &amp; );
365#endif
366};
367
368#endif //QT_NO_IMAGEIO
369
370Q_EXPORT void bitBlt( QImage* dst, int dx, int dy, const QImage* src,
371 int sx=0, int sy=0, int sw=-1, int sh=-1,
372 int conversion_flags=0 );
373
374
375/*****************************************************************************
376 QImage member functions
377 *****************************************************************************/
378
379inline bool QImage::hasAlphaBuffer() const
380{
381 return data-&gt;alpha;
382}
383
384inline uchar *QImage::bits() const
385{
386 return data-&gt;bits ? data-&gt;bits[0] : 0;
387}
388
389inline uchar **QImage::jumpTable() const
390{
391 return data-&gt;bits;
392}
393
394inline QRgb *QImage::colorTable() const
395{
396 return data-&gt;ctbl;
397}
398
399inline int QImage::numBytes() const
400{
401 return data-&gt;nbytes;
402}
403
404inline int QImage::bytesPerLine() const
405{
406 return data-&gt;h ? data-&gt;nbytes/data-&gt;h : 0;
407}
408
409inline QImage QImage::copy(const QRect&amp; r) const
410{
411 return copy(r.x(), r.y(), r.width(), r.height());
412}
413
414inline QRgb QImage::color( int i ) const
415{
416#if defined(QT_CHECK_RANGE)
417 if ( i &gt;= data-&gt;ncols )
418 warningIndexRange( "color", i );
419#endif
420 return data-&gt;ctbl ? data-&gt;ctbl[i] : (QRgb)-1;
421}
422
423inline void QImage::setColor( int i, QRgb c )
424{
425#if defined(QT_CHECK_RANGE)
426 if ( i &gt;= data-&gt;ncols )
427 warningIndexRange( "setColor", i );
428#endif
429 if ( data-&gt;ctbl )
430 data-&gt;ctbl[i] = c;
431}
432
433inline uchar *QImage::scanLine( int i ) const
434{
435#if defined(QT_CHECK_RANGE)
436 if ( i &gt;= data-&gt;h )
437 warningIndexRange( "scanLine", i );
438#endif
439 return data-&gt;bits ? data-&gt;bits[i] : 0;
440}
441
442inline int QImage::dotsPerMeterX() const
443{
444 return data-&gt;dpmx;
445}
446
447inline int QImage::dotsPerMeterY() const
448{
449 return data-&gt;dpmy;
450}
451
452inline QPoint QImage::offset() const
453{
454 return data-&gt;offset;
455}
456
457
458#endif // QIMAGE_H
459</pre>
460<!-- eof -->
461<p><address><hr><div align=center>
462<table width=100% cellspacing=0 border=0><tr>
463<td>Copyright &copy; 2007
464<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
465<td align=right><div align=right>Qt 3.3.8</div>
466</table></div></address></body>
467</html>
Note: See TracBrowser for help on using the repository browser.