source: trunk/doc/html/qimageio.html@ 190

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

reference documentation added

File size: 18.8 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/qimage.cpp:3715 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QImageIO 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>QImageIO Class Reference</h1>
33
34<p>The QImageIO class contains parameters for loading and
35saving images.
36<a href="#details">More...</a>
37<p><tt>#include &lt;<a href="qimage-h.html">qimage.h</a>&gt;</tt>
38<p><a href="qimageio-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn><a href="#QImageIO"><b>QImageIO</b></a> ()</li>
42<li class=fn><a href="#QImageIO-2"><b>QImageIO</b></a> ( QIODevice&nbsp;*&nbsp;ioDevice, const&nbsp;char&nbsp;*&nbsp;format )</li>
43<li class=fn><a href="#QImageIO-3"><b>QImageIO</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format )</li>
44<li class=fn><a href="#~QImageIO"><b>~QImageIO</b></a> ()</li>
45<li class=fn>const QImage &amp; <a href="#image"><b>image</b></a> () const</li>
46<li class=fn>int <a href="#status"><b>status</b></a> () const</li>
47<li class=fn>const char * <a href="#format"><b>format</b></a> () const</li>
48<li class=fn>QIODevice * <a href="#ioDevice"><b>ioDevice</b></a> () const</li>
49<li class=fn>QString <a href="#fileName"><b>fileName</b></a> () const</li>
50<li class=fn>int <a href="#quality"><b>quality</b></a> () const</li>
51<li class=fn>QString <a href="#description"><b>description</b></a> () const</li>
52<li class=fn>const char * <a href="#parameters"><b>parameters</b></a> () const</li>
53<li class=fn>float <a href="#gamma"><b>gamma</b></a> () const</li>
54<li class=fn>void <a href="#setImage"><b>setImage</b></a> ( const&nbsp;QImage&nbsp;&amp;&nbsp;image )</li>
55<li class=fn>void <a href="#setStatus"><b>setStatus</b></a> ( int&nbsp;status )</li>
56<li class=fn>void <a href="#setFormat"><b>setFormat</b></a> ( const&nbsp;char&nbsp;*&nbsp;format )</li>
57<li class=fn>void <a href="#setIODevice"><b>setIODevice</b></a> ( QIODevice&nbsp;*&nbsp;ioDevice )</li>
58<li class=fn>void <a href="#setFileName"><b>setFileName</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName )</li>
59<li class=fn>void <a href="#setQuality"><b>setQuality</b></a> ( int&nbsp;q )</li>
60<li class=fn>void <a href="#setDescription"><b>setDescription</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;description )</li>
61<li class=fn>void <a href="#setParameters"><b>setParameters</b></a> ( const&nbsp;char&nbsp;*&nbsp;parameters )</li>
62<li class=fn>void <a href="#setGamma"><b>setGamma</b></a> ( float&nbsp;gamma )</li>
63<li class=fn>bool <a href="#read"><b>read</b></a> ()</li>
64<li class=fn>bool <a href="#write"><b>write</b></a> ()</li>
65</ul>
66<h2>Static Public Members</h2>
67<ul>
68<li class=fn>const char * <a href="#imageFormat"><b>imageFormat</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName )</li>
69<li class=fn>const char * <a href="#imageFormat-2"><b>imageFormat</b></a> ( QIODevice&nbsp;*&nbsp;d )</li>
70<li class=fn>QStrList <a href="#inputFormats"><b>inputFormats</b></a> ()</li>
71<li class=fn>QStrList <a href="#outputFormats"><b>outputFormats</b></a> ()</li>
72<li class=fn>void <a href="#defineIOHandler"><b>defineIOHandler</b></a> ( const&nbsp;char&nbsp;*&nbsp;format, const&nbsp;char&nbsp;*&nbsp;header, const&nbsp;char&nbsp;*&nbsp;flags, image_io_handler&nbsp;readImage, image_io_handler&nbsp;writeImage )</li>
73</ul>
74<hr><a name="details"></a><h2>Detailed Description</h2>
75
76
77<p> The QImageIO class contains parameters for loading and
78saving images.
79<p>
80
81
82<p> QImageIO contains a <a href="qiodevice.html">QIODevice</a> object that is used for image data
83I/O. The programmer can install new image file formats in addition
84to those that Qt provides.
85<p> Qt currently supports the following image file formats: PNG, BMP,
86XBM, XPM and PNM. It may also support JPEG, MNG and GIF, if
87specially configured during compilation. The different PNM formats
88are: PBM (P1 or P4), PGM (P2 or P5), and PPM (P3 or P6).
89<p> You don't normally need to use this class; <a href="qpixmap.html#load">QPixmap::load</a>(),
90<a href="qpixmap.html#save">QPixmap::save</a>(), and <a href="qimage.html">QImage</a> contain sufficient functionality.
91<p> For image files that contain sequences of images, only the first
92is read. See <a href="qmovie.html">QMovie</a> for loading multiple images.
93<p> PBM, PGM, and PPM format <em>output</em> is always in the more condensed
94raw format. PPM and PGM files with more than 256 levels of
95intensity are scaled down when reading.
96<p> <b>Warning:</b> If you are in a country which recognizes software patents
97and in which Unisys holds a patent on LZW compression and/or
98decompression and you want to use GIF, Unisys may require you to
99license the technology. Such countries include Canada, Japan, the
100USA, France, Germany, Italy and the UK.
101<p> GIF support may be removed completely in a future version of Qt.
102We recommend using the PNG format.
103<p> <p>See also <a href="qimage.html">QImage</a>, <a href="qpixmap.html">QPixmap</a>, <a href="qfile.html">QFile</a>, <a href="qmovie.html">QMovie</a>, <a href="graphics.html">Graphics Classes</a>, <a href="images.html">Image Processing Classes</a>, and <a href="io.html">Input/Output and Networking</a>.
104
105<hr><h2>Member Function Documentation</h2>
106<h3 class=fn><a name="QImageIO"></a>QImageIO::QImageIO ()
107</h3>
108Constructs a QImageIO object with all parameters set to zero.
109
110<h3 class=fn><a name="QImageIO-2"></a>QImageIO::QImageIO ( <a href="qiodevice.html">QIODevice</a>&nbsp;*&nbsp;ioDevice, const&nbsp;char&nbsp;*&nbsp;format )
111</h3>
112Constructs a QImageIO object with the I/O device <em>ioDevice</em> and a
113<em>format</em> tag.
114
115<h3 class=fn><a name="QImageIO-3"></a>QImageIO::QImageIO ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName, const&nbsp;char&nbsp;*&nbsp;format )
116</h3>
117Constructs a QImageIO object with the file name <em>fileName</em> and a
118<em>format</em> tag.
119
120<h3 class=fn><a name="~QImageIO"></a>QImageIO::~QImageIO ()
121</h3>
122Destroys the object and all related data.
123
124<h3 class=fn>void <a name="defineIOHandler"></a>QImageIO::defineIOHandler ( const&nbsp;char&nbsp;*&nbsp;format, const&nbsp;char&nbsp;*&nbsp;header, const&nbsp;char&nbsp;*&nbsp;flags, image_io_handler&nbsp;readImage, image_io_handler&nbsp;writeImage )<tt> [static]</tt>
125</h3>
126Defines an image I/O handler for the image format called <em>format</em>, which is recognized using the <a href="qregexp.html#details">regular expression</a> <em>header</em>, read using <em>readImage</em> and
127written using <em>writeImage</em>.
128<p> <em>flags</em> is a string of single-character flags for this format.
129The only flag defined currently is T (upper case), so the only
130legal value for <em>flags</em> are "T" and the empty string. The "T"
131flag means that the image file is a text file, and Qt should treat
132all newline conventions as equivalent. (XPM files and some PPM
133files are text files for example.)
134<p> <em>format</em> is used to select a handler to write a <a href="qimage.html">QImage</a>; <em>header</em>
135is used to select a handler to read an image file.
136<p> If <em>readImage</em> is a null pointer, the QImageIO will not be able
137to read images in <em>format</em>. If <em>writeImage</em> is a null pointer,
138the QImageIO will not be able to write images in <em>format</em>. If
139both are null, the QImageIO object is valid but useless.
140<p> Example:
141<pre>
142 void readGIF( QImageIO *image )
143 {
144 // read the image using the image-&gt;<a href="#ioDevice">ioDevice</a>()
145 }
146
147 void writeGIF( QImageIO *image )
148 {
149 // write the image using the image-&gt;<a href="#ioDevice">ioDevice</a>()
150 }
151
152 // add the GIF image handler
153
154 QImageIO::<a href="#defineIOHandler">defineIOHandler</a>( "GIF",
155 "^GIF[0-9][0-9][a-z]",
156 0,
157 readGIF,
158 writeGIF );
159 </pre>
160
161<p> Before the regex test, all the 0 bytes in the file header are
162converted to 1 bytes. This is done because when Qt was
163ASCII-based, <a href="qregexp.html">QRegExp</a> could not handle 0 bytes in strings.
164<p> The regexp is only applied on the first 14 bytes of the file.
165<p> Note that Qt assumes that there is only one handler per format; if
166two handlers support the same format, Qt will choose one
167arbitrarily. It is not possible to have one handler support
168reading, and another support writing.
169
170<h3 class=fn><a href="qstring.html">QString</a> <a name="description"></a>QImageIO::description () const
171</h3>
172
173<p> Returns the image description string.
174<p> <p>See also <a href="#setDescription">setDescription</a>().
175
176<h3 class=fn><a href="qstring.html">QString</a> <a name="fileName"></a>QImageIO::fileName () const
177</h3>
178
179<p> Returns the file name currently set.
180<p> <p>See also <a href="#setFileName">setFileName</a>().
181
182<h3 class=fn>const char * <a name="format"></a>QImageIO::format () const
183</h3>
184
185<p> Returns the image format string or 0 if no format has been
186explicitly set.
187
188<h3 class=fn>float <a name="gamma"></a>QImageIO::gamma () const
189</h3>
190Returns the gamma value at which the image will be viewed.
191<p> <p>See also <a href="#setGamma">setGamma</a>().
192
193<h3 class=fn>const&nbsp;<a href="qimage.html">QImage</a>&nbsp;&amp; <a name="image"></a>QImageIO::image () const
194</h3>
195
196<p> Returns the image currently set.
197<p> <p>See also <a href="#setImage">setImage</a>().
198
199<h3 class=fn>const char * <a name="imageFormat"></a>QImageIO::imageFormat ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName )<tt> [static]</tt>
200</h3>
201Returns a string that specifies the image format of the file <em>fileName</em>, or null if the file cannot be read or if the format is
202not recognized.
203
204<h3 class=fn>const char * <a name="imageFormat-2"></a>QImageIO::imageFormat ( <a href="qiodevice.html">QIODevice</a>&nbsp;*&nbsp;d )<tt> [static]</tt>
205</h3>
206This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
207<p> Returns a string that specifies the image format of the image read
208from IO device <em>d</em>, or 0 if the device cannot be read or if the
209format is not recognized.
210<p> Make sure that <em>d</em> is at the right position in the device (for
211example, at the beginning of the file).
212<p> <p>See also <a href="qiodevice.html#at">QIODevice::at</a>().
213
214<h3 class=fn><a href="qstrlist.html">QStrList</a> <a name="inputFormats"></a>QImageIO::inputFormats ()<tt> [static]</tt>
215</h3>
216Returns a sorted list of image formats that are supported for
217image input.
218
219<h3 class=fn><a href="qiodevice.html">QIODevice</a>&nbsp;* <a name="ioDevice"></a>QImageIO::ioDevice () const
220</h3>
221
222<p> Returns the IO device currently set.
223<p> <p>See also <a href="#setIODevice">setIODevice</a>().
224
225<h3 class=fn><a href="qstrlist.html">QStrList</a> <a name="outputFormats"></a>QImageIO::outputFormats ()<tt> [static]</tt>
226</h3>
227Returns a sorted list of image formats that are supported for
228image output.
229
230<p>Example: <a href="scribble-example.html#x911">scribble/scribble.cpp</a>.
231<h3 class=fn>const char * <a name="parameters"></a>QImageIO::parameters () const
232</h3>
233Returns the image's parameters string.
234<p> <p>See also <a href="#setParameters">setParameters</a>().
235
236<h3 class=fn>int <a name="quality"></a>QImageIO::quality () const
237</h3>
238Returns the quality of the written image, related to the
239compression ratio.
240<p> <p>See also <a href="#setQuality">setQuality</a>() and <a href="qimage.html#save">QImage::save</a>().
241
242<h3 class=fn>bool <a name="read"></a>QImageIO::read ()
243</h3>
244Reads an image into memory and returns TRUE if the image was
245successfully read; otherwise returns FALSE.
246<p> Before reading an image you must set an IO device or a file name.
247If both an IO device and a file name have been set, the IO device
248will be used.
249<p> Setting the image file format string is optional.
250<p> Note that this function does <em>not</em> set the <a href="#format">format</a> used to read the image. If you need that
251information, use the <a href="#imageFormat">imageFormat</a>() static functions.
252<p> Example:
253<p> <pre>
254 QImageIO iio;
255 <a href="qpixmap.html">QPixmap</a> pixmap;
256 iio.<a href="#setFileName">setFileName</a>( "vegeburger.bmp" );
257 if ( image.read() ) // ok
258 pixmap = iio.<a href="#image">image</a>(); // convert to pixmap
259 </pre>
260
261<p> <p>See also <a href="#setIODevice">setIODevice</a>(), <a href="#setFileName">setFileName</a>(), <a href="#setFormat">setFormat</a>(), <a href="#write">write</a>(), and <a href="qpixmap.html#load">QPixmap::load</a>().
262
263<h3 class=fn>void <a name="setDescription"></a>QImageIO::setDescription ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;description )
264</h3>
265Sets the image description string for image handlers that support
266image descriptions to <em>description</em>.
267<p> Currently, no image format supported by Qt uses the description
268string.
269
270<h3 class=fn>void <a name="setFileName"></a>QImageIO::setFileName ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName )
271</h3>
272Sets the name of the file to read or write an image from to <em>fileName</em>.
273<p> <p>See also <a href="#setIODevice">setIODevice</a>().
274
275<h3 class=fn>void <a name="setFormat"></a>QImageIO::setFormat ( const&nbsp;char&nbsp;*&nbsp;format )
276</h3>
277Sets the image format to <em>format</em> for the image to be read or
278written.
279<p> It is necessary to specify a format before writing an image, but
280it is not necessary to specify a format before reading an image.
281<p> If no format has been set, Qt guesses the image format before
282reading it. If a format is set the image will only be read if it
283has that format.
284<p> <p>See also <a href="#read">read</a>(), <a href="#write">write</a>(), and <a href="#format">format</a>().
285
286<h3 class=fn>void <a name="setGamma"></a>QImageIO::setGamma ( float&nbsp;gamma )
287</h3>
288Sets the gamma value at which the image will be viewed to <em>gamma</em>. If the image format stores a gamma value for which the
289image is intended to be used, then this setting will be used to
290modify the image. Setting to 0.0 will disable gamma correction
291(i.e. any specification in the file will be ignored).
292<p> The default value is 0.0.
293<p> <p>See also <a href="#gamma">gamma</a>().
294
295<h3 class=fn>void <a name="setIODevice"></a>QImageIO::setIODevice ( <a href="qiodevice.html">QIODevice</a>&nbsp;*&nbsp;ioDevice )
296</h3>
297Sets the IO device to be used for reading or writing an image.
298<p> Setting the IO device allows images to be read/written to any
299block-oriented <a href="qiodevice.html">QIODevice</a>.
300<p> If <em>ioDevice</em> is not null, this IO device will override file name
301settings.
302<p> <p>See also <a href="#setFileName">setFileName</a>().
303
304<h3 class=fn>void <a name="setImage"></a>QImageIO::setImage ( const&nbsp;<a href="qimage.html">QImage</a>&nbsp;&amp;&nbsp;image )
305</h3>
306Sets the image to <em>image</em>.
307<p> <p>See also <a href="#image">image</a>().
308
309<h3 class=fn>void <a name="setParameters"></a>QImageIO::setParameters ( const&nbsp;char&nbsp;*&nbsp;parameters )
310</h3>
311Sets the image's parameter string to <em>parameters</em>. This is for
312image handlers that require special parameters.
313<p> Although the current image formats supported by Qt ignore the
314parameters string, it may be used in future extensions or by
315contributions (for example, JPEG).
316<p> <p>See also <a href="#parameters">parameters</a>().
317
318<h3 class=fn>void <a name="setQuality"></a>QImageIO::setQuality ( int&nbsp;q )
319</h3>
320Sets the quality of the written image to <em>q</em>, related to the
321compression ratio.
322<p> <em>q</em> must be in the range -1..100. Specify 0 to obtain small
323compressed files, 100 for large uncompressed files. (-1 signifies
324the default compression.)
325<p> <p>See also <a href="#quality">quality</a>() and <a href="qimage.html#save">QImage::save</a>().
326
327<h3 class=fn>void <a name="setStatus"></a>QImageIO::setStatus ( int&nbsp;status )
328</h3>
329Sets the image IO status to <em>status</em>. A non-zero value indicates
330an error, whereas 0 means that the IO operation was successful.
331<p> <p>See also <a href="#status">status</a>().
332
333<h3 class=fn>int <a name="status"></a>QImageIO::status () const
334</h3>
335
336<p> Returns the image's IO status. A non-zero value indicates an
337error, whereas 0 means that the IO operation was successful.
338<p> <p>See also <a href="#setStatus">setStatus</a>().
339
340<h3 class=fn>bool <a name="write"></a>QImageIO::write ()
341</h3>
342Writes an image to an IO device and returns TRUE if the image was
343successfully written; otherwise returns FALSE.
344<p> Before writing an image you must set an IO device or a file name.
345If both an IO device and a file name have been set, the IO device
346will be used.
347<p> The image will be written using the specified image format.
348<p> Example:
349<pre>
350 QImageIO iio;
351 <a href="qimage.html">QImage</a> im;
352 im = pixmap; // convert to image
353 iio.<a href="#setImage">setImage</a>( im );
354 iio.<a href="#setFileName">setFileName</a>( "vegeburger.bmp" );
355 iio.<a href="#setFormat">setFormat</a>( "BMP" );
356 if ( iio.<a href="#write">write</a>() )
357 // returned TRUE if written successfully
358 </pre>
359
360<p> <p>See also <a href="#setIODevice">setIODevice</a>(), <a href="#setFileName">setFileName</a>(), <a href="#setFormat">setFormat</a>(), <a href="#read">read</a>(), and <a href="qpixmap.html#save">QPixmap::save</a>().
361
362<!-- eof -->
363<hr><p>
364This file is part of the <a href="index.html">Qt toolkit</a>.
365Copyright &copy; 1995-2007
366<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
367<table width=100% cellspacing=0 border=0><tr>
368<td>Copyright &copy; 2007
369<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
370<td align=right><div align=right>Qt 3.3.8</div>
371</table></div></address></body>
372</html>
Note: See TracBrowser for help on using the repository browser.