Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The TQImageIO class contains parameters for loading and saving images. More...
#include <qimage.h>
The TQImageIO class contains parameters for loading and saving images.
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.
TQt 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).
You don't normally need to use this class; TQPixmap::load(), TQPixmap::save(), and TQImage contain sufficient functionality.
For image files that contain sequences of images, only the first is read. See TQMovie for loading multiple images.
PBM, PGM, and PPM format output is always in the more condensed raw format. PPM and PGM files with more than 256 levels of intensity are scaled down when reading.
Warning: 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 retquire you to license the technology. Such countries include Canada, Japan, the USA, France, Germany, Italy and the UK.
GIF support may be removed completely in a future version of TQt. We recommend using the PNG format.
See also TQImage, TQPixmap, TQFile, TQMovie, Graphics Classes, Image Processing Classes, and Input/Output and Networking.
flags 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 flags 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.)
format is used to select a handler to write a TQImage; header is used to select a handler to read an image file.
If readImage is a null pointer, the TQImageIO will not be able to read images in format. If writeImage is a null pointer, the TQImageIO will not be able to write images in format. If both are null, the TQImageIO object is valid but useless.
Example:
void readGIF( TQImageIO *image ) { // read the image using the image->ioDevice() } void writeGIF( TQImageIO *image ) { // write the image using the image->ioDevice() } // add the GIF image handler TQImageIO::defineIOHandler( "GIF", "^GIF[0-9][0-9][a-z]", 0, readGIF, writeGIF );
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, TQRegExp could not handle 0 bytes in strings.
The regexp is only applied on the first 14 bytes of the file.
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.
Returns the image description string.
See also setDescription().
Returns the file name currently set.
See also setFileName().
Returns the image format string or 0 if no format has been explicitly set.
See also setGamma().
Returns the image currently set.
See also setImage().
Returns a string that specifies the image format of the image read from IO device d, or 0 if the device cannot be read or if the format is not recognized.
Make sure that d is at the right position in the device (for example, at the beginning of the file).
See also TQIODevice::at().
Returns the IO device currently set.
See also setIODevice().
Example: scribble/scribble.cpp.
See also setParameters().
See also setQuality() and TQImage::save().
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.
Setting the image file format string is optional.
Note that this function does not set the format used to read the image. If you need that information, use the imageFormat() static functions.
Example:
TQImageIO iio; TQPixmap pixmap; iio.setFileName( "vegeburger.bmp" ); if ( image.read() ) // ok pixmap = iio.image(); // convert to pixmap
See also setIODevice(), setFileName(), setFormat(), write(), and TQPixmap::load().
Currently, no image format supported by TQt uses the description string.
See also setIODevice().
It is necessary to specify a format before writing an image, but it is not necessary to specify a format before reading an image.
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.
See also read(), write(), and format().
The default value is 0.0.
See also gamma().
Setting the IO device allows images to be read/written to any block-oriented TQIODevice.
If ioDevice is not null, this IO device will override file name settings.
See also setFileName().
See also image().
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).
See also parameters().
q must be in the range -1..100. Specify 0 to obtain small compressed files, 100 for large uncompressed files. (-1 signifies the default compression.)
See also quality() and TQImage::save().
See also status().
Returns the image's IO status. A non-zero value indicates an error, whereas 0 means that the IO operation was successful.
See also setStatus().
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.
The image will be written using the specified image format.
Example:
TQImageIO iio; TQImage im; im = pixmap; // convert to image iio.setImage( im ); iio.setFileName( "vegeburger.bmp" ); iio.setFormat( "BMP" ); if ( iio.write() ) // returned TRUE if written successfully
See also setIODevice(), setFileName(), setFormat(), read(), and TQPixmap::save().
This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.
Copyright © 2007 Trolltech | Trademarks | TQt 3.3.8
|