IDS peak IPL v1.17.0
Loading...
Searching...
No Matches
peak_ipl_pixel_format.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
16
17#include <cstddef>
18#include <cstdint>
19
24
25namespace peak
26{
27namespace ipl
28{
29
33class PixelFormat final
34{
35public:
43 : m_name(peak::ipl::PixelFormatName::Invalid)
44 {}
45
54 PixelFormat(peak::ipl::PixelFormatName name); // NOLINT (note: implicitly used by Image...)
55
56
63 ~PixelFormat() = default;
64
73 PixelFormat(PixelFormat&& other) = default;
74
83 PixelFormat(const PixelFormat& other) = default;
84
93 PixelFormat& operator=(const PixelFormat& other) = default;
94
103 PixelFormat& operator=(PixelFormat&& other) = default;
104
112 PEAK_IPL_NO_DISCARD std::string Name() const
113 {
114 return peak::ipl::ToString(m_name);
115 }
116
125 {
126 return m_name;
127 }
128
140 {
141 return m_name == other.m_name;
142 }
143
153
163
172 PEAK_IPL_NO_DISCARD size_t NumChannels() const;
173
186
197
211
212
222
235 PEAK_IPL_NO_DISCARD uint64_t CalculateStorageSizeOfPixels(uint64_t numPixels) const;
236
245 PEAK_IPL_NO_DISCARD bool IsPacked() const;
246
255 PEAK_IPL_NO_DISCARD bool IsBayered() const;
256
265 PEAK_IPL_NO_DISCARD bool IsYUV() const;
266
275 PEAK_IPL_NO_DISCARD bool IsCoord3D() const;
276
285 PEAK_IPL_NO_DISCARD bool IsFloat() const;
286
296
297
298private:
300};
301
303 : m_name(name)
304{}
305
307{
308 size_t numSignificantBitsPerChannel = 0;
309
312 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numSignificantBitsPerChannel);
313 });
314
315 return numSignificantBitsPerChannel;
316}
317
319{
320 size_t numStorageBitsPerChannel = 0;
321
324 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numStorageBitsPerChannel);
325 });
326
327 return numStorageBitsPerChannel;
328}
329
330inline size_t PixelFormat::NumChannels() const
331{
332 size_t numChannels = 0;
333
336 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numChannels);
337 });
338
339 return numChannels;
340}
341
343{
344 uint32_t maximumValuePerChannel = 0;
345
348 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &maximumValuePerChannel);
349 });
350
351 return maximumValuePerChannel;
352}
353
355{
356 size_t numSignificantBitsPerPixel = 0;
357
360 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numSignificantBitsPerPixel);
361 });
362
363 return numSignificantBitsPerPixel;
364}
365
367{
368 size_t numStorageBitsPerPixel = 0;
369
372 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numStorageBitsPerPixel);
373 });
374
375 return numStorageBitsPerPixel;
376}
377
379{
381
384 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_ENDIANNESS*>(&endianness));
385 });
386
387 return endianness;
388}
389
390inline uint64_t PixelFormat::CalculateStorageSizeOfPixels(uint64_t numPixels) const
391{
392 uint64_t sizeOfPixels = 0;
393
396 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), numPixels, &sizeOfPixels);
397 });
398
399 return sizeOfPixels;
400}
401
402inline bool PixelFormat::IsPacked() const
403{
404 bool isPacked = false;
405
408 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&isPacked));
409 });
410
411 return isPacked;
412}
413
414inline bool PixelFormat::IsBayered() const
415{
416 bool isPacked = false;
417
420 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&isPacked));
421 });
422
423 return isPacked;
424}
425
426inline bool PixelFormat::IsYUV() const
427{
428 auto result{ false };
429
432 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&result));
433 });
434
435 return result;
436}
437
438inline bool PixelFormat::IsCoord3D() const
439{
440 auto result{ false };
441
444 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&result));
445 });
446
447 return result;
448}
449
450inline bool PixelFormat::IsFloat() const
451{
452 auto result{ false };
453
456 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&result));
457 });
458
459 return result;
460}
461
463{
465
468 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BAYER_PATTERN*>(&pattern));
469 });
470
471 return pattern;
472}
473
474} /* namespace ipl */
475} /* namespace peak */
size_t NumChannels() const
Returns the number of channels the given pixel format has.
Definition peak_ipl_pixel_format.hpp:330
peak::ipl::BayerPattern BayerPattern() const
Queries the bayer pattern of the given pixel format.
Definition peak_ipl_pixel_format.hpp:462
peak::ipl::PixelFormatName PixelFormatName() const
Returns the name of the pixel format as enum value.
Definition peak_ipl_pixel_format.hpp:124
std::string Name() const
Returns the name of the pixel format as String.
Definition peak_ipl_pixel_format.hpp:112
bool IsBayered() const
Returns whether the pixel format is a bayer format.
Definition peak_ipl_pixel_format.hpp:414
PixelFormat()
Constructor for a new PixelFormat instance.
Definition peak_ipl_pixel_format.hpp:42
bool IsFloat() const
Returns whether the pixel format is a float format.
Definition peak_ipl_pixel_format.hpp:450
peak::ipl::Endianness Endianness() const
Returns the endianness of the given pixel format.
Definition peak_ipl_pixel_format.hpp:378
PixelFormat & operator=(const PixelFormat &other)=default
Copy assigment for PixelFormat instance.
uint64_t CalculateStorageSizeOfPixels(uint64_t numPixels) const
Returns the storage size the given number pixels of the given pixel format in bytes.
Definition peak_ipl_pixel_format.hpp:390
bool IsPacked() const
Returns whether the pixel format is packed.
Definition peak_ipl_pixel_format.hpp:402
size_t NumStorageBitsPerPixel() const
Returns the number of storage bits per pixel the given pixel format has.
Definition peak_ipl_pixel_format.hpp:366
PixelFormat(PixelFormat &&other)=default
Copy Constructor for a new PixelFormat instance.
bool operator==(const PixelFormat &other) const
Compare PixelFormat.
Definition peak_ipl_pixel_format.hpp:139
bool IsCoord3D() const
Returns whether the pixel format is a 3D coordinate format.
Definition peak_ipl_pixel_format.hpp:438
size_t NumSignificantBitsPerPixel() const
Returns the number of significant bits per pixel the given pixel format has.
Definition peak_ipl_pixel_format.hpp:354
~PixelFormat()=default
Destructor for the PixelFormat instance.
size_t NumStorageBitsPerChannel() const
Returns the number of storage bits per pixel per channel of the given pixel format.
Definition peak_ipl_pixel_format.hpp:318
bool IsYUV() const
Returns whether the pixel format is a yuv format.
Definition peak_ipl_pixel_format.hpp:426
PixelFormat & operator=(PixelFormat &&other)=default
Move assignment for PixelFormat instance.
uint32_t MaximumValuePerChannel() const
Returns the maximum value of one pixel channel the given pixel format has.
Definition peak_ipl_pixel_format.hpp:342
size_t NumSignificantBitsPerChannel() const
Returns the number of significant bits per pixel per channel of the given pixel format.
Definition peak_ipl_pixel_format.hpp:306
PixelFormat(const PixelFormat &other)=default
Move constructor for PixelFormat instance.
The "peak::ipl" namespace contains the whole image processing library.
std::string ToString(ConversionMode entry)
Convert a ConversionMode to a string.
Definition peak_ipl_simple_types.hpp:277
Endianness
Enum holding the possible endianness (the byte order).
Definition peak_ipl_simple_types.hpp:185
@ LittleEndian
Little endian (lower bytes first)
Definition peak_ipl_simple_types.hpp:187
BayerPattern
Enum holding the possible bayer patterns.
Definition peak_ipl_simple_types.hpp:172
@ Unknown
Unknown pattern.
Definition peak_ipl_simple_types.hpp:173
PixelFormatName
Enum holding the possible pixel format names.
Definition peak_ipl_simple_types.hpp:41
@ Invalid
Invalid Pixel Format.
Definition peak_ipl_simple_types.hpp:42
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:271
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_attribute_defines.h:25
PEAK_IPL_C_API PEAK_IPL_PixelFormat_IsPacked(PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_BOOL8 *isPacked)
Check if the supplied format is packed.
PEAK_IPL_C_API PEAK_IPL_PixelFormat_GetMaximumValuePerChannel(PEAK_IPL_PIXEL_FORMAT pixelFormat, uint32_t *channelMaximumValue)
Queries the maximum value of one pixel channel of the given pixel format.
PEAK_IPL_C_API PEAK_IPL_PixelFormat_GetNumSignificantBitsPerChannel(PEAK_IPL_PIXEL_FORMAT pixelFormat, size_t *numSignificantBits)
Queries the number of significant bits per pixel per channel of the given pixel format.
PEAK_IPL_C_API PEAK_IPL_PixelFormat_GetNumChannels(PEAK_IPL_PIXEL_FORMAT pixelFormat, size_t *numChannels)
Queries the number of channels of the given pixel format.
PEAK_IPL_C_API PEAK_IPL_PixelFormat_GetNumStorageBitsPerChannel(PEAK_IPL_PIXEL_FORMAT pixelFormat, size_t *numStorageBits)
Queries the number of storage bits per pixel per channel of the given pixel format.
PEAK_IPL_C_API PEAK_IPL_PixelFormat_GetNumSignificantBitsPerPixel(PEAK_IPL_PIXEL_FORMAT pixelFormat, size_t *numSignificantBits)
Queries the number of significant bits per pixel of the given pixel format.
PEAK_IPL_C_API PEAK_IPL_PixelFormat_IsBayered(PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_BOOL8 *isBayered)
Check if the supplied format is a bayer format.
PEAK_IPL_C_API PEAK_IPL_PixelFormat_GetBayerPattern(PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_BAYER_PATTERN *pattern)
Queries the bayer pattern of the given pixel format.
PEAK_IPL_C_API PEAK_IPL_PixelFormat_CalculateStorageSizeOfPixels(PEAK_IPL_PIXEL_FORMAT pixelFormat, uint64_t numPixels, uint64_t *size)
Calculates the storage size of the given number of pixels of the given pixel format in bytes.
PEAK_IPL_C_API PEAK_IPL_PixelFormat_IsFloat(PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_BOOL8 *isFloat)
Check if the supplied format is a float format.
int8_t PEAK_IPL_BOOL8
Definition peak_ipl_backend.h:26
PEAK_IPL_C_API PEAK_IPL_PixelFormat_GetEndianness(PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_ENDIANNESS *endianness)
Queries the endianness of the given pixel format.
int32_t PEAK_IPL_BAYER_PATTERN
Definition peak_ipl_backend.h:185
int32_t PEAK_IPL_PIXEL_FORMAT
Definition peak_ipl_backend.h:173
PEAK_IPL_C_API PEAK_IPL_PixelFormat_GetNumStorageBitsPerPixel(PEAK_IPL_PIXEL_FORMAT pixelFormat, size_t *numStorageBits)
Queries the number of storage bits per pixel of the given pixel format.
PEAK_IPL_C_API PEAK_IPL_PixelFormat_IsYUV(PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_BOOL8 *isYUV)
Check if the supplied format is a yuv format.
PEAK_IPL_C_API PEAK_IPL_PixelFormat_IsCoord3D(PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_BOOL8 *isCoord3D)
Check if the supplied format is a 3D coordinate format.
int32_t PEAK_IPL_ENDIANNESS
Definition peak_ipl_backend.h:194
#define PEAK_IPL_C_ABI_PREFIX
Definition peak_ipl_dll_defines.h:16