Qtopia Home - Classes - Hierachy - Annotated - Functions - Licenses - Reference |
|
The QImageIO class contains parameters for loading and saving images. More...
#include <qimage.h>
The QImageIO class contains parameters for loading and saving images.
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 implements.
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).
You will normally not need to use this class, QPixmap::load(), QPixmap::save() and QImage contain most of the needed functionality.
For image files which contain sequences of images, only the first is read. See the QMovie 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: 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.
GIF support may be removed completely in a future version of Qt. We recommend using the PNG format.
See also QImage, QPixmap, QFile, and QMovie.
\arg format is the name of the format. \arg header is a regular expression that recognizes the image header. \arg flags is "T" for text formats like PBM; generally you will want to use 0. \arg read_image is a function to read an image of this format. \arg write_image is a function to write an image of this format.
Both read_image and write_image are of type image_io_handler, which is a function pointer.
Example:
void readGIF( QImageIO *image )
{
// read the image, using the image->ioDevice()
}
void writeGIF( QImageIO *image )
{
// write the image, using the image->ioDevice()
}
// add the GIF image handler
QImageIO::defineIOHandler( "GIF",
"^GIF[0-9][0-9][a-z]",
0,
readGIF,
writeGIF );
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.
For image formats supporting incremental display, such as sequences of animated frames, see the QImageFormatType class.
See also setDescription().
See also setFileName().
See also setImage().
See also setIODevice().
See also setParameters().
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.
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:
QImageIO iio;
QPixmap pixmap;
iio.setFileName( "burger.bmp" );
if ( image.read() ) // ok
pixmap = iio.image(); // convert to pixmap
See also setIODevice(), setFileName(), setFormat(), write(), and QPixmap::load().
Currently, no image format supported by Qt use the description string.
See also setIODevice().
It is necessary to specify a format before writing an image.
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.
See also read(), write(), and format().
Setting the IO device allows images to be read/written to any block-oriented QIODevice.
If ioDevice is not null, this IO device will override file name settings.
See also setFileName().
See also image().
Although all image formats supported by Qt ignore the parameters string, it will be useful for future extensions or contributions (like JPEG).
See also status().
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 has been set, then the IO device will be used.
The image will be written using the specified image format.
Example:
QImageIO iio;
QImage im;
im = pixmap; // convert to image
iio.setImage( im );
iio.setFileName( "burger.bmp" );
iio.setFormat( "BMP" );
iio.write(); // TRUE if ok
See also setIODevice(), setFileName(), setFormat(), read(), and QPixmap::save().
This file is part of the Qtopia platform, copyright © 1995-2005 Trolltech, all rights reserved.
| Copyright © 2005 Trolltech | Trademarks | Qtopia version 2.2.0
|