libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
imagedesc.h
Go to the documentation of this file.
1
8#pragma once
9
12#include <promeki/core/size2d.h>
15
17
33class ImageDesc {
35 public:
38
40 ImageDesc() : _pixelFormat(PixelFormat::lookup(PixelFormat::Invalid)) { }
41
48 _size(sz), _pixelFormat(PixelFormat::lookup(pixfmt)) { }
49
56 ImageDesc(size_t w, size_t h, int pixfmt) :
57 _size(Size2Du32(w, h)), _pixelFormat(PixelFormat::lookup(pixfmt)) { }
58
63 int pixelFormatID() const {
64 return _pixelFormat->id();
65 }
66
71 bool isValid() const {
72 return _size.isValid() && _pixelFormat->isValid();
73 }
74
79 const Size2Du32 &size() const {
80 return _size;
81 }
82
87 size_t width() const {
88 return _size.width();
89 }
90
95 size_t height() const {
96 return _size.height();
97 }
98
103 void setSize(const Size2Du32 &val) {
104 _size = val;
105 return;
106 }
107
113 void setSize(int width, int height) {
114 _size.set(width, height);
115 return;
116 }
117
122 size_t linePad() const {
123 return _linePad;
124 }
125
130 void setLinePad(size_t val) {
131 _linePad = val;
132 return;
133 }
134
139 size_t lineAlign() const {
140 return _lineAlign;
141 }
142
147 void setLineAlign(size_t val) {
148 _lineAlign = val;
149 return;
150 }
151
156 bool interlaced() const {
157 return _interlaced;
158 }
159
164 void setInterlaced(bool val) {
165 _interlaced = val;
166 return;
167 }
168
173 const PixelFormat *pixelFormat() const {
174 return _pixelFormat;
175 }
176
182 _pixelFormat = PixelFormat::lookup(pixfmt);
183 return;
184 }
185
187 const Metadata &metadata() const {
188 return _metadata;
189 }
190
193 return _metadata;
194 }
195
200 int planeCount() const {
201 return _pixelFormat->planeCount();
202 }
203
208 String toString() const {
209 String ret = _size.toString();
210 ret += ' ';
211 ret += _pixelFormat->name();
212 return ret;
213 }
214
216 operator String() const {
217 return toString();
218 }
219
220 private:
221 Size2Du32 _size;
222 size_t _linePad = 0;
223 size_t _lineAlign = 1;
224 bool _interlaced = false;
225 const PixelFormat *_pixelFormat;
226 Metadata _metadata;
227};
228
230
Describes the format and layout of a single image.
Definition imagedesc.h:33
ImageDesc()
Constructs an invalid (default) image description with no pixel format.
Definition imagedesc.h:40
String toString() const
Returns a human-readable string representation of this image description.
Definition imagedesc.h:208
Metadata & metadata()
Returns a mutable reference to the metadata.
Definition imagedesc.h:192
void setSize(const Size2Du32 &val)
Sets the image dimensions.
Definition imagedesc.h:103
void setLineAlign(size_t val)
Sets the scanline alignment requirement.
Definition imagedesc.h:147
void setInterlaced(bool val)
Sets whether the image is interlaced.
Definition imagedesc.h:164
size_t height() const
Returns the image height in pixels.
Definition imagedesc.h:95
size_t lineAlign() const
Returns the scanline alignment requirement in bytes.
Definition imagedesc.h:139
ImageDesc(size_t w, size_t h, int pixfmt)
Constructs an image description from width, height, and pixel format ID.
Definition imagedesc.h:56
bool isValid() const
Returns true if this image description has valid dimensions and pixel format.
Definition imagedesc.h:71
const Metadata & metadata() const
Returns a const reference to the metadata.
Definition imagedesc.h:187
bool interlaced() const
Returns true if the image is interlaced.
Definition imagedesc.h:156
int pixelFormatID() const
Returns the pixel format identifier.
Definition imagedesc.h:63
void setPixelFormat(int pixfmt)
Sets the pixel format by ID.
Definition imagedesc.h:181
const Size2Du32 & size() const
Returns the image dimensions.
Definition imagedesc.h:79
void setLinePad(size_t val)
Sets the number of padding bytes appended to each scanline.
Definition imagedesc.h:130
int planeCount() const
Returns the number of image planes defined by the pixel format.
Definition imagedesc.h:200
void setSize(int width, int height)
Sets the image dimensions from width and height values.
Definition imagedesc.h:113
size_t linePad() const
Returns the number of padding bytes appended to each scanline.
Definition imagedesc.h:122
ImageDesc(const Size2Du32 &sz, int pixfmt)
Constructs an image description from a size and pixel format ID.
Definition imagedesc.h:47
const PixelFormat * pixelFormat() const
Returns a pointer to the PixelFormat descriptor for this image.
Definition imagedesc.h:173
size_t width() const
Returns the image width in pixels.
Definition imagedesc.h:87
Dynamic array container wrapping std::vector.
Definition list.h:40
Key-value metadata container using typed Variant values.
Definition metadata.h:68
Describes a pixel packing format and provides format-specific operations.
Definition pixelformat.h:43
static const PixelFormat * lookup(int id)
Looks up a registered pixel format by its ID.
const T & height() const
Returns the height.
Definition size2d.h:72
void set(const T &w, const T &h)
Sets both width and height.
Definition size2d.h:48
const T & width() const
Returns the width.
Definition size2d.h:61
String toString() const
Returns the size as a string in "WxH" format.
Definition size2d.h:82
bool isValid() const
Returns true if both width and height are greater than zero.
Definition size2d.h:43
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
#define PROMEKI_SHARED_FINAL(TYPE)
Macro for non-polymorphic native shared objects.
Definition sharedptr.h:88