![]() |
Home · Overviews · Examples |
The QImageReader class provides a format independent interface for reading images from files or other devices. More...
The QImageReader class provides a format independent interface for reading images from files or other devices.
The most common way to read images is through QImage and QPixmap's constructors, or by calling QImage::load() and QPixmap::load(). QImageReader is a specialized class which gives you more control when reading images. For example, you can read an image into a specific size by calling setScaledSize, and you can select a clip rect, effectively loading only parts of an image, by calling setClipRect. Depending on the underlying support in the image format, this can save memory and speed up loading of images.
To read an image, you start by constructing a QImageReader object. Pass either a file name or a device pointer, and the image format to QImageReader's constructor. You can then set several options, such as the clip rect (by calling setClipRect) and scaled size (by calling setScaledSize). canRead returns the image if the QImageReader can read the image (i.e., the image format is supported and the device is open for reading). Call read to read the image.
If any error occurs when reading the image, read will return a null QImage. You can then call error to find the type of error that occurred, or errorString to get a human readable description of what went wrong.
Call supportedImageFormats for a list of formats that QImageReader can read. QImageReader supports all built-in image formats, in addition to any image format plugins that support reading.
See also QImageWriter, QImageIOHandler, and QImageIOPlugin.
Copyright © 2007 Trolltech | Trademarks | Qt Jambi 4.3.2_01 |