libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
ImageFileIO Class Reference

Abstract backend for image file format I/O. More...

#include <imagefileio.h>

Collaboration diagram for ImageFileIO:

Public Member Functions

 ImageFileIO ()=default
 Default constructor.
 
virtual ~ImageFileIO ()
 Virtual destructor.
 
int id () const
 Returns the format identifier for this backend.
 
bool isValid () const
 Returns true if this backend has a valid (non-zero) format ID.
 
bool canLoad () const
 Returns true if this backend supports loading images.
 
bool canSave () const
 Returns true if this backend supports saving images.
 
String name () const
 Returns the human-readable name of this backend.
 
virtual Error load (ImageFile &imageFile) const
 Loads an image from a file into the given ImageFile.
 
virtual Error save (ImageFile &imageFile) const
 Saves the image from the given ImageFile to disk.
 

Static Public Member Functions

static int registerImageFileIO (ImageFileIO *object)
 Registers an ImageFileIO backend in the global registry.
 
static const ImageFileIOlookup (int id)
 Looks up a registered backend by format ID.
 

Protected Attributes

int _id = 0
 Format identifier.
 
bool _canLoad = false
 Whether loading is supported.
 
bool _canSave = false
 Whether saving is supported.
 
String _name
 Human-readable format name.
 

Detailed Description

Abstract backend for image file format I/O.

Subclasses implement format-specific loading and saving of images (e.g. PNG). Backends register themselves via PROMEKI_REGISTER_IMAGEFILEIO and are looked up by their format ID.

Member Function Documentation

◆ canLoad()

bool ImageFileIO::canLoad ( ) const
inline

Returns true if this backend supports loading images.

Returns
true if loading is supported.

◆ canSave()

bool ImageFileIO::canSave ( ) const
inline

Returns true if this backend supports saving images.

Returns
true if saving is supported.

◆ id()

int ImageFileIO::id ( ) const
inline

Returns the format identifier for this backend.

Returns
The format ID.

◆ isValid()

bool ImageFileIO::isValid ( ) const
inline

Returns true if this backend has a valid (non-zero) format ID.

Returns
true if the ID is not zero.

◆ load()

virtual Error ImageFileIO::load ( ImageFile imageFile) const
virtual

Loads an image from a file into the given ImageFile.

Parameters
imageFileThe ImageFile to populate with the loaded image data.
Returns
Error::Ok on success, or an error on failure.

◆ lookup()

static const ImageFileIO * ImageFileIO::lookup ( int  id)
static

Looks up a registered backend by format ID.

Parameters
idThe format identifier (e.g. ImageFile::PNG).
Returns
A pointer to the matching backend, or nullptr if not found.

◆ name()

String ImageFileIO::name ( ) const
inline

Returns the human-readable name of this backend.

Returns
The backend name as a String.

◆ registerImageFileIO()

static int ImageFileIO::registerImageFileIO ( ImageFileIO object)
static

Registers an ImageFileIO backend in the global registry.

Parameters
objectPointer to the backend to register. Ownership is taken.
Returns
A non-zero value (used for static initialization).

◆ save()

virtual Error ImageFileIO::save ( ImageFile imageFile) const
virtual

Saves the image from the given ImageFile to disk.

Parameters
imageFileThe ImageFile containing the image data and filename.
Returns
Error::Ok on success, or an error on failure.

The documentation for this class was generated from the following file: