![]() |
Qt 6.x
The Qt SDK
|
The QImageReader class provides a format independent interface for reading images from files or other devices. More...
#include <qimagereader.h>
Public Types | |
enum | ImageReaderError { UnknownError , FileNotFoundError , DeviceError , UnsupportedFormatError , InvalidDataError } |
This enum describes the different types of errors that can occur when reading images with QImageReader. More... | |
Public Member Functions | |
QImageReader () | |
Constructs an empty QImageReader object. | |
QImageReader (QIODevice *device, const QByteArray &format=QByteArray()) | |
Constructs a QImageReader object with the device device and the image format format. | |
QImageReader (const QString &fileName, const QByteArray &format=QByteArray()) | |
Constructs a QImageReader object with the file name fileName and the image format format. | |
~QImageReader () | |
Destructs the QImageReader object. | |
void | setFormat (const QByteArray &format) |
Sets the format QImageReader will use when reading images, to format. | |
QByteArray | format () const |
Returns the format QImageReader uses for reading images. | |
void | setAutoDetectImageFormat (bool enabled) |
If enabled is true, image format autodetection is enabled; otherwise, it is disabled. | |
bool | autoDetectImageFormat () const |
Returns true if image format autodetection is enabled on this image reader; otherwise returns false . | |
void | setDecideFormatFromContent (bool ignored) |
If ignored is set to true, then the image reader will ignore specified formats or file extensions and decide which plugin to use only based on the contents in the datastream. | |
bool | decideFormatFromContent () const |
Returns whether the image reader should decide which plugin to use only based on the contents of the datastream rather than on the file extension. | |
void | setDevice (QIODevice *device) |
Sets QImageReader's device to device. | |
QIODevice * | device () const |
Returns the device currently assigned to QImageReader, or \nullptr if no device has been assigned. | |
void | setFileName (const QString &fileName) |
Sets the file name of QImageReader to fileName. | |
QString | fileName () const |
If the currently assigned device is a QFile, or if setFileName() has been called, this function returns the name of the file QImageReader reads from. | |
QSize | size () const |
Returns the size of the image, without actually reading the image contents. | |
QImage::Format | imageFormat () const |
QStringList | textKeys () const |
QString | text (const QString &key) const |
void | setClipRect (const QRect &rect) |
Sets the image clip rect (also known as the ROI, or Region Of Interest) to rect. | |
QRect | clipRect () const |
Returns the clip rect (also known as the ROI, or Region Of Interest) of the image. | |
void | setScaledSize (const QSize &size) |
Sets the scaled size of the image to size. | |
QSize | scaledSize () const |
Returns the scaled size of the image. | |
void | setQuality (int quality) |
int | quality () const |
void | setScaledClipRect (const QRect &rect) |
Sets the scaled clip rect to rect. | |
QRect | scaledClipRect () const |
Returns the scaled clip rect of the image. | |
void | setBackgroundColor (const QColor &color) |
QColor | backgroundColor () const |
bool | supportsAnimation () const |
QImageIOHandler::Transformations | transformation () const |
void | setAutoTransform (bool enabled) |
bool | autoTransform () const |
QByteArray | subType () const |
QList< QByteArray > | supportedSubTypes () const |
bool | canRead () const |
Returns true if an image can be read for the device (i.e., the image format is supported, and the device seems to contain valid data); otherwise returns false . | |
QImage | read () |
Reads an image from the device. | |
bool | read (QImage *image) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Reads an image from the device into image, which must point to a QImage. | |
bool | jumpToNextImage () |
For image formats that support animation, this function steps over the current image, returning true if successful or false if there is no following image in the animation. | |
bool | jumpToImage (int imageNumber) |
For image formats that support animation, this function skips to the image whose sequence number is imageNumber, returning true if successful or false if the corresponding image cannot be found. | |
int | loopCount () const |
For image formats that support animation, this function returns the number of times the animation should loop. | |
int | imageCount () const |
For image formats that support animation, this function returns the total number of images in the animation. | |
int | nextImageDelay () const |
For image formats that support animation, this function returns the number of milliseconds to wait until displaying the next frame in the animation. | |
int | currentImageNumber () const |
For image formats that support animation, this function returns the sequence number of the current frame. | |
QRect | currentImageRect () const |
For image formats that support animation, this function returns the rect for the current frame. | |
ImageReaderError | error () const |
Returns the type of error that occurred last. | |
QString | errorString () const |
Returns a human readable description of the last error that occurred. | |
bool | supportsOption (QImageIOHandler::ImageOption option) const |
Static Public Member Functions | |
static QByteArray | imageFormat (const QString &fileName) |
If supported, this function returns the image format of the file fileName. | |
static QByteArray | imageFormat (QIODevice *device) |
If supported, this function returns the image format of the device device. | |
static QList< QByteArray > | supportedImageFormats () |
Returns the list of image formats supported by QImageReader. | |
static QList< QByteArray > | supportedMimeTypes () |
Returns the list of MIME types supported by QImageReader. | |
static QList< QByteArray > | imageFormatsForMimeType (const QByteArray &mimeType) |
static int | allocationLimit () |
static void | setAllocationLimit (int mbLimit) |
The QImageReader class provides a format independent interface for reading images from files or other devices.
\inmodule QtGui \reentrant
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.
Definition at line 22 of file qimagereader.h.
This enum describes the different types of errors that can occur when reading images with QImageReader.
\value FileNotFoundError QImageReader was used with a file name, but not file was found with that name. This can also happen if the file name contained no extension, and the file with the correct extension is not supported by Qt.
\value DeviceError QImageReader encountered a device error when reading the image. You can consult your particular device for more details on what went wrong.
\value UnsupportedFormatError Qt does not support the requested image format.
\value InvalidDataError The image data was invalid, and QImageReader was unable to read an image from it. The can happen if the image file is damaged.
\value UnknownError An unknown error occurred. If you get this value after calling read(), it is most likely caused by a bug in QImageReader.
Enumerator | |
---|---|
UnknownError | |
FileNotFoundError | |
DeviceError | |
UnsupportedFormatError | |
InvalidDataError |
Definition at line 26 of file qimagereader.h.
QImageReader::QImageReader | ( | ) |
Constructs an empty QImageReader object.
Before reading an image, call setDevice() or setFileName().
Definition at line 569 of file qimagereader.cpp.
|
explicit |
Constructs a QImageReader object with the device device and the image format format.
Definition at line 578 of file qimagereader.cpp.
References QImageReaderPrivate::device, device(), QImageReaderPrivate::format, and format().
|
explicit |
Constructs a QImageReader object with the file name fileName and the image format format.
Definition at line 591 of file qimagereader.cpp.
References QImageReaderPrivate::deleteDevice.
QImageReader::~QImageReader | ( | ) |
Destructs the QImageReader object.
Definition at line 600 of file qimagereader.cpp.
|
static |
Returns the current allocation limit, in megabytes.
Definition at line 1553 of file qimagereader.cpp.
References QImageReaderPrivate::maxAlloc, ok, and qEnvironmentVariableIntValue().
Referenced by Jpeg2000JasperReader::Jpeg2000JasperReader(), and QImageIOHandler::allocateImage().
bool QImageReader::autoDetectImageFormat | ( | ) | const |
Returns true
if image format autodetection is enabled on this image reader; otherwise returns false
.
By default, autodetection is enabled.
Definition at line 696 of file qimagereader.cpp.
References QImageReaderPrivate::autoDetectImageFormat.
bool QImageReader::autoTransform | ( | ) | const |
Returns true
if the image handler will apply transformation metadata on read().
Definition at line 1107 of file qimagereader.cpp.
References QImageReaderPrivate::ApplyTransform, QImageReaderPrivate::autoTransform, QImageReaderPrivate::DoNotApplyTransform, Q_FALLTHROUGH, and QImageReaderPrivate::UsePluginDefault.
Referenced by read(), and readImage().
QColor QImageReader::backgroundColor | ( | ) | const |
Returns the background color that's used when reading an image. If the image format does not support setting the background color an invalid color is returned.
Definition at line 1014 of file qimagereader.cpp.
References QImageIOHandler::BackgroundColor, QImageReaderPrivate::handler, QImageReaderPrivate::initHandler(), QImageIOHandler::option(), and QImageIOHandler::supportsOption().
Referenced by QMoviePrivate::infoForFrame().
bool QImageReader::canRead | ( | ) | const |
Returns true
if an image can be read for the device (i.e., the image format is supported, and the device seems to contain valid data); otherwise returns false
.
canRead() is a lightweight function that only does a quick test to see if the image data is valid. read() may still return false after canRead() returns true
, if the image data is corrupt.
For images that support animation, canRead() returns false
when all frames have been read.
Definition at line 1139 of file qimagereader.cpp.
References QImageIOHandler::canRead(), QImageReaderPrivate::handler, and QImageReaderPrivate::initHandler().
Referenced by QMoviePrivate::infoForFrame(), QMoviePrivate::isValid(), QSSGLoadedTexture::loadCompressedImage(), and readDib().
QRect QImageReader::clipRect | ( | ) | const |
Returns the clip rect (also known as the ROI, or Region Of Interest) of the image.
If no clip rect has been set, an invalid QRect is returned.
Definition at line 936 of file qimagereader.cpp.
References QImageReaderPrivate::clipRect.
int QImageReader::currentImageNumber | ( | ) | const |
For image formats that support animation, this function returns the sequence number of the current frame.
If the image format doesn't support animation, 0 is returned.
This function returns -1 if an error occurred.
Definition at line 1385 of file qimagereader.cpp.
References QImageIOHandler::currentImageNumber(), QImageReaderPrivate::handler, and QImageReaderPrivate::initHandler().
QRect QImageReader::currentImageRect | ( | ) | const |
For image formats that support animation, this function returns the rect for the current frame.
Otherwise, a null rect is returned.
Definition at line 1398 of file qimagereader.cpp.
References QImageIOHandler::currentImageRect(), QImageReaderPrivate::handler, and QImageReaderPrivate::initHandler().
bool QImageReader::decideFormatFromContent | ( | ) | const |
Returns whether the image reader should decide which plugin to use only based on the contents of the datastream rather than on the file extension.
Definition at line 730 of file qimagereader.cpp.
References QImageReaderPrivate::ignoresFormatAndExtension.
QIODevice * QImageReader::device | ( | ) | const |
Returns the device currently assigned to QImageReader, or \nullptr if no device has been assigned.
Definition at line 764 of file qimagereader.cpp.
References QImageReaderPrivate::device.
Referenced by QImageReader(), imageFormat(), QMoviePrivate::infoForFrame(), QMoviePrivate::reset(), and setDevice().
QImageReader::ImageReaderError QImageReader::error | ( | ) | const |
Returns the type of error that occurred last.
Definition at line 1410 of file qimagereader.cpp.
References QImageReaderPrivate::imageReaderError.
Referenced by QMoviePrivate::_q_loadNextFrame(), QMoviePrivate::infoForFrame(), and QMoviePrivate::isValid().
QString QImageReader::errorString | ( | ) | const |
Returns a human readable description of the last error that occurred.
Definition at line 1421 of file qimagereader.cpp.
References QImageReaderPrivate::errorString, and QString::isEmpty().
Referenced by QMimeTypeParserBase::parse(), readAndroidDependencyXml(), readImage(), SharedTextureImageResponse::textureFactory(), and updateAndroidManifest().
QString QImageReader::fileName | ( | ) | const |
If the currently assigned device is a QFile, or if setFileName() has been called, this function returns the name of the file QImageReader reads from.
Otherwise (i.e., if no device has been assigned or the device is not a QFile), an empty QString is returned.
Definition at line 795 of file qimagereader.cpp.
References QImageReaderPrivate::device, file, and QFile::fileName().
Referenced by imageFormat(), QMoviePrivate::infoForFrame(), read(), setFileName(), and SharedTextureImageResponse::textureFactory().
QByteArray QImageReader::format | ( | ) | const |
Returns the format QImageReader uses for reading images.
You can call this function after assigning a device to the reader to determine the format of the device. For example:
If the reader cannot read any image from the device (e.g., there is no image there, or the image has already been read), or if the format is unsupported, this function returns an empty QByteArray().
Definition at line 635 of file qimagereader.cpp.
References QImageIOHandler::canRead(), QImageIOHandler::format(), QImageReaderPrivate::format, QImageReaderPrivate::handler, QImageReaderPrivate::initHandler(), and QByteArray::isEmpty().
Referenced by QImageReader(), imageFormat(), QMoviePrivate::infoForFrame(), QuickSharedImageLoader::loadFile(), probeImageData(), readImage(), and setFormat().
int QImageReader::imageCount | ( | ) | const |
For image formats that support animation, this function returns the total number of images in the animation.
If the format does not support animation, 0 is returned.
This function returns -1 if an error occurred.
Definition at line 1353 of file qimagereader.cpp.
References QImageReaderPrivate::handler, QImageIOHandler::imageCount(), and QImageReaderPrivate::initHandler().
Referenced by QMoviePrivate::frameCount(), and readImage().
QImage::Format QImageReader::imageFormat | ( | ) | const |
Returns the format of the image, without actually reading the image contents. The format describes the image format \l QImageReader::read() returns, not the format of the actual image.
If the image format does not support this feature, this function returns an invalid format.
Definition at line 872 of file qimagereader.cpp.
References QImage::Format_Invalid, QImageReaderPrivate::handler, QImageIOHandler::ImageFormat, QImageReaderPrivate::initHandler(), QImageIOHandler::option(), QImageIOHandler::supportsOption(), and QVariant::toInt().
Referenced by imageFormat().
|
static |
If supported, this function returns the image format of the file fileName.
Otherwise, an empty string is returned.
Definition at line 1455 of file qimagereader.cpp.
References file, fileName(), imageFormat(), QFile::open(), and QIODeviceBase::ReadOnly.
|
static |
If supported, this function returns the image format of the device device.
Otherwise, an empty string is returned.
Definition at line 1470 of file qimagereader.cpp.
References QImageIOHandler::canRead(), createReadHandlerHelper(), device(), QImageIOHandler::format(), and format().
|
static |
Returns the list of image formats corresponding to mimeType.
Note that the QGuiApplication instance must be created before this function is called.
Definition at line 1540 of file qimagereader.cpp.
References QImageReaderWriterHelpers::CanRead, QImageReaderWriterHelpers::imageFormatsForMimeType(), and mimeType.
bool QImageReader::jumpToImage | ( | int | imageNumber | ) |
For image formats that support animation, this function skips to the image whose sequence number is imageNumber, returning true if successful or false if the corresponding image cannot be found.
The next call to read() will attempt to read this image.
Definition at line 1322 of file qimagereader.cpp.
References QImageReaderPrivate::handler, QImageReaderPrivate::initHandler(), and QImageIOHandler::jumpToImage().
Referenced by QMoviePrivate::infoForFrame(), and readImage().
bool QImageReader::jumpToNextImage | ( | ) |
For image formats that support animation, this function steps over the current image, returning true if successful or false if there is no following image in the animation.
The default implementation calls read(), then discards the resulting image, but the image handler may have a more efficient way of implementing this operation.
Definition at line 1306 of file qimagereader.cpp.
References QImageReaderPrivate::handler, QImageReaderPrivate::initHandler(), and QImageIOHandler::jumpToNextImage().
int QImageReader::loopCount | ( | ) | const |
For image formats that support animation, this function returns the number of times the animation should loop.
If this function returns -1, it can either mean the animation should loop forever, or that an error occurred. If an error occurred, canRead() will return false.
Definition at line 1337 of file qimagereader.cpp.
References QImageReaderPrivate::handler, QImageReaderPrivate::initHandler(), and QImageIOHandler::loopCount().
Referenced by QMoviePrivate::next().
int QImageReader::nextImageDelay | ( | ) | const |
For image formats that support animation, this function returns the number of milliseconds to wait until displaying the next frame in the animation.
If the image format doesn't support animation, 0 is returned.
This function returns -1 if an error occurred.
Definition at line 1369 of file qimagereader.cpp.
References QImageReaderPrivate::handler, QImageReaderPrivate::initHandler(), and QImageIOHandler::nextImageDelay().
Referenced by QMoviePrivate::infoForFrame().
int QImageReader::quality | ( | ) | const |
Returns the quality setting of the image format.
Definition at line 833 of file qimagereader.cpp.
References QImageReaderPrivate::quality.
Referenced by setQuality().
QImage QImageReader::read | ( | ) |
Reads an image from the device.
On success, the image that was read is returned; otherwise, a null QImage is returned. You can then call error() to find the type of error that occurred, or errorString() to get a human readable description of the error.
For image formats that support animation, calling read() repeatedly will return the next frame. When all frames have been read, a null image will be returned.
Definition at line 1159 of file qimagereader.cpp.
References read().
Referenced by QPlatformPixmap::fromData(), QRasterPlatformPixmap::fromData(), QImage::fromData(), QPlatformPixmap::fromFile(), QMoviePrivate::infoForFrame(), QImage::load(), QImage::load(), QSSGLoadedTexture::loadCompressedImage(), QuickSharedImageLoader::loadFile(), probeImageData(), read(), QJp2Handler::read(), readDib(), readImage(), SharedTextureImageResponse::textureFactory(), and src_gui_image_qimagereader::wrapper1().
bool QImageReader::read | ( | QImage * | image | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Reads an image from the device into image, which must point to a QImage.
Returns true
on success; otherwise, returns false
.
If image has same format and size as the image data that is about to be read, this function may not need to allocate a new image before reading. Because of this, it can be faster than the other read() overload, which always constructs a new image; especially when reading several images with the same format and size.
For image formats that support animation, calling read() repeatedly will return the next frame. When all frames have been read, a null image will be returned.
Definition at line 1189 of file qimagereader.cpp.
References autoTransform(), QFileInfo::baseName(), QImageIOHandler::ClipRect, QImageReaderPrivate::clipRect, QImageReaderPrivate::errorString, fileName(), QImageReaderPrivate::handler, Qt::IgnoreAspectRatio, QImageReaderPrivate::imageReaderError, QImageReaderPrivate::initHandler(), InvalidDataError, QString::isEmpty(), QRect::isNull(), QRect::isValid(), QSize::isValid(), Q_TRACE, Q_TRACE_ENABLED, qEnvironmentVariableIsEmpty(), qt_imageTransform(), QImageIOHandler::Quality, QImageReaderPrivate::quality, qWarning, QImageIOHandler::read(), QString::right(), QImageIOHandler::ScaledClipRect, QImageReaderPrivate::scaledClipRect, QImageIOHandler::ScaledSize, QImageReaderPrivate::scaledSize, QImageIOHandler::setOption(), QByteArray::size(), Qt::SmoothTransformation, QImageIOHandler::supportsOption(), QString::toLatin1(), and transformation().
QRect QImageReader::scaledClipRect | ( | ) | const |
Returns the scaled clip rect of the image.
Definition at line 983 of file qimagereader.cpp.
References QImageReaderPrivate::scaledClipRect.
QSize QImageReader::scaledSize | ( | ) | const |
Returns the scaled size of the image.
Definition at line 961 of file qimagereader.cpp.
References QImageReaderPrivate::scaledSize.
Referenced by QMoviePrivate::infoForFrame(), and QMoviePrivate::next().
|
static |
Sets the allocation limit to mbLimit megabytes. Images that would require a QImage memory allocation above this limit will be rejected. If mbLimit is 0, the allocation size check will be disabled.
This limit helps applications avoid unexpectedly large memory usage from loading corrupt image files. It is normally not needed to change it. The default limit is large enough for all commonly used image sizes.
At runtime, this value may be overridden by the environment variable QT_IMAGEIO_MAXALLOC
.
Definition at line 1583 of file qimagereader.cpp.
References QImageReaderPrivate::maxAlloc.
void QImageReader::setAutoDetectImageFormat | ( | bool | enabled | ) |
If enabled is true, image format autodetection is enabled; otherwise, it is disabled.
By default, autodetection is enabled.
QImageReader uses an extensive approach to detecting the image format; firstly, if you pass a file name to QImageReader, it will attempt to detect the file extension if the given file name does not point to an existing file, by appending supported default extensions to the given file name, one at a time. It then uses the following approach to detect the image format:
\list
\endlist
By disabling image format autodetection, QImageReader will only query the plugins and built-in handlers based on the format string (i.e., no file name extensions are tested).
Definition at line 685 of file qimagereader.cpp.
References QImageReaderPrivate::autoDetectImageFormat, and enabled.
void QImageReader::setAutoTransform | ( | bool | enabled | ) |
Determines that images returned by read() should have transformation metadata automatically applied if enabled is true
.
Definition at line 1094 of file qimagereader.cpp.
References QImageReaderPrivate::ApplyTransform, QImageReaderPrivate::autoTransform, and QImageReaderPrivate::DoNotApplyTransform.
Referenced by readImage().
Sets the background color to color. Image formats that support this operation are expected to initialize the background to color before reading an image.
Definition at line 997 of file qimagereader.cpp.
References QImageIOHandler::BackgroundColor, QImageReaderPrivate::handler, QImageReaderPrivate::initHandler(), QImageIOHandler::setOption(), and QImageIOHandler::supportsOption().
Referenced by QMoviePrivate::infoForFrame().
Sets the image clip rect (also known as the ROI, or Region Of Interest) to rect.
The coordinates of rect are relative to the untransformed image size, as returned by size().
Definition at line 924 of file qimagereader.cpp.
References QImageReaderPrivate::clipRect, and rect.
void QImageReader::setDecideFormatFromContent | ( | bool | ignored | ) |
If ignored is set to true, then the image reader will ignore specified formats or file extensions and decide which plugin to use only based on the contents in the datastream.
Setting this flag means that all image plugins gets loaded. Each plugin will read the first bytes in the image data and decide if the plugin is compatible or not.
This also disables auto detecting the image format.
Definition at line 716 of file qimagereader.cpp.
References QImageReaderPrivate::ignoresFormatAndExtension.
Sets QImageReader's device to device.
If a device has already been set, the old device is removed from QImageReader and is otherwise left unchanged.
If the device is not already open, QImageReader will attempt to open the device in \l {QIODeviceBase::}{ReadOnly} mode by calling open(). Note that this does not work for certain devices, such as QProcess, QTcpSocket and QUdpSocket, where more logic is required to open the device.
Definition at line 749 of file qimagereader.cpp.
References QMap< Key, T >::clear(), QImageReaderPrivate::deleteDevice, QImageReaderPrivate::device, device(), QImageReaderPrivate::handler, and QImageReaderPrivate::text.
Referenced by Uic::printDependencies(), setFileName(), and Uic::write().
Sets the file name of QImageReader to fileName.
Internally, QImageReader will create a QFile object and open it in \l {QIODeviceBase::}{ReadOnly} mode, and use this when reading images.
If fileName does not include a file extension (e.g., .png or .bmp), QImageReader will cycle through all supported extensions until it finds a matching file.
Definition at line 780 of file qimagereader.cpp.
References QImageReaderPrivate::deleteDevice, fileName(), and setDevice().
void QImageReader::setFormat | ( | const QByteArray & | format | ) |
Sets the format QImageReader will use when reading images, to format.
format is a case insensitive text string. Example:
You can call supportedImageFormats() for the full list of formats QImageReader supports.
Definition at line 616 of file qimagereader.cpp.
References QImageReaderPrivate::format, and format().
Referenced by src_gui_image_qimagereader::wrapper0().
void QImageReader::setQuality | ( | int | quality | ) |
Sets the quality setting of the image format to quality.
Some image formats, in particular lossy ones, entail a tradeoff between a) visual quality of the resulting image, and b) decoding execution time. This function sets the level of that tradeoff for image formats that support it.
In case of scaled image reading, the quality setting may also influence the tradeoff level between visual quality and execution speed of the scaling algorithm.
The value range of quality depends on the image format. For example, the "jpeg" format supports a quality range from 0 (low visual quality) to 100 (high visual quality).
Definition at line 821 of file qimagereader.cpp.
References QImageReaderPrivate::quality, and quality().
Sets the scaled clip rect to rect.
The scaled clip rect is the clip rect (also known as ROI, or Region Of Interest) that is applied after the image has been scaled.
Definition at line 973 of file qimagereader.cpp.
References rect, and QImageReaderPrivate::scaledClipRect.
Referenced by readImage().
Sets the scaled size of the image to size.
The scaling is performed after the initial clip rect, but before the scaled clip rect is applied. The algorithm used for scaling depends on the image format. By default (i.e., if the image format does not support scaling), QImageReader will use QImage::scale() with Qt::SmoothScaling.
Definition at line 951 of file qimagereader.cpp.
References QImageReaderPrivate::scaledSize, and size().
Referenced by QMoviePrivate::infoForFrame(), QuickSharedImageLoader::loadFile(), and readImage().
QSize QImageReader::size | ( | ) | const |
Returns the size of the image, without actually reading the image contents.
If the image format does not support this feature, this function returns an invalid size. Qt's built-in image handlers all support this feature, but custom image format plugins are not required to do so.
Definition at line 849 of file qimagereader.cpp.
References QImageReaderPrivate::handler, QImageReaderPrivate::initHandler(), QImageIOHandler::option(), QImageIOHandler::Size, QImageIOHandler::supportsOption(), and QVariant::toSize().
Referenced by AVFImageCapture::doCapture(), QuickSharedImageLoader::loadFile(), probeImageData(), readImage(), setScaledSize(), and src_gui_image_qimagereader::wrapper2().
QByteArray QImageReader::subType | ( | ) | const |
Returns the subtype of the image.
Definition at line 1045 of file qimagereader.cpp.
References QImageReaderPrivate::handler, QImageReaderPrivate::initHandler(), QImageIOHandler::option(), QImageIOHandler::SubType, QImageIOHandler::supportsOption(), and QVariant::toByteArray().
|
static |
Returns the list of image formats supported by QImageReader.
By default, Qt can read the following formats:
\table \header
Reading and writing SVG files is supported through the \l{Qt SVG} module. The \l{Qt Image Formats} module provides support for additional image formats.
Note that the QApplication instance must be created before this function is called.
Definition at line 1510 of file qimagereader.cpp.
References QImageReaderWriterHelpers::CanRead, and QImageReaderWriterHelpers::supportedImageFormats().
Referenced by BackendSupport::BackendSupport(), QSSGInputUtil::getStreamForTextureFile(), imageReadMimeFormats(), QImageReaderPrivate::initHandler(), QWaylandTextureSharingExtension::initialize(), msgConversionError(), and QMovie::supportedFormats().
|
static |
Returns the list of MIME types supported by QImageReader.
Note that the QApplication instance must be created before this function is called.
Definition at line 1524 of file qimagereader.cpp.
References QImageReaderWriterHelpers::CanRead, and QImageReaderWriterHelpers::supportedMimeTypes().
QList< QByteArray > QImageReader::supportedSubTypes | ( | ) | const |
Returns the list of subtypes supported by an image.
Definition at line 1060 of file qimagereader.cpp.
References QImageReaderPrivate::handler, QImageReaderPrivate::initHandler(), QImageIOHandler::option(), QImageIOHandler::SupportedSubTypes, and QImageIOHandler::supportsOption().
bool QImageReader::supportsAnimation | ( | ) | const |
Returns true
if the image format supports animation; otherwise, false is returned.
Definition at line 1031 of file qimagereader.cpp.
References QImageIOHandler::Animation, QImageReaderPrivate::handler, QImageReaderPrivate::initHandler(), QImageIOHandler::option(), QImageIOHandler::supportsOption(), and QVariant::toBool().
bool QImageReader::supportsOption | ( | QImageIOHandler::ImageOption | option | ) | const |
Returns true
if the reader supports option; otherwise returns false.
Different image formats support different options. Call this function to determine whether a certain option is supported by the current format. For example, the PNG format allows you to embed text into the image's metadata (see text()), and the BMP format allows you to determine the image's size without loading the whole image into memory (see size()).
Definition at line 1444 of file qimagereader.cpp.
References QImageReaderPrivate::handler, QImageReaderPrivate::initHandler(), and QImageIOHandler::supportsOption().
Referenced by QMovie::supportedFormats(), and src_gui_image_qimagereader::wrapper2().
Returns the image text associated with key.
Support for this option is implemented through QImageIOHandler::Description.
Definition at line 911 of file qimagereader.cpp.
References QImageReaderPrivate::getText(), QImageReaderPrivate::text, and QMap< Key, T >::value().
Referenced by QV4::Document::load(), qRelocateResourceFile(), DomInclude::read(), DomHeader::read(), DomResourcePixmap::read(), DomResourceIcon::read(), and DomString::read().
QStringList QImageReader::textKeys | ( | ) | const |
Returns the text keys for this image. You can use these keys with text() to list the image text for a certain key.
Support for this option is implemented through QImageIOHandler::Description.
Definition at line 895 of file qimagereader.cpp.
References QImageReaderPrivate::getText(), QMap< Key, T >::keys(), and QImageReaderPrivate::text.
QImageIOHandler::Transformations QImageReader::transformation | ( | ) | const |
Returns the transformation metadata of the image, including image orientation. If the format does not support transformation metadata, QImageIOHandler::TransformationNone is returned.
Definition at line 1078 of file qimagereader.cpp.
References QImageReaderPrivate::handler, QImageIOHandler::ImageTransformation, QImageReaderPrivate::initHandler(), QImageIOHandler::option(), QImageIOHandler::supportsOption(), QVariant::toInt(), and QImageIOHandler::TransformationNone.
Referenced by read().