Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QPictureIO Class

TheQPictureIO class contains parameters for loading and saving pictures.More...

Header:#include <QPictureIO>

This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Public Functions

QPictureIO()
QPictureIO(QIODevice * ioDevice, const char * format)
QPictureIO(const QString & fileName, const char * format)
~QPictureIO()
QStringdescription() const
QStringfileName() const
const char *format() const
floatgamma() const
QIODevice *ioDevice() const
const char *parameters() const
const QPicture &picture() const
intquality() const
boolread()
voidsetDescription(const QString & description)
voidsetFileName(const QString & fileName)
voidsetFormat(const char * format)
voidsetGamma(float gamma)
voidsetIODevice(QIODevice * ioDevice)
voidsetParameters(const char * parameters)
voidsetPicture(const QPicture & picture)
voidsetQuality(int q)
voidsetStatus(int status)
intstatus() const
boolwrite()

Static Public Members

voiddefineIOHandler(const char * format, const char * header, const char * flags, picture_io_handler readPicture, picture_io_handler writePicture)
QList<QByteArray>inputFormats()
QList<QByteArray>outputFormats()
QByteArraypictureFormat(const QString & fileName)
QByteArraypictureFormat(QIODevice * d)

Detailed Description

TheQPictureIO class contains parameters for loading and saving pictures.

QPictureIO contains aQIODevice 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().

See alsoQPicture,QPixmap, andQFile.

Member Function Documentation

QPictureIO::QPictureIO()

Constructs aQPictureIO object with all parameters set to zero.

QPictureIO::QPictureIO(QIODevice * ioDevice, constchar * format)

Constructs aQPictureIO object with the I/O deviceioDevice and aformat tag.

QPictureIO::QPictureIO(constQString & fileName, constchar * format)

Constructs aQPictureIO object with the file namefileName and aformat tag.

QPictureIO::~QPictureIO()

Destroys the object and all related data.

[static]void QPictureIO::defineIOHandler(constchar * format, constchar * header, constchar * flags,picture_io_handler readPicture,picture_io_handler writePicture)

Defines a picture I/O handler for the picture format calledformat, which is recognized using the regular expression defined inheader, read usingreadPicture and written usingwritePicture.

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 forflags 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 aQPicture;header is used to select a handler to read an picture file.

IfreadPicture is a null pointer, theQPictureIO will not be able to read pictures informat. IfwritePicture is a null pointer, theQPictureIO will not be able to write pictures informat. If both are null, theQPictureIO object is valid but useless.

Example:

void readSVG(QPictureIO*picture){// read the picture using the picture->ioDevice()}void writeSVG(QPictureIO*picture){// write the picture using the picture->ioDevice()}// add the SVG picture handler// ...

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.)

QString QPictureIO::description() const

Returns the picture description string.

See alsosetDescription().

QString QPictureIO::fileName() const

Returns the file name currently set.

See alsosetFileName().

constchar * QPictureIO::format() const

Returns the picture format string or 0 if no format has been explicitly set.

See alsosetFormat().

float QPictureIO::gamma() const

Returns the gamma value at which the picture will be viewed.

See alsosetGamma().

[static]QList<QByteArray> QPictureIO::inputFormats()

Returns a sorted list of picture formats that are supported for picture input.

QIODevice * QPictureIO::ioDevice() const

Returns the IO device currently set.

See alsosetIODevice().

[static]QList<QByteArray> QPictureIO::outputFormats()

Returns a sorted list of picture formats that are supported for picture output.

constchar * QPictureIO::parameters() const

Returns the picture's parameters string.

See alsosetParameters().

constQPicture & QPictureIO::picture() const

Returns the picture currently set.

See alsosetPicture().

[static]QByteArray QPictureIO::pictureFormat(constQString & fileName)

Returns a string that specifies the picture format of the filefileName, or null if the file cannot be read or if the format is not recognized.

[static]QByteArray QPictureIO::pictureFormat(QIODevice * d)

This is an overloaded function.

Returns a string that specifies the picture format of the picture read from IO deviced, or 0 if the device cannot be read or if the format is not recognized.

Make sure thatd is at the right position in the device (for example, at the beginning of the file).

See alsoQIODevice::at().

int QPictureIO::quality() const

Returns the quality of the written picture, related to the compression ratio.

See alsosetQuality() andQPicture::save().

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 doesnot set theformat used to read the picture. If you need that information, use thepictureFormat() static functions.

Example:

QPictureIO iio;QPixmap  pixmap;        iio.setFileName("vegeburger.pic");if (iio.read()) {// OKQPicture picture= iio.picture();QPainter painter(&pixmap);            painter.drawPicture(0,0, picture);        }

See alsosetIODevice(),setFileName(),setFormat(),write(), andQPixmap::load().

void QPictureIO::setDescription(constQString & description)

Sets the picture description string for picture handlers that support picture descriptions todescription.

Currently, no picture format supported by Qt uses the description string.

See alsodescription().

void QPictureIO::setFileName(constQString & fileName)

Sets the name of the file to read or write an picture from tofileName.

See alsofileName() andsetIODevice().

void QPictureIO::setFormat(constchar * format)

Sets the picture format toformat 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.

See alsoread(),write(), andformat().

void QPictureIO::setGamma(float gamma)

Sets the gamma value at which the picture will be viewed togamma. 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.

See alsogamma().

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-orientedQIODevice.

IfioDevice is not null, this IO device will override file name settings.

See alsosetFileName().

void QPictureIO::setParameters(constchar * parameters)

Sets the picture's parameter string toparameters. 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).

See alsoparameters().

void QPictureIO::setPicture(constQPicture & picture)

Sets the picture topicture.

See alsopicture().

void QPictureIO::setQuality(int q)

Sets the quality of the written picture toq, 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.)

See alsoquality() andQPicture::save().

void QPictureIO::setStatus(int status)

Sets the picture IO status tostatus. A non-zero value indicates an error, whereas 0 means that the IO operation was successful.

See alsostatus().

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.

See alsosetStatus().

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:

QPictureIO iio;QPicture   picture;QPainter painter(&picture);        painter.drawPixmap(0,0, pixmap);        iio.setPicture(picture);        iio.setFileName("vegeburger.pic");        iio.setFormat("PIC");if (iio.write())returntrue;// returned true if written successfully

See alsosetIODevice(),setFileName(),setFormat(),read(), andQPixmap::save().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp