summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/qimageio.3qt
blob: c74b7f20d006228c02899f342f416b47f9382194 (plain)
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
'\" t
.TH QImageIO 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA.  All rights reserved.  See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QImageIO \- Parameters for loading and saving images
.SH SYNOPSIS
\fC#include <ntqimage.h>\fR
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQImageIO\fR ()"
.br
.ti -1c
.BI "\fBQImageIO\fR ( QIODevice * ioDevice, const char * format )"
.br
.ti -1c
.BI "\fBQImageIO\fR ( const QString & fileName, const char * format )"
.br
.ti -1c
.BI "\fB~QImageIO\fR ()"
.br
.ti -1c
.BI "const QImage & \fBimage\fR () const"
.br
.ti -1c
.BI "int \fBstatus\fR () const"
.br
.ti -1c
.BI "const char * \fBformat\fR () const"
.br
.ti -1c
.BI "QIODevice * \fBioDevice\fR () const"
.br
.ti -1c
.BI "QString \fBfileName\fR () const"
.br
.ti -1c
.BI "int \fBquality\fR () const"
.br
.ti -1c
.BI "QString \fBdescription\fR () const"
.br
.ti -1c
.BI "const char * \fBparameters\fR () const"
.br
.ti -1c
.BI "float \fBgamma\fR () const"
.br
.ti -1c
.BI "void \fBsetImage\fR ( const QImage & image )"
.br
.ti -1c
.BI "void \fBsetStatus\fR ( int status )"
.br
.ti -1c
.BI "void \fBsetFormat\fR ( const char * format )"
.br
.ti -1c
.BI "void \fBsetIODevice\fR ( QIODevice * ioDevice )"
.br
.ti -1c
.BI "void \fBsetFileName\fR ( const QString & fileName )"
.br
.ti -1c
.BI "void \fBsetQuality\fR ( int q )"
.br
.ti -1c
.BI "void \fBsetDescription\fR ( const QString & description )"
.br
.ti -1c
.BI "void \fBsetParameters\fR ( const char * parameters )"
.br
.ti -1c
.BI "void \fBsetGamma\fR ( float gamma )"
.br
.ti -1c
.BI "bool \fBread\fR ()"
.br
.ti -1c
.BI "bool \fBwrite\fR ()"
.br
.in -1c
.SS "Static Public Members"
.in +1c
.ti -1c
.BI "const char * \fBimageFormat\fR ( const QString & fileName )"
.br
.ti -1c
.BI "const char * \fBimageFormat\fR ( QIODevice * d )"
.br
.ti -1c
.BI "QStrList \fBinputFormats\fR ()"
.br
.ti -1c
.BI "QStrList \fBoutputFormats\fR ()"
.br
.ti -1c
.BI "void \fBdefineIOHandler\fR ( const char * format, const char * header, const char * flags, image_io_handler readImage, image_io_handler writeImage )"
.br
.in -1c
.SH DESCRIPTION
The QImageIO class contains parameters for loading and saving images.
.PP
QImageIO contains a QIODevice object that is used for image data I/O. The programmer can install new image file formats in addition to those that Qt provides.
.PP
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), and PPM (P3 or P6).
.PP
You don't normally need to use this class; QPixmap::load(), QPixmap::save(), and QImage contain sufficient functionality.
.PP
For image files that contain sequences of images, only the first is read. See QMovie for loading multiple images.
.PP
PBM, PGM, and PPM format \fIoutput\fR is always in the more condensed raw format. PPM and PGM files with more than 256 levels of intensity are scaled down when reading.
.PP
\fBWarning:\fR If you are in a country which recognizes software patents and in which Unisys holds a patent on LZW compression and/or decompression and you want to use GIF, Unisys may require you to license the technology. Such countries include Canada, Japan, the USA, France, Germany, Italy and the UK.
.PP
GIF support may be removed completely in a future version of Qt. We recommend using the PNG format.
.PP
See also QImage, QPixmap, QFile, QMovie, Graphics Classes, Image Processing Classes, and Input/Output and Networking.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QImageIO::QImageIO ()"
Constructs a QImageIO object with all parameters set to zero.
.SH "QImageIO::QImageIO ( QIODevice * ioDevice, const char * format )"
Constructs a QImageIO object with the I/O device \fIioDevice\fR and a \fIformat\fR tag.
.SH "QImageIO::QImageIO ( const QString & fileName, const char * format )"
Constructs a QImageIO object with the file name \fIfileName\fR and a \fIformat\fR tag.
.SH "QImageIO::~QImageIO ()"
Destroys the object and all related data.
.SH "void QImageIO::defineIOHandler ( const char * format, const char * header, const char * flags, image_io_handler readImage, image_io_handler writeImage )\fC [static]\fR"
Defines an image I/O handler for the image format called \fIformat\fR, which is recognized using the regular expression \fIheader\fR, read using \fIreadImage\fR and written using \fIwriteImage\fR.
.PP
\fIflags\fR is a string of single-character flags for this format. The only flag defined currently is T (upper case), so the only legal value for \fIflags\fR are "T" and the empty string. The "T" flag means that the image file is a text file, and Qt should treat all newline conventions as equivalent. (XPM files and some PPM files are text files for example.)
.PP
\fIformat\fR is used to select a handler to write a QImage; \fIheader\fR is used to select a handler to read an image file.
.PP
If \fIreadImage\fR is a null pointer, the QImageIO will not be able to read images in \fIformat\fR. If \fIwriteImage\fR is a null pointer, the QImageIO will not be able to write images in \fIformat\fR. If both are null, the QImageIO object is valid but useless.
.PP
Example:
.PP
.nf
.br
        void readGIF( QImageIO *image )
.br
        {
.br
        // read the image using the image->ioDevice()
.br
        }
.br
.br
        void writeGIF( QImageIO *image )
.br
        {
.br
        // write the image using the image->ioDevice()
.br
        }
.br
.br
        // add the GIF image handler
.br
.br
        QImageIO::defineIOHandler( "GIF",
.br
                                   "^GIF[0-9][0-9][a-z]",
.br
                                   0,
.br
                                   readGIF,
.br
                                   writeGIF );
.br
.fi
.PP
Before the regex test, all the 0 bytes in the file header are converted to 1 bytes. This is done because when Qt was ASCII-based, QRegExp could not handle 0 bytes in strings.
.PP
The regexp is only applied on the first 14 bytes of the file.
.PP
Note that Qt assumes that there is only one handler per format; if two handlers support the same format, Qt will choose one arbitrarily. It is not possible to have one handler support reading, and another support writing.
.SH "QString QImageIO::description () const"
Returns the image description string.
.PP
See also setDescription().
.SH "QString QImageIO::fileName () const"
Returns the file name currently set.
.PP
See also setFileName().
.SH "const char * QImageIO::format () const"
Returns the image format string or 0 if no format has been explicitly set.
.SH "float QImageIO::gamma () const"
Returns the gamma value at which the image will be viewed.
.PP
See also setGamma().
.SH "const QImage & QImageIO::image () const"
Returns the image currently set.
.PP
See also setImage().
.SH "const char * QImageIO::imageFormat ( const QString & fileName )\fC [static]\fR"
Returns a string that specifies the image format of the file \fIfileName\fR, or null if the file cannot be read or if the format is not recognized.
.SH "const char * QImageIO::imageFormat ( QIODevice * d )\fC [static]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns a string that specifies the image format of the image read from IO device \fId\fR, or 0 if the device cannot be read or if the format is not recognized.
.PP
Make sure that \fId\fR is at the right position in the device (for example, at the beginning of the file).
.PP
See also QIODevice::at().
.SH "QStrList QImageIO::inputFormats ()\fC [static]\fR"
Returns a sorted list of image formats that are supported for image input.
.SH "QIODevice * QImageIO::ioDevice () const"
Returns the IO device currently set.
.PP
See also setIODevice().
.SH "QStrList QImageIO::outputFormats ()\fC [static]\fR"
Returns a sorted list of image formats that are supported for image output.
.PP
Example: scribble/scribble.cpp.
.SH "const char * QImageIO::parameters () const"
Returns the image's parameters string.
.PP
See also setParameters().
.SH "int QImageIO::quality () const"
Returns the quality of the written image, related to the compression ratio.
.PP
See also setQuality() and QImage::save().
.SH "bool QImageIO::read ()"
Reads an image into memory and returns TRUE if the image was successfully read; otherwise returns FALSE.
.PP
Before reading an image you must set an IO device or a file name. If both an IO device and a file name have been set, the IO device will be used.
.PP
Setting the image file format string is optional.
.PP
Note that this function does \fInot\fR set the format used to read the image. If you need that information, use the imageFormat() static functions.
.PP
Example:
.PP
.nf
.br
        QImageIO iio;
.br
        QPixmap  pixmap;
.br
        iio.setFileName( "vegeburger.bmp" );
.br
        if ( image.read() )        // ok
.br
            pixmap = iio.image();  // convert to pixmap
.br
.fi
.PP
See also setIODevice(), setFileName(), setFormat(), write(), and QPixmap::load().
.SH "void QImageIO::setDescription ( const QString & description )"
Sets the image description string for image handlers that support image descriptions to \fIdescription\fR.
.PP
Currently, no image format supported by Qt uses the description string.
.SH "void QImageIO::setFileName ( const QString & fileName )"
Sets the name of the file to read or write an image from to \fIfileName\fR.
.PP
See also setIODevice().
.SH "void QImageIO::setFormat ( const char * format )"
Sets the image format to \fIformat\fR for the image to be read or written.
.PP
It is necessary to specify a format before writing an image, but it is not necessary to specify a format before reading an image.
.PP
If no format has been set, Qt guesses the image format before reading it. If a format is set the image will only be read if it has that format.
.PP
See also read(), write(), and format().
.SH "void QImageIO::setGamma ( float gamma )"
Sets the gamma value at which the image will be viewed to \fIgamma\fR. If the image format stores a gamma value for which the image is intended to be used, then this setting will be used to modify the image. Setting to 0.0 will disable gamma correction (i.e. any specification in the file will be ignored).
.PP
The default value is 0.0.
.PP
See also gamma().
.SH "void QImageIO::setIODevice ( QIODevice * ioDevice )"
Sets the IO device to be used for reading or writing an image.
.PP
Setting the IO device allows images to be read/written to any block-oriented QIODevice.
.PP
If \fIioDevice\fR is not null, this IO device will override file name settings.
.PP
See also setFileName().
.SH "void QImageIO::setImage ( const QImage & image )"
Sets the image to \fIimage\fR.
.PP
See also image().
.SH "void QImageIO::setParameters ( const char * parameters )"
Sets the image's parameter string to \fIparameters\fR. This is for image handlers that require special parameters.
.PP
Although the current image formats supported by Qt ignore the parameters string, it may be used in future extensions or by contributions (for example, JPEG).
.PP
See also parameters().
.SH "void QImageIO::setQuality ( int q )"
Sets the quality of the written image to \fIq\fR, related to the compression ratio.
.PP
\fIq\fR must be in the range -1..100. Specify 0 to obtain small compressed files, 100 for large uncompressed files. (-1 signifies the default compression.)
.PP
See also quality() and QImage::save().
.SH "void QImageIO::setStatus ( int status )"
Sets the image IO status to \fIstatus\fR. A non-zero value indicates an error, whereas 0 means that the IO operation was successful.
.PP
See also status().
.SH "int QImageIO::status () const"
Returns the image's IO status. A non-zero value indicates an error, whereas 0 means that the IO operation was successful.
.PP
See also setStatus().
.SH "bool QImageIO::write ()"
Writes an image to an IO device and returns TRUE if the image was successfully written; otherwise returns FALSE.
.PP
Before writing an image you must set an IO device or a file name. If both an IO device and a file name have been set, the IO device will be used.
.PP
The image will be written using the specified image format.
.PP
Example:
.PP
.nf
.br
        QImageIO iio;
.br
        QImage   im;
.br
        im = pixmap; // convert to image
.br
        iio.setImage( im );
.br
        iio.setFileName( "vegeburger.bmp" );
.br
        iio.setFormat( "BMP" );
.br
        if ( iio.write() )
.br
            // returned TRUE if written successfully
.br
.fi
.PP
See also setIODevice(), setFileName(), setFormat(), read(), and QPixmap::save().

.SH "SEE ALSO"
.BR http://doc.trolltech.com/qimageio.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech. 
.P
If you find errors in this manual page, please report them to
.BR [email protected] .
Please include the name of the manual page (qimageio.3qt) and the Qt
version (3.3.8).