Image Formats NG
Public Member Functions | List of all members
ImageIOHandler Class Referenceabstract

Base class for all handlers. More...

Inherited by DDSHandler, DefaultHandler, JpegHandler, QPngHandler, and TestHandler.

Public Member Functions

 ImageIOHandler ()
 Creates an ImageIOHandler object.
 
virtual ~ImageIOHandler ()
 Destroys the ImageIOHandler object.
 
QIODevice * device () const
 Returns the device currently assigned to the ImageIOHandler. More...
 
QMimeType mimeType () const
 Returns the mime type that is currently assigned to the ImageIOHandler. More...
 
QByteArray subType () const
 Returns subType that is used to write an image. More...
 
virtual bool canRead () const =0
 Returns true if an image can be read from the device (i.e., the image format is supported, the device can be read from and the initial header information suggests that the image can be read); otherwise returns false. More...
 
virtual bool readHeader (ImageHeader &header)=0
 Read an metadata from the device, and stores it in header. More...
 
virtual bool read (ImageContents &contents, const ImageOptions &options)=0
 Read an image data from the device, and stores it in contents. More...
 
virtual bool write (const ImageContents &contents, const ImageOptions &options)
 Writes the contents with the given options to the assigned device. More...
 

Detailed Description

Base class for all handlers.

Member Function Documentation

◆ canRead()

bool ImageIOHandler::canRead ( ) const
pure virtual

Returns true if an image can be read from the device (i.e., the image format is supported, the device can be read from and the initial header information suggests that the image can be read); otherwise returns false.

When reimplementing canRead(), make sure that the I/O device (device()) is left in its original state (e.g., by using peek() rather than read()).

◆ device()

QIODevice * ImageIOHandler::device ( ) const

Returns the device currently assigned to the ImageIOHandler.

If no device has been assigned, nullptr is returned.

◆ mimeType()

QMimeType ImageIOHandler::mimeType ( ) const

Returns the mime type that is currently assigned to the ImageIOHandler.

If no mime type has been assigned yet, an empty string is returned.

◆ read()

bool ImageIOHandler::read ( ImageContents contents,
const ImageOptions options 
)
pure virtual

Read an image data from the device, and stores it in contents.

Returns true if the contents is successfully read; otherwise returns false.

◆ readHeader()

bool ImageIOHandler::readHeader ( ImageHeader header)
pure virtual

Read an metadata from the device, and stores it in header.

Returns true if the header is successfully read; otherwise returns false.

This method is called before read() and should not read actual image data if possible.

◆ subType()

QByteArray ImageIOHandler::subType ( ) const

Returns subType that is used to write an image.

If no subtype has been assigned, an empty QByteArray is returned.

◆ write()

bool ImageIOHandler::write ( const ImageContents contents,
const ImageOptions options 
)
virtual

Writes the contents with the given options to the assigned device.

Returns true on success; otherwise returns false.

The default implementation does nothing, and simply returns false.