Eneboo - Documentación para desarrolladores
|
The QImageIO class contains parameters for loading and saving images. Más...
#include <qimage.h>
Métodos públicos | |
QImageIO () | |
QImageIO (QIODevice *ioDevice, const char *format) | |
QImageIO (const QString &fileName, const char *format) | |
~QImageIO () | |
const QImage & | image () const |
int | status () const |
const char * | format () const |
QIODevice * | ioDevice () const |
QString | fileName () const |
int | quality () const |
QString | description () const |
const char * | parameters () const |
float | gamma () const |
void | setImage (const QImage &) |
void | setStatus (int) |
void | setFormat (const char *) |
void | setIODevice (QIODevice *) |
void | setFileName (const QString &) |
void | setQuality (int) |
void | setDescription (const QString &) |
void | setParameters (const char *) |
void | setGamma (float) |
bool | read () |
bool | write () |
QImageIO () | |
QImageIO (QIODevice *ioDevice, const char *format) | |
QImageIO (const QString &fileName, const char *format) | |
~QImageIO () | |
const QImage & | image () const |
int | status () const |
const char * | format () const |
QIODevice * | ioDevice () const |
QString | fileName () const |
int | quality () const |
QString | description () const |
const char * | parameters () const |
float | gamma () const |
void | setImage (const QImage &) |
void | setStatus (int) |
void | setFormat (const char *) |
void | setIODevice (QIODevice *) |
void | setFileName (const QString &) |
void | setQuality (int) |
void | setDescription (const QString &) |
void | setParameters (const char *) |
void | setGamma (float) |
bool | read () |
bool | write () |
Métodos públicos estáticos | |
static const char * | imageFormat (const QString &fileName) |
static const char * | imageFormat (QIODevice *) |
static QStrList | inputFormats () |
static QStrList | outputFormats () |
static void | defineIOHandler (const char *format, const char *header, const char *flags, image_io_handler read_image, image_io_handler write_image) |
static const char * | imageFormat (const QString &fileName) |
static const char * | imageFormat (QIODevice *) |
static QStrList | inputFormats () |
static QStrList | outputFormats () |
static void | defineIOHandler (const char *format, const char *header, const char *flags, image_io_handler read_image, image_io_handler write_image) |
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 provides.
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).
You don't normally need to use this class; QPixmap::load(), QPixmap::save(), and QImage contain sufficient functionality.
For image files that contain sequences of images, only the first is read. See 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.
GIF support may be removed completely in a future version of Qt. We recommend using the PNG format.
QImageIO::QImageIO | ( | ) |
Constructs a QImageIO object with all parameters set to zero.
QImageIO::QImageIO | ( | QIODevice * | ioDevice, |
const char * | format | ||
) |
Constructs a QImageIO object with the I/O device ioDevice and a format tag.
QImageIO::QImageIO | ( | const QString & | fileName, |
const char * | format | ||
) |
Constructs a QImageIO object with the file name fileName and a format tag.
QImageIO::~QImageIO | ( | ) |
Destroys the object and all related data.
QImageIO::QImageIO | ( | ) |
QImageIO::QImageIO | ( | QIODevice * | ioDevice, |
const char * | format | ||
) |
QImageIO::QImageIO | ( | const QString & | fileName, |
const char * | format | ||
) |
QImageIO::~QImageIO | ( | ) |
void QImageIO::defineIOHandler | ( | const char * | format, |
const char * | header, | ||
const char * | flags, | ||
image_io_handler | readImage, | ||
image_io_handler | writeImage | ||
) | [static] |
Defines an image I/O handler for the image format called format, which is recognized using the regular expression header, read using readImage and written using writeImage.
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 Qt 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 QImage; header is used to select a handler to read an image file.
If readImage is a null pointer, the QImageIO will not be able to read images in format. If writeImage is a null pointer, the QImageIO will not be able to write images in format. If both are null, the QImageIO object is valid but useless.
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 );
Before the regex test, all the 0 bytes in the file header are converted to 1 bytes. This is done because when Qt was ASCII-based, QRegExp could not handle 0 bytes in strings.
The regexp is only applied on the first 14 bytes of the file.
Note that Qt assumes that there is only one handler per format; if two handlers support the same format, Qt will choose one arbitrarily. It is not possible to have one handler support reading, and another support writing.
static void QImageIO::defineIOHandler | ( | const char * | format, |
const char * | header, | ||
const char * | flags, | ||
image_io_handler | read_image, | ||
image_io_handler | write_image | ||
) | [static] |
QString QImageIO::description | ( | ) | const [inline] |
QString QImageIO::description | ( | ) | const [inline] |
Returns the image description string.
QString QImageIO::fileName | ( | ) | const [inline] |
Returns the file name currently set.
QString QImageIO::fileName | ( | ) | const [inline] |
const char * QImageIO::format | ( | ) | const [inline] |
Returns the image format string or 0 if no format has been explicitly set.
const char* QImageIO::format | ( | ) | const [inline] |
float QImageIO::gamma | ( | ) | const |
Returns the gamma value at which the image will be viewed.
float QImageIO::gamma | ( | ) | const |
const QImage& QImageIO::image | ( | ) | const [inline] |
const QImage & QImageIO::image | ( | ) | const [inline] |
Returns the image currently set.
const char * QImageIO::imageFormat | ( | const QString & | fileName | ) | [static] |
Returns a string that specifies the image format of the file fileName, or null if the file cannot be read or if the format is not recognized.
const char * QImageIO::imageFormat | ( | QIODevice * | d | ) | [static] |
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. 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).
static const char* QImageIO::imageFormat | ( | const QString & | fileName | ) | [static] |
static const char* QImageIO::imageFormat | ( | QIODevice * | ) | [static] |
static QStrList QImageIO::inputFormats | ( | ) | [static] |
QStrList QImageIO::inputFormats | ( | ) | [static] |
Returns a sorted list of image formats that are supported for image input.
QIODevice * QImageIO::ioDevice | ( | ) | const [inline] |
Returns the IO device currently set.
QIODevice* QImageIO::ioDevice | ( | ) | const [inline] |
static QStrList QImageIO::outputFormats | ( | ) | [static] |
QStrList QImageIO::outputFormats | ( | ) | [static] |
Returns a sorted list of image formats that are supported for image output.
const char* QImageIO::parameters | ( | ) | const |
const char * QImageIO::parameters | ( | ) | const |
Returns the image's parameters string.
int QImageIO::quality | ( | ) | const |
Returns the quality of the written image, related to the compression ratio.
int QImageIO::quality | ( | ) | const |
bool QImageIO::read | ( | ) |
Reads an image into memory and returns TRUE if the image was successfully read; otherwise returns FALSE.
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:
QImageIO iio; QPixmap pixmap; iio.setFileName( "vegeburger.bmp" ); if ( image.read() ) // ok pixmap = iio.image(); // convert to pixmap
bool QImageIO::read | ( | ) |
void QImageIO::setDescription | ( | const QString & | description | ) |
Sets the image description string for image handlers that support image descriptions to description.
Currently, no image format supported by Qt uses the description string.
void QImageIO::setDescription | ( | const QString & | ) |
void QImageIO::setFileName | ( | const QString & | ) |
void QImageIO::setFileName | ( | const QString & | fileName | ) |
Sets the name of the file to read or write an image from to fileName.
void QImageIO::setFormat | ( | const char * | ) |
void QImageIO::setFormat | ( | const char * | format | ) |
Sets the image format to format for the image to be read or written.
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, Qt guesses the image format before reading it. If a format is set the image will only be read if it has that format.
void QImageIO::setGamma | ( | float | ) |
void QImageIO::setGamma | ( | float | gamma | ) |
Sets the gamma value at which the image will be viewed to gamma. 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).
The default value is 0.0.
void QImageIO::setImage | ( | const QImage & | ) |
void QImageIO::setIODevice | ( | QIODevice * | ) |
void QImageIO::setIODevice | ( | QIODevice * | ioDevice | ) |
Sets the IO device to be used for reading or writing an image.
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.
void QImageIO::setParameters | ( | const char * | ) |
void QImageIO::setParameters | ( | const char * | parameters | ) |
Sets the image's parameter string to parameters. This is for image handlers that require special parameters.
Although the current image formats supported by Qt ignore the parameters string, it may be used in future extensions or by contributions (for example, JPEG).
void QImageIO::setQuality | ( | int | q | ) |
Sets the quality of the written image to q, related to the compression ratio.
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.)
void QImageIO::setQuality | ( | int | ) |
void QImageIO::setStatus | ( | int | ) |
void QImageIO::setStatus | ( | int | status | ) |
Sets the image IO status to status. A non-zero value indicates an error, whereas 0 means that the IO operation was successful.
int QImageIO::status | ( | ) | const [inline] |
Returns the image's IO status. A non-zero value indicates an error, whereas 0 means that the IO operation was successful.
int QImageIO::status | ( | ) | const [inline] |
bool QImageIO::write | ( | void | ) |
Writes an image to an IO device and returns TRUE if the image was successfully written; otherwise returns FALSE.
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:
QImageIO iio; QImage im; im = pixmap; // convert to image iio.setImage( im ); iio.setFileName( "vegeburger.bmp" ); iio.setFormat( "BMP" ); if ( iio.write() ) // returned TRUE if written successfully
bool QImageIO::write | ( | ) |