IDS peak IPL  v1.7.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:
35  : m_name(peak::ipl::PixelFormatName::Invalid)
36  {}
38  ~PixelFormat() = default;
39  PixelFormat(const PixelFormat& other) = default;
40  PixelFormat& operator=(const PixelFormat& other) = default;
41  PixelFormat(PixelFormat&& other) = default;
42  PixelFormat& operator=(PixelFormat&& other) = default;
43 
53  std::string Name() const
54  {
55  return peak::ipl::ToString(m_name);
56  }
57 
68  {
69  return m_name;
70  }
71 
72  bool operator==(const PixelFormat& other) const
73  {
74  return m_name == other.m_name;
75  }
76 
85  size_t NumSignificantBitsPerChannel() const;
86 
96  size_t NumStorageBitsPerChannel() const;
97 
106  size_t NumChannels() const;
107 
117  uint32_t MaximumValuePerChannel() const;
118 
128  size_t NumSignificantBitsPerPixel() const;
129 
139  size_t NumStorageBitsPerPixel() const;
140 
141 
151 
162  uint64_t CalculateStorageSizeOfPixels(uint64_t numPixels) const;
163 
172  bool IsPacked() const;
173 
182  bool IsBayered() const;
183 
184 private:
186 };
187 
189  : m_name(name)
190 {}
191 
193 {
194  size_t numSignificantBitsPerChannel = 0;
195 
198  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numSignificantBitsPerChannel);
199  });
200 
201  return numSignificantBitsPerChannel;
202 }
203 
205 {
206  size_t numStorageBitsPerChannel = 0;
207 
210  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numStorageBitsPerChannel);
211  });
212 
213  return numStorageBitsPerChannel;
214 }
215 
216 inline size_t PixelFormat::NumChannels() const
217 {
218  size_t numChannels = 0;
219 
222  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numChannels);
223  });
224 
225  return numChannels;
226 }
227 
228 inline uint32_t PixelFormat::MaximumValuePerChannel() const
229 {
230  uint32_t maximumValuePerChannel = 0;
231 
234  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &maximumValuePerChannel);
235  });
236 
237  return maximumValuePerChannel;
238 }
239 
241 {
242  size_t numSignificantBitsPerPixel = 0;
243 
246  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numSignificantBitsPerPixel);
247  });
248 
249  return numSignificantBitsPerPixel;
250 }
251 
253 {
254  size_t numStorageBitsPerPixel = 0;
255 
258  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), &numStorageBitsPerPixel);
259  });
260 
261  return numStorageBitsPerPixel;
262 }
263 
265 {
267 
270  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_ENDIANNESS*>(&endianness));
271  });
272 
273  return endianness;
274 }
275 
276 inline uint64_t PixelFormat::CalculateStorageSizeOfPixels(uint64_t numPixels) const
277 {
278  uint64_t sizeOfPixels = 0;
279 
282  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), numPixels, &sizeOfPixels);
283  });
284 
285  return sizeOfPixels;
286 }
287 
288 inline bool PixelFormat::IsPacked() const
289 {
290  bool isPacked = false;
291 
294  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&isPacked));
295  });
296 
297  return isPacked;
298 }
299 
300 inline bool PixelFormat::IsBayered() const
301 {
302  bool isPacked = false;
303 
306  static_cast<PEAK_IPL_PIXEL_FORMAT>(m_name), reinterpret_cast<PEAK_IPL_BOOL8*>(&isPacked));
307  });
308 
309  return isPacked;
310 }
311 
312 } /* namespace ipl */
313 } /* namespace peak */
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_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
PixelFormat()
Definition: peak_ipl_pixel_format.hpp:34
PixelFormatName
Enum holding the possible pixel format names.
Definition: peak_ipl_simple_types.hpp:38
PixelFormat & operator=(const PixelFormat &other)=default
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
std::string Name() const
Returns the name of the pixel format as String.
Definition: peak_ipl_pixel_format.hpp:53
uint64_t CalculateStorageSizeOfPixels(uint64_t numPixels) const
Returns the storage size of the given number of pixels of the given pixel format in bytes...
Definition: peak_ipl_pixel_format.hpp:276
bool IsPacked() const
Returns whether the pixel format is packed.
Definition: peak_ipl_pixel_format.hpp:288
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:144
peak::ipl::Endianness Endianness() const
Returns the endianness of the given pixel format.
Definition: peak_ipl_pixel_format.hpp:264
uint32_t MaximumValuePerChannel() const
Returns the maximum value of one pixel channel of the given pixel format.
Definition: peak_ipl_pixel_format.hpp:228
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.
size_t NumSignificantBitsPerPixel() const
Returns the number of significant bits per pixel of the given pixel format.
Definition: peak_ipl_pixel_format.hpp:240
peak::ipl::PixelFormatName PixelFormatName() const
Returns the name of the pixel format as enum value.
Definition: peak_ipl_pixel_format.hpp:67
size_t NumChannels() const
Returns the number of channels of the given pixel format.
Definition: peak_ipl_pixel_format.hpp:216
bool IsBayered() const
Returns whether the pixel format is a bayer format.
Definition: peak_ipl_pixel_format.hpp:300
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...
bool operator==(const PixelFormat &other) const
Definition: peak_ipl_pixel_format.hpp:72
size_t NumStorageBitsPerPixel() const
Returns the number of storage bits per pixel of the given pixel format.
Definition: peak_ipl_pixel_format.hpp:252
PEAK_IPL_C_API PEAK_IPL_PixelFormat_IsBayered(PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_BOOL8 *isBayered)
Check if 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.
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:192
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.
std::string ToString(ConversionMode entry)
Definition: peak_ipl_simple_types.hpp:220
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:204
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 supplied format is packed.