IDSpeakIPL  v1.8.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 
262 
263 private:
265 };
266 
268  : m_name(name)
269 {}
270 
272 {
273  size_t numSignificantBitsPerChannel = 0;
274 
277  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numSignificantBitsPerChannel);
278  });
279 
280  return numSignificantBitsPerChannel;
281 }
282 
284 {
285  size_t numStorageBitsPerChannel = 0;
286 
289  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numStorageBitsPerChannel);
290  });
291 
292  return numStorageBitsPerChannel;
293 }
294 
295 inline size_t PixelFormat::NumChannels() const
296 {
297  size_t numChannels = 0;
298 
301  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numChannels);
302  });
303 
304  return numChannels;
305 }
306 
307 inline uint32_t PixelFormat::MaximumValuePerChannel() const
308 {
309  uint32_t maximumValuePerChannel = 0;
310 
313  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &maximumValuePerChannel);
314  });
315 
316  return maximumValuePerChannel;
317 }
318 
320 {
321  size_t numSignificantBitsPerPixel = 0;
322 
325  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numSignificantBitsPerPixel);
326  });
327 
328  return numSignificantBitsPerPixel;
329 }
330 
332 {
333  size_t numStorageBitsPerPixel = 0;
334 
337  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numStorageBitsPerPixel);
338  });
339 
340  return numStorageBitsPerPixel;
341 }
342 
344 {
346 
349  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_ENDIANNESS*>(&endianness));
350  });
351 
352  return endianness;
353 }
354 
355 inline uint64_t PixelFormat::CalculateStorageSizeOfPixels(uint64_t numPixels) const
356 {
357  uint64_t sizeOfPixels = 0;
358 
361  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), numPixels, &sizeOfPixels);
362  });
363 
364  return sizeOfPixels;
365 }
366 
367 inline bool PixelFormat::IsPacked() const
368 {
369  bool isPacked = false;
370 
373  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&isPacked));
374  });
375 
376  return isPacked;
377 }
378 
379 inline bool PixelFormat::IsBayered() const
380 {
381  bool isPacked = false;
382 
385  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&isPacked));
386  });
387 
388  return isPacked;
389 }
390 
392 {
394 
397  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BAYER_PATTERN*>(&pattern));
398  });
399 
400  return pattern;
401 }
402 
403 } /* namespace ipl */
404 } /* 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:260
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
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:355
PEAK_IPL_NO_DISCARD bool IsPacked() const
Returns whether the pixel format is packed.
Definition: peak_ipl_pixel_format.hpp:367
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:167
PEAK_IPL_NO_DISCARD peak::ipl::Endianness Endianness() const
Returns the endianness of the given pixel format.
Definition: peak_ipl_pixel_format.hpp:343
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:307
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:319
PEAK_IPL_NO_DISCARD size_t NumChannels() const
Returns the number of channels the given pixel format has.
Definition: peak_ipl_pixel_format.hpp:295
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:379
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:154
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:331
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:271
PEAK_IPL_NO_DISCARD peak::ipl::BayerPattern BayerPattern() const
Queries the bayer pattern of the given pixel format.
Definition: peak_ipl_pixel_format.hpp:391
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:283
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.