Qt 4.8
|
The QPictureIO class contains parameters for loading and saving pictures. More...
#include <qpicture.h>
Public Functions | |
QString | description () const |
Returns the picture description string. More... | |
QString | fileName () const |
Returns the file name currently set. More... | |
const char * | format () const |
Returns the picture format string or 0 if no format has been explicitly set. More... | |
float | gamma () const |
Returns the gamma value at which the picture will be viewed. More... | |
QIODevice * | ioDevice () const |
Returns the IO device currently set. More... | |
const char * | parameters () const |
Returns the picture's parameters string. More... | |
const QPicture & | picture () const |
Returns the picture currently set. More... | |
QPictureIO () | |
Constructs a QPictureIO object with all parameters set to zero. More... | |
QPictureIO (QIODevice *ioDevice, const char *format) | |
Constructs a QPictureIO object with the I/O device ioDevice and a format tag. More... | |
QPictureIO (const QString &fileName, const char *format) | |
Constructs a QPictureIO object with the file name fileName and a format tag. More... | |
int | quality () const |
Returns the quality of the written picture, related to the compression ratio. More... | |
bool | read () |
Reads an picture into memory and returns true if the picture was successfully read; otherwise returns false. More... | |
void | setDescription (const QString &) |
Sets the picture description string for picture handlers that support picture descriptions to description. More... | |
void | setFileName (const QString &) |
Sets the name of the file to read or write an picture from to fileName. More... | |
void | setFormat (const char *) |
Sets the picture format to format for the picture to be read or written. More... | |
void | setGamma (float) |
Sets the gamma value at which the picture will be viewed to gamma. More... | |
void | setIODevice (QIODevice *) |
Sets the IO device to be used for reading or writing an picture. More... | |
void | setParameters (const char *) |
Sets the picture's parameter string to parameters. More... | |
void | setPicture (const QPicture &) |
Sets the picture to picture. More... | |
void | setQuality (int) |
Sets the quality of the written picture to q, related to the compression ratio. More... | |
void | setStatus (int) |
Sets the picture IO status to status. More... | |
int | status () const |
Returns the picture's IO status. More... | |
bool | write () |
Writes an picture to an IO device and returns true if the picture was successfully written; otherwise returns false. More... | |
~QPictureIO () | |
Destroys the object and all related data. More... | |
Static Public Functions | |
static void | defineIOHandler (const char *format, const char *header, const char *flags, picture_io_handler read_picture, picture_io_handler write_picture) |
Defines a picture I/O handler for the picture format called format, which is recognized using the regular expression defined in header, read using readPicture and written using writePicture. More... | |
static QList< QByteArray > | inputFormats () |
Returns a sorted list of picture formats that are supported for picture input. More... | |
static QList< QByteArray > | outputFormats () |
Returns a sorted list of picture formats that are supported for picture output. More... | |
static QByteArray | pictureFormat (const QString &fileName) |
Returns a string that specifies the picture format of the file fileName, or null if the file cannot be read or if the format is not recognized. More... | |
static QByteArray | pictureFormat (QIODevice *) |
Returns a string that specifies the picture format of the picture read from IO device d, or 0 if the device cannot be read or if the format is not recognized. More... | |
Private Functions | |
void | init () |
Contains initialization common to all QPictureIO constructors. More... | |
Properties | |
QPictureIOData * | d |
The QPictureIO class contains parameters for loading and saving pictures.
QPictureIO contains a QIODevice object that is used for picture data I/O. The programmer can install new picture file formats in addition to those that Qt provides.
You don't normally need to use this class; QPicture::load(), QPicture::save().
Definition at line 136 of file qpicture.h.
QPictureIO::QPictureIO | ( | ) |
Constructs a QPictureIO object with all parameters set to zero.
Definition at line 1401 of file qpicture.cpp.
QPictureIO::QPictureIO | ( | QIODevice * | ioDevice, |
const char * | format | ||
) |
Constructs a QPictureIO object with the I/O device ioDevice and a format tag.
Definition at line 1411 of file qpicture.cpp.
QPictureIO::QPictureIO | ( | const QString & | fileName, |
const char * | format | ||
) |
Constructs a QPictureIO object with the file name fileName and a format tag.
Definition at line 1423 of file qpicture.cpp.
QPictureIO::~QPictureIO | ( | ) |
|
static |
Defines a picture I/O handler for the picture format called format, which is recognized using the regular expression defined in header, read using readPicture and written using writePicture.
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 picture 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 QPicture; header is used to select a handler to read an picture file.
If readPicture is a null pointer, the QPictureIO will not be able to read pictures in format. If writePicture is a null pointer, the QPictureIO will not be able to write pictures in format. If both are null, the QPictureIO object is valid but useless.
Example:
Before the regular expression 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 if one handlerIO supports writing a format and another supports reading it, Qt supports both reading and writing. If two handlers support the same operation, Qt chooses one arbitrarily.)
Definition at line 1578 of file qpicture.cpp.
QString QPictureIO::description | ( | ) | const |
Returns the picture description string.
Definition at line 1638 of file qpicture.cpp.
QString QPictureIO::fileName | ( | ) | const |
Returns the file name currently set.
Definition at line 1630 of file qpicture.cpp.
const char * QPictureIO::format | ( | ) | const |
Returns the picture format string or 0 if no format has been explicitly set.
Definition at line 1616 of file qpicture.cpp.
float QPictureIO::gamma | ( | ) | const |
Returns the gamma value at which the picture will be viewed.
Definition at line 1783 of file qpicture.cpp.
|
private |
Contains initialization common to all QPictureIO constructors.
Definition at line 1434 of file qpicture.cpp.
|
static |
Returns a sorted list of picture formats that are supported for picture input.
Definition at line 1876 of file qpicture.cpp.
Referenced by QPicture::inputFormatList(), and QPicture::inputFormats().
QIODevice * QPictureIO::ioDevice | ( | ) | const |
Returns the IO device currently set.
Definition at line 1623 of file qpicture.cpp.
|
static |
Returns a sorted list of picture formats that are supported for picture output.
Definition at line 1899 of file qpicture.cpp.
Referenced by QPicture::outputFormatList(), and QPicture::outputFormats().
const char * QPictureIO::parameters | ( | ) | const |
Returns the picture's parameters string.
Definition at line 1739 of file qpicture.cpp.
const QPicture & QPictureIO::picture | ( | ) | const |
Returns the picture currently set.
Definition at line 1602 of file qpicture.cpp.
Referenced by QPicture::load(), and QPicture::save().
|
static |
Returns a string that specifies the picture format of the file fileName, or null if the file cannot be read or if the format is not recognized.
Definition at line 1808 of file qpicture.cpp.
Referenced by QPicture::pictureFormat().
|
static |
Returns a string that specifies the picture format of the picture read from IO device d, or 0 if the device cannot be read or if the format is not recognized.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Make sure that d is at the right position in the device (for example, at the beginning of the file).
Definition at line 1835 of file qpicture.cpp.
int QPictureIO::quality | ( | ) | const |
Returns the quality of the written picture, related to the compression ratio.
Definition at line 1712 of file qpicture.cpp.
bool QPictureIO::read | ( | ) |
Reads an picture into memory and returns true if the picture was successfully read; otherwise returns false.
Before reading an picture 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 picture file format string is optional.
Note that this function does not set the format used to read the picture. If you need that information, use the pictureFormat() static functions.
Example:
Definition at line 1937 of file qpicture.cpp.
Referenced by QPicture::load().
void QPictureIO::setDescription | ( | const QString & | description | ) |
Sets the picture description string for picture handlers that support picture descriptions to description.
Currently, no picture format supported by Qt uses the description string.
Definition at line 1796 of file qpicture.cpp.
void QPictureIO::setFileName | ( | const QString & | fileName | ) |
Sets the name of the file to read or write an picture from to fileName.
Definition at line 1701 of file qpicture.cpp.
void QPictureIO::setFormat | ( | const char * | format | ) |
Sets the picture format to format for the picture to be read or written.
It is necessary to specify a format before writing an picture, but it is not necessary to specify a format before reading an picture.
If no format has been set, Qt guesses the picture format before reading it. If a format is set the picture will only be read if it has that format.
Definition at line 1674 of file qpicture.cpp.
void QPictureIO::setGamma | ( | float | gamma | ) |
Sets the gamma value at which the picture will be viewed to gamma.
If the picture format stores a gamma value for which the picture is intended to be used, then this setting will be used to modify the picture. Setting to 0.0 will disable gamma correction (i.e. any specification in the file will be ignored).
The default value is 0.0.
Definition at line 1773 of file qpicture.cpp.
void QPictureIO::setIODevice | ( | QIODevice * | ioDevice | ) |
Sets the IO device to be used for reading or writing an picture.
Setting the IO device allows pictures to be read/written to any block-oriented QIODevice.
If ioDevice is not null, this IO device will override file name settings.
Definition at line 1690 of file qpicture.cpp.
void QPictureIO::setParameters | ( | const char * | parameters | ) |
Sets the picture's parameter string to parameters.
This is for picture handlers that require special parameters.
Although the current picture formats supported by Qt ignore the parameters string, it may be used in future extensions or by contributions (for example, JPEG).
Definition at line 1755 of file qpicture.cpp.
void QPictureIO::setPicture | ( | const QPicture & | picture | ) |
Sets the picture to picture.
Definition at line 1645 of file qpicture.cpp.
void QPictureIO::setQuality | ( | int | q | ) |
Sets the quality of the written picture 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.)
Definition at line 1728 of file qpicture.cpp.
void QPictureIO::setStatus | ( | int | status | ) |
Sets the picture IO status to status.
A non-zero value indicates an error, whereas 0 means that the IO operation was successful.
Definition at line 1656 of file qpicture.cpp.
int QPictureIO::status | ( | ) | const |
Returns the picture's IO status.
A non-zero value indicates an error, whereas 0 means that the IO operation was successful.
Definition at line 1610 of file qpicture.cpp.
bool QPictureIO::write | ( | ) |
Writes an picture to an IO device and returns true if the picture was successfully written; otherwise returns false.
Before writing an picture 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 picture will be written using the specified picture format.
Example:
Definition at line 2006 of file qpicture.cpp.
Referenced by QPicture::save().
|
private |
Definition at line 183 of file qpicture.h.