CopperSpice API  1.9.1
QImageIOPlugin Class Referenceabstract

The QImageIOPlugin class defines an interface for writing an image format plugin. More...

Inheritance diagram for QImageIOPlugin:
QObject

Public Typedefs

using Capabilities = QFlags< Capability >
 

Public Types

enum  Capability
 

Public Methods

 QImageIOPlugin (QObject *parent=nullptr)
 
virtual ~QImageIOPlugin ()
 
virtual Capabilities capabilities (QIODevice *device, const QString &format) const = 0
 
virtual QImageIOHandlercreate (QIODevice *device, const QString &format=QString ()) const = 0
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Additional Inherited Members

- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 
- Public Slots inherited from QObject
void deleteLater ()
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The QImageIOPlugin class defines an interface for writing an image format plugin.

QImageIOPlugin is a factory for creating QImageIOHandler objects, which are used internally by QImageReader and QImageWriter to add support for different image formats. Writing an image I/O plugin is achieved by subclassing this base class, reimplementing the pure virtual methods capabilities() and create() and then exporting the class with the CS_PLUGIN_REGISTER() macro.

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.

The create() method should create an instance of your QImageIOHandler subclass with the provided device and format properly set, and then return this handler.

Different plugins can support different capabilities. For example, you may have one plugin that supports reading the GIF format, and another that supports writing. CopperSpice will select the correct plugin for the job, depending on the return value of capabilities(). If several plugins support the same capability, CopperSpice will select one arbitrarily.

See also
QImageIOHandler, Creating Plugins

Member Typedef Documentation

Member Enumeration Documentation

This enum describes the capabilities of a QImageIOPlugin.

ConstantValueDescription
QImageIOPlugin::CanRead0x1 Plugin can read images.
QImageIOPlugin::CanWrite0x2 Plugin can write images.
QImageIOPlugin::CanReadIncremental0x4 Plugin can read images incrementally.

Constructor & Destructor Documentation

QImageIOPlugin::QImageIOPlugin ( QObject parent = nullptr)
explicit

Constructs an image plugin with the given parent.

QImageIOPlugin::~QImageIOPlugin ( )
virtual

Destroys the image plugin. You never have to call this explicitly as CopperSpice destroys a plugin automatically when it is no longer used.

Method Documentation

Capabilities QImageIOPlugin::capabilities ( QIODevice device,
const QString format 
) const
pure virtual

Returns the capabilities of the plugin based on the data in device and the format. If device is a nullptr, it should simply report whether the format can be read or written. Otherwise, it should attempt to determine whether the given format (or any format supported by the plugin if format is empty) can be read from or written to device. It should do this without changing the state of device (typically by using QIODevice::peek()).

For example, if the QImageIOPlugin supports the BMP format, format is either empty or "bmp", and the data in the device starts with the characters "BM", this function should return CanRead. If format is "bmp", device is 0 and the handler supports both reading and writing, this function should return CanRead | CanWrite.

Format names are always given in lower case.

QImageIOHandler * QImageIOPlugin::create ( QIODevice device,
const QString format = QString() 
) const
pure virtual

Creates and returns a QImageIOHandler subclass with device and format set. The format must come from the values listed in the "Keys" entry in the plugin metadata or be empty. If the format is empty the data in the device must have been recognized by the capabilities() method (with a likewise empty format).

Format names are always given in lower case.