libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
imagefileio.h
Go to the documentation of this file.
1
8#pragma once
9
11#include <promeki/core/string.h>
12
19#define PROMEKI_REGISTER_IMAGEFILEIO(name) [[maybe_unused]] static int PROMEKI_CONCAT(__promeki_imagefileio_, PROMEKI_UNIQUE_ID) = \
20 ImageFileIO::registerImageFileIO(new name);
21
22
24
25class Error;
26class ImageFile;
27
36 public:
42 static int registerImageFileIO(ImageFileIO *object);
43
49 static const ImageFileIO *lookup(int id);
50
52 ImageFileIO() = default;
53
55 virtual ~ImageFileIO() {};
56
61 int id() const {
62 return _id;
63 }
64
69 bool isValid() const {
70 return _id != 0;
71 }
72
77 bool canLoad() const {
78 return _canLoad;
79 }
80
85 bool canSave() const {
86 return _canSave;
87 }
88
93 String name() const {
94 return _name;
95 }
96
102 virtual Error load(ImageFile &imageFile) const;
103
109 virtual Error save(ImageFile &imageFile) const;
110
111 protected:
112 int _id = 0;
113 bool _canLoad = false;
114 bool _canSave = false;
116
117};
118
120
Lightweight error code wrapper for the promeki library.
Definition error.h:39
Abstract backend for image file format I/O.
Definition imagefileio.h:35
virtual ~ImageFileIO()
Virtual destructor.
Definition imagefileio.h:55
bool _canSave
Whether saving is supported.
Definition imagefileio.h:114
int _id
Format identifier.
Definition imagefileio.h:112
String name() const
Returns the human-readable name of this backend.
Definition imagefileio.h:93
ImageFileIO()=default
Default constructor.
int id() const
Returns the format identifier for this backend.
Definition imagefileio.h:61
bool canSave() const
Returns true if this backend supports saving images.
Definition imagefileio.h:85
virtual Error load(ImageFile &imageFile) const
Loads an image from a file into the given ImageFile.
bool canLoad() const
Returns true if this backend supports loading images.
Definition imagefileio.h:77
bool _canLoad
Whether loading is supported.
Definition imagefileio.h:113
static int registerImageFileIO(ImageFileIO *object)
Registers an ImageFileIO backend in the global registry.
virtual Error save(ImageFile &imageFile) const
Saves the image from the given ImageFile to disk.
bool isValid() const
Returns true if this backend has a valid (non-zero) format ID.
Definition imagefileio.h:69
String _name
Human-readable format name.
Definition imagefileio.h:115
static const ImageFileIO * lookup(int id)
Looks up a registered backend by format ID.
Image file loader and saver.
Definition imagefile.h:27
Dynamic array container wrapping std::vector.
Definition list.h:40
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19