You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/doc/man/man3/tqimageio.3qt

366 lines
13 KiB

'\" 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).