File: qimageio.html

package info (click to toggle)
qt-embedded 2.3.2-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 68,608 kB
  • ctags: 45,998
  • sloc: cpp: 276,654; ansic: 71,987; makefile: 29,074; sh: 12,305; yacc: 2,465; python: 1,863; perl: 481; lex: 480; xml: 68; lisp: 15
file content (247 lines) | stat: -rw-r--r-- 15,408 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QImageIO Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">

<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>

<h1 align=center>QImageIO Class Reference</h1><br clear="all">
<p>
The QImageIO class contains parameters for loading and saving images.
<a href="#details">More...</a>
<p>
<code>#include &lt;<a href="qimage-h.html">qimage.h</a>&gt;</code>
<p><a href="qimageio-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#afc47b"><b>QImageIO</b></a>()</div>
<li><div class="fn"><a href="#ff7b34"><b>QImageIO</b></a>(QIODevice*ioDevice, constchar*format)</div>
<li><div class="fn"><a href="#a49478"><b>QImageIO</b></a>(constQString&amp;fileName, constchar*format)</div>
<li><div class="fn"><a href="#b8d6a8"><b>~QImageIO</b></a>()</div>
<li><div class="fn">constQImage&amp;<a href="#3bed6d"><b>image</b></a>()const</div>
<li><div class="fn">int<a href="#cef10f"><b>status</b></a>()const</div>
<li><div class="fn">constchar*<a href="#11648f"><b>format</b></a>()const</div>
<li><div class="fn">QIODevice*<a href="#5437be"><b>ioDevice</b></a>()const</div>
<li><div class="fn">QString<a href="#8aad19"><b>fileName</b></a>()const</div>
<li><div class="fn">constchar*<a href="#bbfc9f"><b>parameters</b></a>()const</div>
<li><div class="fn">QString<a href="#a4d516"><b>description</b></a>()const</div>
<li><div class="fn">void<a href="#1f6590"><b>setImage</b></a>(constQImage&amp;)</div>
<li><div class="fn">void<a href="#7d6c7e"><b>setStatus</b></a>(int)</div>
<li><div class="fn">void<a href="#ca413e"><b>setFormat</b></a>(constchar*)</div>
<li><div class="fn">void<a href="#d05dce"><b>setIODevice</b></a>(QIODevice*)</div>
<li><div class="fn">void<a href="#55b14c"><b>setFileName</b></a>(constQString&amp;)</div>
<li><div class="fn">void<a href="#c30e03"><b>setParameters</b></a>(constchar*)</div>
<li><div class="fn">void<a href="#03ae95"><b>setDescription</b></a>(constQString&amp;)</div>
<li><div class="fn">bool<a href="#be99e5"><b>read</b></a>()</div>
<li><div class="fn">bool<a href="#ee15db"><b>write</b></a>()</div>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class="fn">constchar*<a href="#05c737"><b>imageFormat</b></a>(constQString&amp;fileName)</div>
<li><div class="fn">constchar*<a href="#91d640"><b>imageFormat</b></a>(QIODevice*)</div>
<li><div class="fn">QStrList<a href="#9824aa"><b>inputFormats</b></a>()</div>
<li><div class="fn">QStrList<a href="#040fd9"><b>outputFormats</b></a>()</div>
<li><div class="fn">void<a href="#4d20fa"><b>defineIOHandler</b></a>(constchar*format, constchar*header, constchar*flags, image_io_handlerread_image, image_io_handlerwrite_image)</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QImageIO class contains parameters for loading and saving images.
<p>
QImageIO contains a <a href="qiodevice.html">QIODevice</a> object that is used for image data I/O.
The programmer can install new image file formats in addition to those
that Qt implements.
<p>Qt currently supports the following image file formats: PNG, BMP,
XBM, XPM and PNM.  It may also support JPEG, MNG and GIF, if specially
configured during compilation.  The different PNM formats are: PBM
(P1 or P4), PGM (P2 or P5), PPM (P3 or P6).
<p>You will normally not need to use this class, <a href="qpixmap.html#a728cf">QPixmap::load</a>(),
<a href="qpixmap.html#a38b1c">QPixmap::save</a>() and <a href="qimage.html">QImage</a> contain most of the needed functionality.
<p>For image files which contain sequences of images, only the first is
read.  See the <a href="qmovie.html">QMovie</a> for loading multiple images.
<p>PBM, PGM, and PPM format <em>output</em> is always in the more condensed
raw format. PPM and PGM files with more than 256 levels of intensity
are scaled down when reading.<p><b>Warning:</b> Unisys has changed its position regarding GIF.  If you are
in a country where Unisys holds a patent on LZW compression and/or
decompression and you want to use GIF, Unisys may require you to
license that technology.  These countries include Canada, Japan, the
USA, France, Germany, Italy and the UK.
<p>GIF support may be removed completely in a future version of Qt.  We
recommend using the PNG format.
<p>See also  <a href="qimage.html">QImage</a>, <a href="qpixmap.html">QPixmap</a>, <a href="qfile.html">QFile</a> and <a href="qmovie.html">QMovie</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="afc47b"></a>QImageIO::QImageIO()</h3>
<p>Constructs a QImageIO object with all parameters set to zero.
<h3 class="fn"><a name="ff7b34"></a>QImageIO::QImageIO(<a href="qiodevice.html">QIODevice</a>*ioDevice, constchar*format)</h3>
<p>Constructs a QImageIO object with an I/O device and a format tag.
<h3 class="fn"><a name="a49478"></a>QImageIO::QImageIO(const<a href="qstring.html">QString</a>&amp;fileName, constchar*format)</h3>
<p>Constructs a QImageIO object with a file name and a format tag.
<h3 class="fn"><a name="b8d6a8"></a>QImageIO::~QImageIO()</h3>
<p>Destructs the object and all related data.
<h3 class="fn">void<a name="4d20fa"></a>QImageIO::defineIOHandler(constchar*format, constchar*header, constchar*flags, image_io_handlerread_image, image_io_handlerwrite_image) <code>[static]</code></h3>
<p>Defines a image IO handler for a specified image format.
An image IO handler is responsible for reading and writing images.
<p>Arguments:
<ul>
<li><em>format</em> is the name of the format.
<li><em>header</em> is a regular expression that recognizes the image header.
<li><em>flags</em> is "T" for text formats like PBM; generally you will
want to use 0.
<li><em>read_image</em> is a function to read an image of this format.
<li><em>write_image</em> is a function to write an image of this format.
</ul>
Both read_image and write_image are of type image_io_handler, which is
a function pointer.
<p>Example:
<pre>    void readGIF( <a href="qimageio.html">QImageIO</a> *image )
    {
      // read the image, using the image-&gt;<a href="#5437be">ioDevice</a>()
    }

    void writeGIF( <a href="qimageio.html">QImageIO</a> *image )
    {
      // write the image, using the image-&gt;<a href="#5437be">ioDevice</a>()
    }

    // add the GIF image handler

    <a href="#4d20fa">QImageIO::defineIOHandler</a>( "GIF",
                               "^GIF[0-9][0-9][a-z]",
                               0,
                               readGIF,
                               writeGIF );
</pre>
<p>Prior to comparison with the regular expression, the file header is
converted to change all 0 bytes into 1 bytes. This is done because 0
is such a common header byte yet regular expressions cannot match it.
<p>For image formats supporting incremental display, such as sequences
of animated frames, see the <a href="qimageformattype.html">QImageFormatType</a> class.
<h3 class="fn"><a href="qstring.html">QString</a><a name="a4d516"></a>QImageIO::description()const</h3>
<p>Returns the image description string.
<p>See also  <a href="#03ae95">setDescription</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="8aad19"></a>QImageIO::fileName()const</h3>
<p>Returns the file name currently set.
<p>See also  <a href="#55b14c">setFileName</a>().
<h3 class="fn">constchar*<a name="11648f"></a>QImageIO::format()const</h3>
<p>Returns the image format string, or 0 if no format has been explicitly set.
<h3 class="fn">const<a href="qimage.html">QImage</a>&amp;<a name="3bed6d"></a>QImageIO::image()const</h3>
<p>Returns the image currently set.
<p>See also  <a href="#1f6590">setImage</a>().
<h3 class="fn">constchar*<a name="91d640"></a>QImageIO::imageFormat(<a href="qiodevice.html">QIODevice</a>*d) <code>[static]</code></h3>
<p>Returns a string that specifies the image format of the image read from
<em>d,</em> or null if the file cannot be read or if the format is not recognized.
<h3 class="fn">constchar*<a name="05c737"></a>QImageIO::imageFormat(const<a href="qstring.html">QString</a>&amp;fileName) <code>[static]</code></h3>
<p>Returns a string that specifies the image format of the file <em>fileName,</em>
or null if the file cannot not be read or if the format is not recognized.
<h3 class="fn"><a href="qstrlist.html">QStrList</a><a name="9824aa"></a>QImageIO::inputFormats() <code>[static]</code></h3>
<p>Returns a sorted list of image formats which are supported for image input.
<h3 class="fn"><a href="qiodevice.html">QIODevice</a>*<a name="5437be"></a>QImageIO::ioDevice()const</h3>
<p>Returns the IO device currently set.
<p>See also  <a href="#d05dce">setIODevice</a>().
<h3 class="fn"><a href="qstrlist.html">QStrList</a><a name="040fd9"></a>QImageIO::outputFormats() <code>[static]</code></h3>
<p>Returns a sorted list of image formats which are supported for image output.
<h3 class="fn">constchar*<a name="bbfc9f"></a>QImageIO::parameters()const</h3>
<p>Returns image parameters string.
<p>See also  <a href="#c30e03">setParameters</a>().
<h3 class="fn">bool<a name="be99e5"></a>QImageIO::read()</h3>
<p>Reads an image into memory and returns TRUE if the image was successfully
read.
<p>Before reading an image, you must set an IO device or a file name.
If both an IO device and a file name has been set, then the IO device will
be used.
<p>Setting the image file format string is optional.
<p>Note that this function does <em>not</em> set the <a href="#11648f">format</a>
used to read the image.  If you need that information, use the <a href="#05c737">imageFormat</a>()
static functions.
<p>Example:
<p><pre>    <a href="qimageio.html">QImageIO</a> iio;
    <a href="qpixmap.html">QPixmap</a>  pixmap;
    iio.<a href="#55b14c">setFileName</a>( "burger.bmp" );
    if ( image.read() )                 // ok
        pixmap = iio.<a href="#3bed6d">image</a>();           // convert to pixmap
</pre>
<p>See also  <a href="#d05dce">setIODevice</a>(), <a href="#55b14c">setFileName</a>(), <a href="#ca413e">setFormat</a>(), <a href="#ee15db">write</a>() and <a href="qpixmap.html#a728cf">QPixmap::load</a>().
<h3 class="fn">void<a name="03ae95"></a>QImageIO::setDescription(const<a href="qstring.html">QString</a>&amp;description)</h3>
<p>Sets the image description string for image handlers that support image
descriptions.
<p>Currently, no image format supported by Qt use the description string.
<h3 class="fn">void<a name="55b14c"></a>QImageIO::setFileName(const<a href="qstring.html">QString</a>&amp;fileName)</h3>
<p>Sets the name of the file to read or write an image.
<p>See also  <a href="#d05dce">setIODevice</a>().
<h3 class="fn">void<a name="ca413e"></a>QImageIO::setFormat(constchar*format)</h3>
<p>Sets the image format name of the image about to be read or written.
<p>It is necessary to specify a format before writing an image.
<p>It is not necessary to specify a format before reading an image.
If not format has been set, Qt guesses the image format before reading
it.  If a format is set, but the image has another (valid) format,
the image will not be read.
<p>See also  <a href="#be99e5">read</a>(), <a href="#ee15db">write</a>() and <a href="#11648f">format</a>().
<h3 class="fn">void<a name="d05dce"></a>QImageIO::setIODevice(<a href="qiodevice.html">QIODevice</a>*ioDevice)</h3>
<p>Sets the IO device to be used for reading or writing an image.
<p>Setting the IO device allows images to be read/written to any
block-oriented <a href="qiodevice.html">QIODevice</a>.
<p>If <em>ioDevice</em> is not null, this IO device will override file name
settings.
<p>See also  <a href="#55b14c">setFileName</a>().
<h3 class="fn">void<a name="1f6590"></a>QImageIO::setImage(const<a href="qimage.html">QImage</a>&amp;image)</h3>
<p>Sets the image.
<p>See also  <a href="#3bed6d">image</a>().
<h3 class="fn">void<a name="c30e03"></a>QImageIO::setParameters(constchar*parameters)</h3>
<p>Sets the image parameters string for image handlers that require
special parameters.
<p>Although all image formats supported by Qt ignore the parameters string,
it will be useful for future extensions or contributions (like JPEG).
<h3 class="fn">void<a name="7d6c7e"></a>QImageIO::setStatus(intstatus)</h3>
<p>Sets the image IO status.  A non-zero value indicates an error, while 0 means
that the IO operation was successful.
<p>See also  <a href="#cef10f">status</a>().
<h3 class="fn">int<a name="cef10f"></a>QImageIO::status()const</h3>
<p>Returns the image IO status.  A non-zero value indicates an error, while 0
means that the IO operation was successful.
<p>See also  <a href="#7d6c7e">setStatus</a>().
<h3 class="fn">bool<a name="ee15db"></a>QImageIO::write()</h3>
<p>Writes an image to an IO device and returns TRUE if the image was
successfully written.
<p>Before writing an image, you must set an IO device or a file name.
If both an IO device and a file name has been set, then the IO
device will be used.
<p>The image will be written using the specified image format.
<p>Example:
<pre>    <a href="qimageio.html">QImageIO</a> iio;
    <a href="qimage.html">QImage</a>   im;
    im = pixmap;                                // convert to image
    iio.<a href="#1f6590">setImage</a>( im );
    iio.<a href="#55b14c">setFileName</a>( "burger.bmp" );
    iio.<a href="#ca413e">setFormat</a>( "BMP" );
    iio.<a href="#ee15db">write</a>();                                // TRUE if ok
</pre>
<p>See also  <a href="#d05dce">setIODevice</a>(), <a href="#55b14c">setFileName</a>(), <a href="#ca413e">setFormat</a>(), <a href="#be99e5">read</a>() and <a href="qpixmap.html#a38b1c">QPixmap::save</a>().
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright &copy; 1995-2001
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright  2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>