ImageReader
Qt Base Class: QImageReader
Signature: QImageReader(self) -> None
QImageReader(self, device: PySide6.QtCore.QIODevice, format: Union[PySide6.QtCore.QByteArray, bytes] = Default(QByteArray)) -> None
QImageReader(self, fileName: str, format: Union[PySide6.QtCore.QByteArray, bytes] = Default(QByteArray)) -> None
Base classes
Name |
Children |
Inherits |
QImageReader PySide6.QtGui QImageReader(self) -> None |
|
|
⋔ Inheritance diagram
graph TD
1473245642176["gui.ImageReader"]
1473245519200["QtGui.QImageReader"]
1473291690208["Shiboken.Object"]
140713234304496["builtins.object"]
1473245519200 --> 1473245642176
1473291690208 --> 1473245519200
140713234304496 --> 1473291690208
🛈 DocStrings
Bases: QImageReader
Format independent interface for reading images from files or other devices.
Source code in prettyqt\gui\imagereader.py
| class ImageReader(gui.QImageReader):
"""Format independent interface for reading images from files or other devices."""
def __getitem__(self, key: str) -> str:
return self.text(key)
def get_error(self) -> ImageReaderErrorStr:
"""Return error type.
Returns:
error type
"""
return IMAGE_READER_ERROR.inverse[self.error()]
def get_background_color(self) -> gui.Color:
return gui.Color(self.backgroundColor())
def get_clip_rect(self) -> core.Rect:
return core.Rect(self.clipRect())
def get_current_image_rect(self) -> core.Rect:
return core.Rect(self.currentImageRect())
def get_scaled_clip_rect(self) -> core.Rect:
return core.Rect(self.scaledClipRect())
def get_size(self) -> core.Size:
return core.Size(self.size())
def get_scaled_size(self) -> core.Size:
return core.Size(self.scaledSize())
def get_format(self) -> str:
return self.format().data().decode()
def get_subtype(self) -> str:
return self.subType().data().decode()
def get_supported_subtypes(self) -> list[str]:
return [i.data().decode() for i in self.supportedSubTypes()]
def set_format(self, fmt: datatypes.ByteArrayType):
fmt = datatypes.to_bytearray(fmt)
self.setFormat(fmt)
def get_transformation(self) -> gui.imageiohandler.TransformationStr:
"""Return the transformation and orientation the image has been set to.
Returns:
transformation
"""
return gui.imageiohandler.TRANSFORMATION.inverse[self.transformation()]
def read_image(self) -> gui.Image:
return gui.Image(self.read())
def supports_option(
self, option: gui.imageiohandler.ImageOptionStr | gui.QImageIOHandler.ImageOption
) -> bool:
"""Return whether the image handler supports given option.
Args:
option: option to check
Returns:
option
"""
return self.supportsOption(gui.imageiohandler.IMAGE_OPTION.get_enum_value(option))
@staticmethod
def get_image_format(obj: str | core.QIODevice) -> str:
return ImageReader.imageFormat(obj).data().decode()
@staticmethod
def get_supported_image_formats() -> list[str]:
return [i.data().decode() for i in ImageReader.supportedImageFormats()]
@staticmethod
def get_supported_mime_types() -> list[str]:
return [i.data().decode() for i in ImageReader.supportedMimeTypes()]
@staticmethod
def get_image_formats_for_mime_type(typ: datatypes.ByteArrayType) -> list[str]:
typ = datatypes.to_bytearray(typ)
return [i.data().decode() for i in ImageReader.imageFormatsForMimeType(typ)]
|
get_error() -> ImageReaderErrorStr
Return error type.
Source code in prettyqt\gui\imagereader.py
| def get_error(self) -> ImageReaderErrorStr:
"""Return error type.
Returns:
error type
"""
return IMAGE_READER_ERROR.inverse[self.error()]
|
Return the transformation and orientation the image has been set to.
Source code in prettyqt\gui\imagereader.py
| def get_transformation(self) -> gui.imageiohandler.TransformationStr:
"""Return the transformation and orientation the image has been set to.
Returns:
transformation
"""
return gui.imageiohandler.TRANSFORMATION.inverse[self.transformation()]
|
supports_option(option: gui.imageiohandler.ImageOptionStr | gui.QImageIOHandler.ImageOption) -> bool
Return whether the image handler supports given option.
Parameters:
Name |
Type |
Description |
Default |
option |
ImageOptionStr | ImageOption
|
|
required
|
Source code in prettyqt\gui\imagereader.py
| def supports_option(
self, option: gui.imageiohandler.ImageOptionStr | gui.QImageIOHandler.ImageOption
) -> bool:
"""Return whether the image handler supports given option.
Args:
option: option to check
Returns:
option
"""
return self.supportsOption(gui.imageiohandler.IMAGE_OPTION.get_enum_value(option))
|