PythonQt.QtGui.QImageReader
QImageReader
PythonQtInstanceWrapper object
Native bases: PythonQtInstanceWrapper
Supplemental documentation: Qt 5 reference:
Detailed Description
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.
Note: QImageReader assumes exclusive control over the file or device that is assigned. Any attempts to modify the assigned file or device during the lifetime of the QImageReader object will yield undefined results.
Formats
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. Call supportedMimeTypes() to obtain a list of supported MIME types, which for example can be passed to QFileDialog::setMimeTypeFilters().
QImageReader autodetects the image format by default, by looking at the provided (optional) format string, the file name suffix, and the data stream contents. You can enable or disable this feature, by calling setAutoDetectImageFormat().
High Resolution Versions of Images
It is possible to provide high resolution versions of images should a scaling between device pixels and device independent pixels be in effect.
The high resolution version is marked by the suffix @2x on the base name. The image
read will have its device pixel ratio set to a value of 2.
This can be disabled by setting the environment variable
QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING.
Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html
Complete member index
Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.
| Member | Kind | Signature | Summary |
|---|---|---|---|
DeviceError |
attribute | Any |
|
FileNotFoundError |
attribute | Any |
|
ImageReaderError |
attribute | type |
Convert a number or string to an integer, or return 0 if no arguments are given. |
InvalidDataError |
attribute | Any |
|
UnknownError |
attribute | Any |
(shared captured text) |
UnsupportedFormatError |
attribute | Any |
|
__init__ |
function | (self, *args: Any, **kwargs: Any) -> None |
Native constructor; consult class documentation for supported overloads. (shared captured text) |
autoDetectImageFormat |
function | (self) -> bool |
X.autoDetectImageFormat() -> bool |
autoTransform |
function | (self) -> bool |
X.autoTransform() -> bool |
backgroundColor |
function | (self) -> Any |
X.backgroundColor() -> PythonQt.QtGui.QColor |
canRead |
function | (self) -> bool |
X.canRead() -> bool |
className |
function | (self, *args: Any, **kwargs: Any) -> Any |
Return the classname of the object (shared captured text) |
clipRect |
function | (self) -> Any |
X.clipRect() -> PythonQt.QtCore.QRect |
currentImageNumber |
function | (self) -> int |
X.currentImageNumber() -> int |
currentImageRect |
function | (self) -> Any |
X.currentImageRect() -> PythonQt.QtCore.QRect |
decideFormatFromContent |
function | (self) -> bool |
X.decideFormatFromContent() -> bool |
delete |
function | (self, *args: Any, **kwargs: Any) -> Any |
Deletes the C++ object (at your own risk, my friend!) (shared captured text) |
device |
function | (self) -> Any |
X.device() -> PythonQt.QtCore.QIODevice |
error |
function | (self) -> Any |
Returns the type of error that occurred last. |
errorString |
function | (self) -> str |
X.errorString() -> str |
fileName |
function | (self) -> str |
X.fileName() -> str |
format |
function | (self) -> Any |
X.format() -> PythonQt.QtCore.QByteArray |
gamma |
function | (self) -> float |
X.gamma() -> float |
help |
function | (self, *args: Any, **kwargs: Any) -> Any |
Shows the help of available methods for this class (shared captured text) |
imageCount |
function | (self) -> int |
X.imageCount() -> int |
imageFormat |
function | (self) -> Any |
Returns the format of the image, without actually reading the image contents. |
inherits |
function | (self, *args: Any, **kwargs: Any) -> Any |
Returns if the class inherits or is of given type name (shared captured text) |
jumpToImage |
function | (self, imageNumber: int) -> bool |
X.jumpToImage(imageNumber) -> bool |
jumpToNextImage |
function | (self) -> bool |
X.jumpToNextImage() -> bool |
loopCount |
function | (self) -> int |
X.loopCount() -> int |
nextImageDelay |
function | (self) -> int |
X.nextImageDelay() -> int |
quality |
function | (self) -> int |
X.quality() -> int |
read |
function | (self) -> Any |
X.read() -> PythonQt.QtGui.QImage |
scaledClipRect |
function | (self) -> Any |
X.scaledClipRect() -> PythonQt.QtCore.QRect |
scaledSize |
function | (self) -> Any |
X.scaledSize() -> PythonQt.QtCore.QSize |
setAutoDetectImageFormat |
function | (self, enabled: bool) -> None |
If enabled is true, image format autodetection is enabled; otherwise, it is disabled. |
setAutoTransform |
function | (self, enabled: bool) -> None |
Determines that images returned by [read](https://doc.qt.io/archives/qt-5.15/qimagereader.html#read)() should have transformation metadata automatically applied if enabled is true. |
setBackgroundColor |
function | (self, color: Any) -> None |
Sets the background color to color. |
setClipRect |
function | (self, rect: Any) -> None |
Sets the image clip rect (also known as the ROI, or Region Of Interest) to rect. |
setDecideFormatFromContent |
function | (self, ignored: bool) -> None |
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. |
setDevice |
function | (self, device: Any) -> None |
Sets [QImageReader](https://doc.qt.io/archives/qt-5.15/qimagereader.html)'s device to device. |
setFileName |
function | (self, fileName: str) -> None |
Sets the file name of [QImageReader](https://doc.qt.io/archives/qt-5.15/qimagereader.html) to fileName. |
setFormat |
function | (self, format: Any) -> None |
You can call [supportedImageFormats](https://doc.qt.io/archives/qt-5.15/qimagereader.html#supportedImageFormats)() for the full list of formats… |
setGamma |
function | (self, gamma: float) -> None |
|
setQuality |
function | (self, quality: int) -> None |
Sets the quality setting of the image format to quality. |
setScaledClipRect |
function | (self, rect: Any) -> None |
Sets the scaled clip rect to rect. |
setScaledSize |
function | (self, size: Any) -> None |
Sets the scaled size of the image to size. |
size |
function | (self) -> Any |
X.size() -> PythonQt.QtCore.QSize |
subType |
function | (self) -> Any |
X.subType() -> PythonQt.QtCore.QByteArray |
supportedImageFormats |
function | (self) -> Any |
Returns the list of image formats supported by [QImageReader](https://doc.qt.io/archives/qt-5.15/qimagereader.html). |
supportedMimeTypes |
function | (self) -> Any |
Returns the list of MIME types supported by [QImageReader](https://doc.qt.io/archives/qt-5.15/qimagereader.html). |
supportedSubTypes |
function | (self) -> Any |
Returns the list of subtypes supported by an image. |
supportsAnimation |
function | (self) -> bool |
X.supportsAnimation() -> bool |
supportsOption |
function | (self, option: Any) -> bool |
X.supportsOption(option) -> bool |
text |
function | (self, key: str) -> str |
X.text(key) -> str |
textKeys |
function | (self) -> tuple |
X.textKeys() -> tuple |
tr |
function | (self, sourceText: Any, disambiguation: Any, n: Any) -> str |
X.tr(sourceText, disambiguation, n) -> str (shared captured text) |
trUtf8 |
function | (self, sourceText: Any, disambiguation: Any, n: Any) -> str |
X.trUtf8(sourceText, disambiguation, n) -> str (shared captured text) |