IDS peak IPL  v1.10.0
peak_ipl_pixel_format.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
16 
17 #include <cstddef>
18 #include <cstdint>
19 
23 namespace peak
24 {
25 namespace ipl
26 {
27 
31 class PixelFormat final
32 {
33 public:
41  : m_name(peak::ipl::PixelFormatName::Invalid)
42  {}
43 
52  PixelFormat(peak::ipl::PixelFormatName name); // NOLINT (note: implicitly used by Image...)
53 
54 
61  ~PixelFormat() = default;
62 
71  PixelFormat(PixelFormat&& other) = default;
72 
81  PixelFormat(const PixelFormat& other) = default;
82 
91  PixelFormat& operator=(const PixelFormat& other) = default;
92 
101  PixelFormat& operator=(PixelFormat&& other) = default;
102 
110  PEAK_IPL_NO_DISCARD std::string Name() const
111  {
112  return peak::ipl::ToString(m_name);
113  }
114 
123  {
124  return m_name;
125  }
126 
137  PEAK_IPL_NO_DISCARD bool operator==(const PixelFormat& other) const
138  {
139  return m_name == other.m_name;
140  }
141 
150  PEAK_IPL_NO_DISCARD size_t NumSignificantBitsPerChannel() const;
151 
160  PEAK_IPL_NO_DISCARD size_t NumStorageBitsPerChannel() const;
161 
170  PEAK_IPL_NO_DISCARD size_t NumChannels() const;
171 
183  PEAK_IPL_NO_DISCARD uint32_t MaximumValuePerChannel() const;
184 
194  PEAK_IPL_NO_DISCARD size_t NumSignificantBitsPerPixel() const;
195 
208  PEAK_IPL_NO_DISCARD size_t NumStorageBitsPerPixel() const;
209 
210 
220 
233  PEAK_IPL_NO_DISCARD uint64_t CalculateStorageSizeOfPixels(uint64_t numPixels) const;
234 
243  PEAK_IPL_NO_DISCARD bool IsPacked() const;
244 
253  PEAK_IPL_NO_DISCARD bool IsBayered() const;
254 
263  PEAK_IPL_NO_DISCARD bool IsYUV() const;
264 
273  PEAK_IPL_NO_DISCARD bool IsCoord3D() const;
274 
284 
285 
286 private:
288 };
289 
291  : m_name(name)
292 {}
293 
294 inline size_t PixelFormat::NumSignificantBitsPerChannel() const
295 {
296  size_t numSignificantBitsPerChannel = 0;
297 
300  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numSignificantBitsPerChannel);
301  });
302 
303  return numSignificantBitsPerChannel;
304 }
305 
306 inline size_t PixelFormat::NumStorageBitsPerChannel() const
307 {
308  size_t numStorageBitsPerChannel = 0;
309 
312  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numStorageBitsPerChannel);
313  });
314 
315  return numStorageBitsPerChannel;
316 }
317 
318 inline size_t PixelFormat::NumChannels() const
319 {
320  size_t numChannels = 0;
321 
324  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numChannels);
325  });
326 
327  return numChannels;
328 }
329 
330 inline uint32_t PixelFormat::MaximumValuePerChannel() const
331 {
332  uint32_t maximumValuePerChannel = 0;
333 
336  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &maximumValuePerChannel);
337  });
338 
339  return maximumValuePerChannel;
340 }
341 
342 inline size_t PixelFormat::NumSignificantBitsPerPixel() const
343 {
344  size_t numSignificantBitsPerPixel = 0;
345 
348  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numSignificantBitsPerPixel);
349  });
350 
351  return numSignificantBitsPerPixel;
352 }
353 
354 inline size_t PixelFormat::NumStorageBitsPerPixel() const
355 {
356  size_t numStorageBitsPerPixel = 0;
357 
360  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numStorageBitsPerPixel);
361  });
362 
363  return numStorageBitsPerPixel;
364 }
365 
367 {
369 
372  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_ENDIANNESS*>(&endianness));
373  });
374 
375  return endianness;
376 }
377 
378 inline uint64_t PixelFormat::CalculateStorageSizeOfPixels(uint64_t numPixels) const
379 {
380  uint64_t sizeOfPixels = 0;
381 
384  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), numPixels, &sizeOfPixels);
385  });
386 
387  return sizeOfPixels;
388 }
389 
390 inline bool PixelFormat::IsPacked() const
391 {
392  bool isPacked = false;
393 
396  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&isPacked));
397  });
398 
399  return isPacked;
400 }
401 
402 inline bool PixelFormat::IsBayered() 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 
414 inline bool PixelFormat::IsYUV() const
415 {
416  auto result{ false };
417 
420  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&result));
421  });
422 
423  return result;
424 }
425 
426 inline bool PixelFormat::IsCoord3D() 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 
439 {
441 
444  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BAYER_PATTERN*>(&pattern));
445  });
446 
447  return pattern;
448 }
449 
450 } /* namespace ipl */
451 } /* namespace peak */
#define PEAK_IPL_NO_DISCARD
Definition: peak_ipl_backend.h:26
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.
Little endian (lower bytes first)
~PixelFormat()=default
Destructor for the PixelFormat instance.
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.
#define PEAK_IPL_C_ABI_PREFIX
Definition: peak_ipl_dll_defines.h:16
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.
PixelFormat()
Constructor for a new PixelFormat instance.
Definition: peak_ipl_pixel_format.hpp:40
PixelFormat & operator=(const PixelFormat &other)=default
Copy assigment for PixelFormat instance.
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
PixelFormatName
Enum holding the possible pixel format names.
Definition: peak_ipl_simple_types.hpp:38
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition: peak_ipl_exception.hpp:182
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.
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.
BayerPattern
Enum holding the possible bayer patterns.
Definition: peak_ipl_simple_types.hpp:161
bool operator==(const Sharpness::SharpnessROI &lhs, const Sharpness::SharpnessROI &rhs)
Definition: peak_ipl_sharpness.hpp:419
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_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_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_GetNumStorageBitsPerPixel(PEAK_IPL_PIXEL_FORMAT pixelFormat, size_t *numStorageBits)
Queries the number of storage bits per pixel of the given pixel format.
Represents a pixel format and its specific properties.
Definition: peak_ipl_pixel_format.hpp:31
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_GetNumStorageBitsPerChannel(PEAK_IPL_PIXEL_FORMAT pixelFormat, size_t *numStorageBits)
Queries the number of storage bits per pixel per channel of the given pixel format.
Endianness
Enum holding the possible endianness (the byte order).
Definition: peak_ipl_simple_types.hpp:174
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_IsPacked(PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_BOOL8 *isPacked)
Check if the supplied format is packed.