summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/tqimageio.3qt
blob: 327ed5ffd4bd973665bd2361ddae38ba16871877 (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 TQImageIO 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
TQImageIO \- Parameters for loading and saving images
.SH SYNOPSIS
\fC#include <tqimage.h>\fR
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBTQImageIO\fR ()"
.br
.ti -1c
.BI "\fBTQImageIO\fR ( TQIODevice * ioDevice, const char * format )"
.br
.ti -1c
.BI "\fBTQImageIO\fR ( const TQString & fileName, const char * format )"
.br
.ti -1c
.BI "\fB~TQImageIO\fR ()"
.br
.ti -1c
.BI "const TQImage & \fBimage\fR () const"
.br
.ti -1c
.BI "int \fBstatus\fR () const"
.br
.ti -1c
.BI "const char * \fBformat\fR () const"
.br
.ti -1c
.BI "TQIODevice * \fBioDevice\fR () const"
.br
.ti -1c
.BI "TQString \fBfileName\fR () const"
.br
.ti -1c
.BI "int \fBquality\fR () const"
.br
.ti -1c
.BI "TQString \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 TQImage & 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 ( TQIODevice * ioDevice )"
.br
.ti -1c
.BI "void \fBsetFileName\fR ( const TQString & fileName )"
.br
.ti -1c
.BI "void \fBsetQuality\fR ( int q )"
.br
.ti -1c
.BI "void \fBsetDescription\fR ( const TQString & 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 TQString & fileName )"
.br
.ti -1c
.BI "const char * \fBimageFormat\fR ( TQIODevice * d )"
.br
.ti -1c
.BI "TQStrList \fBinputFormats\fR ()"
.br
.ti -1c
.BI "TQStrList \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 TQImageIO class contains parameters for loading and saving images.
.PP
TQImageIO contains a TQIODevice object that is used for image data I/O. The programmer can install new image file formats in addition to those that TQt 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 TQImage 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 TQImage, QPixmap, QFile, QMovie, Graphics Classes, Image Processing Classes, and Input/Output and Networking.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "TQImageIO::TQImageIO ()"
Constructs a TQImageIO object with all parameters set to zero.
.SH "TQImageIO::TQImageIO ( TQIODevice * ioDevice, const char * format )"
Constructs a TQImageIO object with the I/O device \fIioDevice\fR and a \fIformat\fR tag.
.SH "TQImageIO::TQImageIO ( const TQString & fileName, const char * format )"
Constructs a TQImageIO object with the file name \fIfileName\fR and a \fIformat\fR tag.
.SH "TQImageIO::~TQImageIO ()"
Destroys the object and all related data.
.SH "void TQImageIO::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 TQt 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 TQImage; \fIheader\fR is used to select a handler to read an image file.
.PP
If \fIreadImage\fR is a null pointer, the TQImageIO will not be able to read images in \fIformat\fR. If \fIwriteImage\fR is a null pointer, the TQImageIO will not be able to write images in \fIformat\fR. If both are null, the TQImageIO object is valid but useless.
.PP
Example:
.PP
.nf
.br
        void readGIF( TQImageIO *image )
.br
        {
.br
        // read the image using the image->ioDevice()
.br
        }
.br
.br
        void writeGIF( TQImageIO *image )
.br
        {
.br
        // write the image using the image->ioDevice()
.br
        }
.br
.br
        // add the GIF image handler
.br
.br
        TQImageIO::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 TQt 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 TQt assumes that there is only one handler per format; if two handlers support the same format, TQt will choose one arbitrarily. It is not possible to have one handler support reading, and another support writing.
.SH "TQString TQImageIO::description () const"
Returns the image description string.
.PP
See also setDescription().
.SH "TQString TQImageIO::fileName () const"
Returns the file name currently set.
.PP
See also setFileName().
.SH "const char * TQImageIO::format () const"
Returns the image format string or 0 if no format has been explicitly set.
.SH "float TQImageIO::gamma () const"
Returns the gamma value at which the image will be viewed.
.PP
See also setGamma().
.SH "const TQImage & TQImageIO::image () const"
Returns the image currently set.
.PP
See also setImage().
.SH "const char * TQImageIO::imageFormat ( const TQString & 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 * TQImageIO::imageFormat ( TQIODevice * 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 TQIODevice::at().
.SH "TQStrList TQImageIO::inputFormats ()\fC [static]\fR"
Returns a sorted list of image formats that are supported for image input.
.SH "TQIODevice * TQImageIO::ioDevice () const"
Returns the IO device currently set.
.PP
See also setIODevice().
.SH "TQStrList TQImageIO::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 * TQImageIO::parameters () const"
Returns the image's parameters string.
.PP
See also setParameters().
.SH "int TQImageIO::quality () const"
Returns the quality of the written image, related to the compression ratio.
.PP
See also setQuality() and TQImage::save().
.SH "bool TQImageIO::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
        TQImageIO 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 TQImageIO::setDescription ( const TQString & description )"
Sets the image description string for image handlers that support image descriptions to \fIdescription\fR.
.PP
Currently, no image format supported by TQt uses the description string.
.SH "void TQImageIO::setFileName ( const TQString & fileName )"
Sets the name of the file to read or write an image from to \fIfileName\fR.
.PP
See also setIODevice().
.SH "void TQImageIO::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, TQt 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 TQImageIO::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 TQImageIO::setIODevice ( TQIODevice * 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 TQIODevice.
.PP
If \fIioDevice\fR is not null, this IO device will override file name settings.
.PP
See also setFileName().
.SH "void TQImageIO::setImage ( const TQImage & image )"
Sets the image to \fIimage\fR.
.PP
See also image().
.SH "void TQImageIO::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 TQt ignore the parameters string, it may be used in future extensions or by contributions (for example, JPEG).
.PP
See also parameters().
.SH "void TQImageIO::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 TQImage::save().
.SH "void TQImageIO::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 TQImageIO::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 TQImageIO::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
        TQImageIO iio;
.br
        TQImage   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/tqimageio.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 TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt 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 qt-bugs@trolltech.com .
Please include the name of the manual page (tqimageio.3qt) and the Qt
version (3.3.8).