IDS peak IPL v1.18.0
Loading...
Searching...
No Matches
peak_ipl_pixel_format.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
11
12#include <cstddef>
13#include <cstdint>
14
19
20namespace peak
21{
22namespace ipl
23{
24
29class PixelFormat final
30{
31public:
39 : m_name(peak::ipl::PixelFormatName::Invalid)
40 {}
41
50 PixelFormat(peak::ipl::PixelFormatName name); // NOLINT (note: implicitly used by Image...)
51
52
59 ~PixelFormat() = default;
60
69 PixelFormat(PixelFormat&& other) = default;
70
79 PixelFormat(const PixelFormat& other) = default;
80
89 PixelFormat& operator=(const PixelFormat& other) = default;
90
99 PixelFormat& operator=(PixelFormat&& other) = default;
100
108 PEAK_IPL_NO_DISCARD std::string Name() const
109 {
110 return peak::ipl::ToString(m_name);
111 }
112
121 {
122 return m_name;
123 }
124
136 {
137 return m_name == other.m_name;
138 }
139
149
159
168 PEAK_IPL_NO_DISCARD size_t NumChannels() const;
169
182
193
207
208
218
231 PEAK_IPL_NO_DISCARD uint64_t CalculateStorageSizeOfPixels(uint64_t numPixels) const;
232
241 PEAK_IPL_NO_DISCARD bool IsPacked() const;
242
251 PEAK_IPL_NO_DISCARD bool IsBayered() const;
252
261 PEAK_IPL_NO_DISCARD bool IsYUV() const;
262
271 PEAK_IPL_NO_DISCARD bool IsCoord3D() const;
272
281 PEAK_IPL_NO_DISCARD bool IsFloat() const;
282
292
293
294private:
296};
297
299 : m_name(name)
300{}
301
303{
304 size_t numSignificantBitsPerChannel = 0;
305
308 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numSignificantBitsPerChannel);
309 });
310
311 return numSignificantBitsPerChannel;
312}
313
315{
316 size_t numStorageBitsPerChannel = 0;
317
320 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numStorageBitsPerChannel);
321 });
322
323 return numStorageBitsPerChannel;
324}
325
326inline size_t PixelFormat::NumChannels() const
327{
328 size_t numChannels = 0;
329
332 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numChannels);
333 });
334
335 return numChannels;
336}
337
339{
340 uint32_t maximumValuePerChannel = 0;
341
344 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &maximumValuePerChannel);
345 });
346
347 return maximumValuePerChannel;
348}
349
351{
352 size_t numSignificantBitsPerPixel = 0;
353
356 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numSignificantBitsPerPixel);
357 });
358
359 return numSignificantBitsPerPixel;
360}
361
363{
364 size_t numStorageBitsPerPixel = 0;
365
368 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numStorageBitsPerPixel);
369 });
370
371 return numStorageBitsPerPixel;
372}
373
375{
377
380 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_ENDIANNESS*>(&endianness));
381 });
382
383 return endianness;
384}
385
386inline uint64_t PixelFormat::CalculateStorageSizeOfPixels(uint64_t numPixels) const
387{
388 uint64_t sizeOfPixels = 0;
389
392 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), numPixels, &sizeOfPixels);
393 });
394
395 return sizeOfPixels;
396}
397
398inline bool PixelFormat::IsPacked() const
399{
400 bool isPacked = false;
401
404 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&isPacked));
405 });
406
407 return isPacked;
408}
409
410inline bool PixelFormat::IsBayered() const
411{
412 bool isPacked = false;
413
416 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&isPacked));
417 });
418
419 return isPacked;
420}
421
422inline bool PixelFormat::IsYUV() const
423{
424 auto result{ false };
425
428 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&result));
429 });
430
431 return result;
432}
433
434inline bool PixelFormat::IsCoord3D() const
435{
436 auto result{ false };
437
440 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&result));
441 });
442
443 return result;
444}
445
446inline bool PixelFormat::IsFloat() const
447{
448 auto result{ false };
449
452 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&result));
453 });
454
455 return result;
456}
457
459{
461
464 static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BAYER_PATTERN*>(&pattern));
465 });
466
467 return pattern;
468}
469
470} /* namespace ipl */
471} /* namespace peak */
size_t NumChannels() const
Returns the number of channels the given pixel format has.
Definition peak_ipl_pixel_format.hpp:326
peak::ipl::BayerPattern BayerPattern() const
Queries the bayer pattern of the given pixel format.
Definition peak_ipl_pixel_format.hpp:458
peak::ipl::PixelFormatName PixelFormatName() const
Returns the name of the pixel format as enum value.
Definition peak_ipl_pixel_format.hpp:120
std::string Name() const
Returns the name of the pixel format as String.
Definition peak_ipl_pixel_format.hpp:108
bool IsBayered() const
Returns whether the pixel format is a bayer format.
Definition peak_ipl_pixel_format.hpp:410
PixelFormat()
Constructor for a new PixelFormat instance.
Definition peak_ipl_pixel_format.hpp:38
bool IsFloat() const
Returns whether the pixel format is a float format.
Definition peak_ipl_pixel_format.hpp:446
peak::ipl::Endianness Endianness() const
Returns the endianness of the given pixel format.
Definition peak_ipl_pixel_format.hpp:374
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:386
bool IsPacked() const
Returns whether the pixel format is packed.
Definition peak_ipl_pixel_format.hpp:398
size_t NumStorageBitsPerPixel() const
Returns the number of storage bits per pixel the given pixel format has.
Definition peak_ipl_pixel_format.hpp:362
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:135
bool IsCoord3D() const
Returns whether the pixel format is a 3D coordinate format.
Definition peak_ipl_pixel_format.hpp:434
size_t NumSignificantBitsPerPixel() const
Returns the number of significant bits per pixel the given pixel format has.
Definition peak_ipl_pixel_format.hpp:350
~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:314
bool IsYUV() const
Returns whether the pixel format is a yuv format.
Definition peak_ipl_pixel_format.hpp:422
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:338
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:302
PixelFormat(const PixelFormat &other)=default
Move constructor for PixelFormat instance.
PixelFormatName
Enum holding the possible pixel format names.
Definition peak_ipl_simple_types.hpp:38
@ Invalid
Invalid Pixel Format.
Definition peak_ipl_simple_types.hpp:39
std::string ToString(ConversionMode entry)
Convert a ConversionMode to a string.
Definition peak_ipl_simple_types.hpp:282
Endianness
Enum holding the possible endianness (the byte order).
Definition peak_ipl_simple_types.hpp:184
BayerPattern
Enum holding the possible bayer patterns.
Definition peak_ipl_simple_types.hpp:170
@ LittleEndian
Little endian (lower bytes first)
Definition peak_ipl_simple_types.hpp:186
@ Unknown
Unknown pattern.
Definition peak_ipl_simple_types.hpp:171
The "peak::ipl" namespace contains the whole image processing library.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:284
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_attribute_defines.h:20
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:23
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:182
int32_t PEAK_IPL_PIXEL_FORMAT
Definition peak_ipl_backend.h:170
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:191
#define PEAK_IPL_C_ABI_PREFIX
Definition peak_ipl_dll_defines.h:11