QImageIOPlugin Class
The QImageIOPlugin class defines an interface for writing an image format plugin. More...
| Header: | #include <QImageIOPlugin> |
| qmake: | QT += gui |
| Inherits: | QObject |
Note: All functions in this class are reentrant.
Public Types
| enum | Capability { CanRead, CanWrite, CanReadIncremental } |
Detailed Description
QImageIOPlugin is a factory for creating QImageIOHandler objects, which are used internally by QImageReader and QImageWriter to add support for different image formats to Qt.
Writing an image I/O plugin is achieved by subclassing this base class, reimplementing the pure virtual functions capabilities() and create(), and exporting the class with the Q_PLUGIN_METADATA() macro. See How to Create Qt Plugins for details.
An image format plugin can support three capabilities: reading (CanRead), writing (CanWrite) and incremental reading (CanReadIncremental). Reimplement capabilities() in you subclass to expose the capabilities of your image format.
create() should create an instance of your QImageIOHandler subclass, with the provided device and format properly set, and return this handler.
The json metadata file for the plugin needs to contain information about the image formats the plugins supports, together with the corresponding MIME types (one for each format). For a jpeg plugin, this could, for example, look as follows:
{
"Keys": [ "jpg", "jpeg" ],
"MimeTypes": [ "image/jpeg", "image/jpeg" ]
}
Different plugins can support different capabilities. For example, you may have one plugin that supports reading the GIF format, and another that supports writing. Qt will select the correct plugin for the job, depending on the return value of capabilities(). If several plugins support the same capability, Qt will select one arbitrarily.
See also QImageIOHandler and How to Create Qt Plugins.
Member Type Documentation
enum QImageIOPlugin::Capability
This enum describes the capabilities of a QImageIOPlugin.
| Constant | Value | Description |
|---|---|---|
QImageIOPlugin::CanRead | 0x1 | The plugin can read images. |
QImageIOPlugin::CanWrite | 0x2 | The plugin can write images. |
QImageIOPlugin::CanReadIncremental | 0x4 | The plugin can read images incrementally. |