IDSpeakIPL  v1.9.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 
151 
161 
170  PEAK_IPL_NO_DISCARD size_t NumChannels() const;
171 
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 
272 
273 private:
275 };
276 
278  : m_name(name)
279 {}
280 
282 {
283  size_t numSignificantBitsPerChannel = 0;
284 
287  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numSignificantBitsPerChannel);
288  });
289 
290  return numSignificantBitsPerChannel;
291 }
292 
294 {
295  size_t numStorageBitsPerChannel = 0;
296 
299  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numStorageBitsPerChannel);
300  });
301 
302  return numStorageBitsPerChannel;
303 }
304 
305 inline size_t PixelFormat::NumChannels() const
306 {
307  size_t numChannels = 0;
308 
311  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numChannels);
312  });
313 
314  return numChannels;
315 }
316 
317 inline uint32_t PixelFormat::MaximumValuePerChannel() const
318 {
319  uint32_t maximumValuePerChannel = 0;
320 
323  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &maximumValuePerChannel);
324  });
325 
326  return maximumValuePerChannel;
327 }
328 
330 {
331  size_t numSignificantBitsPerPixel = 0;
332 
335  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numSignificantBitsPerPixel);
336  });
337 
338  return numSignificantBitsPerPixel;
339 }
340 
342 {
343  size_t numStorageBitsPerPixel = 0;
344 
347  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numStorageBitsPerPixel);
348  });
349 
350  return numStorageBitsPerPixel;
351 }
352 
354 {
356 
359  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_ENDIANNESS*>(&endianness));
360  });
361 
362  return endianness;
363 }
364 
365 inline uint64_t PixelFormat::CalculateStorageSizeOfPixels(uint64_t numPixels) const
366 {
367  uint64_t sizeOfPixels = 0;
368 
371  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), numPixels, &sizeOfPixels);
372  });
373 
374  return sizeOfPixels;
375 }
376 
377 inline bool PixelFormat::IsPacked() const
378 {
379  bool isPacked = false;
380 
383  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&isPacked));
384  });
385 
386  return isPacked;
387 }
388 
389 inline bool PixelFormat::IsBayered() const
390 {
391  bool isPacked = false;
392 
395  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&isPacked));
396  });
397 
398  return isPacked;
399 }
400 
401 inline bool PixelFormat::IsYUV() const
402 {
403  auto result{ false };
404 
407  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&result));
408  });
409 
410  return result;
411 }
412 
414 {
416 
419  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BAYER_PATTERN*>(&pattern));
420  });
421 
422  return pattern;
423 }
424 
425 } /* namespace ipl */
426 } /* 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.
~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
PixelFormatName
Enum holding the possible pixel format names.
Definition: peak_ipl_simple_types.hpp:38
PEAK_IPL_NO_DISCARD std::string ToString(ConversionMode entry)
Convert a ConversionMode to a string.
Definition: peak_ipl_simple_types.hpp:263
PixelFormat & operator=(const PixelFormat &other)=default
Copy assigment for PixelFormat instance.
PEAK_IPL_NO_DISCARD bool IsYUV() const
Returns whether the pixel format is a yuv format.
Definition: peak_ipl_pixel_format.hpp:401
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
PEAK_IPL_NO_DISCARD 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:365
PEAK_IPL_NO_DISCARD bool IsPacked() const
Returns whether the pixel format is packed.
Definition: peak_ipl_pixel_format.hpp:377
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition: peak_ipl_exception.hpp:182
Endianness
Enum holding the possible endianness (the byte order).
Definition: peak_ipl_simple_types.hpp:170
PEAK_IPL_NO_DISCARD peak::ipl::Endianness Endianness() const
Returns the endianness of the given pixel format.
Definition: peak_ipl_pixel_format.hpp:353
PEAK_IPL_NO_DISCARD peak::ipl::PixelFormatName PixelFormatName() const
Returns the name of the pixel format as enum value.
Definition: peak_ipl_pixel_format.hpp:122
PEAK_IPL_NO_DISCARD uint32_t MaximumValuePerChannel() const
Returns the maximum value of one pixel channel the given pixel format has.
Definition: peak_ipl_pixel_format.hpp:317
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_NO_DISCARD size_t NumSignificantBitsPerPixel() const
Returns the number of significant bits per pixel the given pixel format has.
Definition: peak_ipl_pixel_format.hpp:329
PEAK_IPL_NO_DISCARD size_t NumChannels() const
Returns the number of channels the given pixel format has.
Definition: peak_ipl_pixel_format.hpp:305
PEAK_IPL_NO_DISCARD std::string Name() const
Returns the name of the pixel format as String.
Definition: peak_ipl_pixel_format.hpp:110
PEAK_IPL_NO_DISCARD bool IsBayered() const
Returns whether the pixel format is a bayer format.
Definition: peak_ipl_pixel_format.hpp:389
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...
Little endian (lower bytes first)
PEAK_IPL_NO_DISCARD bool operator==(const PixelFormat &other) const
Compare PixelFormat.
Definition: peak_ipl_pixel_format.hpp:137
BayerPattern
Enum holding the possible bayer patterns.
Definition: peak_ipl_simple_types.hpp:157
PEAK_IPL_NO_DISCARD size_t NumStorageBitsPerPixel() const
Returns the number of storage bits per pixel the given pixel format has.
Definition: peak_ipl_pixel_format.hpp:341
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_NO_DISCARD 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:281
PEAK_IPL_NO_DISCARD peak::ipl::BayerPattern BayerPattern() const
Queries the bayer pattern of the given pixel format.
Definition: peak_ipl_pixel_format.hpp:413
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_NO_DISCARD 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:293
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.