IDSpeakIPL  v1.8.0
peak_ipl_gain.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
18 
19 namespace
20 {
21 class GainBackendAccessor;
22 }
23 
27 namespace peak
28 {
29 namespace ipl
30 {
31 
35 class Gain final
36 {
37 public:
44  Gain();
45 
52  ~Gain();
53 
65  Gain(const Gain& other);
66 
78  Gain& operator=(const Gain& other);
79 
88  Gain(Gain&& other) noexcept;
89 
98  Gain& operator=(Gain&& other) noexcept;
99 
109  void SetMasterGainValue(float masterGainValue);
110 
118  PEAK_IPL_NO_DISCARD float MasterGainValue() const;
119 
127  PEAK_IPL_NO_DISCARD float MasterGainMin() const;
128 
136  PEAK_IPL_NO_DISCARD float MasterGainMax() const;
137 
147  void SetRedGainValue(float redGainValue);
148 
156  PEAK_IPL_NO_DISCARD float RedGainValue() const;
157 
165  PEAK_IPL_NO_DISCARD float RedGainMin() const;
166 
174  PEAK_IPL_NO_DISCARD float RedGainMax() const;
175 
185  void SetGreenGainValue(float greenGainValue);
186 
194  PEAK_IPL_NO_DISCARD float GreenGainValue() const;
195 
203  PEAK_IPL_NO_DISCARD float GreenGainMin() const;
204 
212  PEAK_IPL_NO_DISCARD float GreenGainMax() const;
213 
223  void SetBlueGainValue(float blueGainValue);
224 
232  PEAK_IPL_NO_DISCARD float BlueGainValue() const;
233 
241  PEAK_IPL_NO_DISCARD float BlueGainMin() const;
242 
250  PEAK_IPL_NO_DISCARD float BlueGainMax() const;
251 
261  PEAK_IPL_NO_DISCARD bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const;
262 
272  void ProcessInPlace(Image& image) const;
273 
284  PEAK_IPL_NO_DISCARD Image Process(const Image& inputImage) const;
285 
286 private:
287  friend GainBackendAccessor;
288  explicit Gain(PEAK_IPL_GAIN_HANDLE gainHandle) noexcept;
289  PEAK_IPL_GAIN_HANDLE m_backendHandle{};
290 };
291 
292 } /* namespace ipl */
293 } /* namespace peak */
294 
295 namespace
296 {
297 
299 class GainBackendAccessor
300 {
301 public:
309  static PEAK_IPL_GAIN_HANDLE BackendHandle(const peak::ipl::Gain& gain)
310  {
311  return gain.m_backendHandle;
312  }
313 
323  static peak::ipl::Gain CreateGain(PEAK_IPL_GAIN_HANDLE gainHandle)
324  {
325  return peak::ipl::Gain(gainHandle);
326  }
327 };
328 
329 } /* namespace */
330 
331 namespace peak
332 {
333 namespace ipl
334 {
335 inline Gain::Gain()
336 {
338 }
339 
340 inline Gain::Gain(PEAK_IPL_GAIN_HANDLE gainHandle) noexcept
341  : m_backendHandle{ gainHandle }
342 {
343  ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Acquire(m_backendHandle); });
344 }
345 
346 inline Gain::~Gain()
347 {
348  if (m_backendHandle)
349  {
350  (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Destruct(m_backendHandle);
351  }
352 }
353 
354 inline Gain::Gain(Gain&& other) noexcept
355 {
356  *this = std::move(other);
357 }
358 
359 inline Gain::Gain(const Gain& other)
360 {
361  if (other.m_backendHandle)
362  {
363  ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Acquire(other.m_backendHandle); });
364  }
365 
366  m_backendHandle = other.m_backendHandle;
367 }
368 
369 inline Gain& Gain::operator=(const Gain& other)
370 {
371  if (this != &other)
372  {
373  if (m_backendHandle)
374  {
375  (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Destruct(m_backendHandle);
376  }
377 
378  if (other.m_backendHandle)
379  {
380  ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Acquire(other.m_backendHandle); });
381  }
382  }
383 
384  m_backendHandle = other.m_backendHandle;
385 
386  return *this;
387 }
388 
389 inline Gain& Gain::operator=(Gain&& other) noexcept
390 {
391  if (this != &other)
392  {
393  (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Destruct(m_backendHandle);
394  m_backendHandle = other.m_backendHandle;
395  other.m_backendHandle = nullptr;
396  }
397 
398  return *this;
399 }
400 inline void Gain::SetMasterGainValue(float masterGainValue)
401 {
404  m_backendHandle, reinterpret_cast<float*>(&masterGainValue));
405  });
406 }
407 inline float Gain::MasterGainValue() const
408 {
409  float masterGainValue;
410 
413  m_backendHandle, reinterpret_cast<float*>(&masterGainValue));
414  });
415 
416  return masterGainValue;
417 }
418 inline float Gain::MasterGainMin() const
419 {
420  float masterGainMin;
421 
424  m_backendHandle, reinterpret_cast<float*>(&masterGainMin));
425  });
426 
427  return masterGainMin;
428 }
429 inline float Gain::MasterGainMax() const
430 {
431  float masterGainMax;
432 
435  m_backendHandle, reinterpret_cast<float*>(&masterGainMax));
436  });
437 
438  return masterGainMax;
439 }
440 inline void Gain::SetRedGainValue(float redGainValue)
441 {
444  m_backendHandle, reinterpret_cast<float*>(&redGainValue));
445  });
446 }
447 inline float Gain::RedGainValue() const
448 {
449  float redGainValue;
450 
453  m_backendHandle, reinterpret_cast<float*>(&redGainValue));
454  });
455 
456  return redGainValue;
457 }
458 inline float Gain::RedGainMin() const
459 {
460  float redGainMin;
461 
463  return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_GetRedGainMin(m_backendHandle, reinterpret_cast<float*>(&redGainMin));
464  });
465 
466  return redGainMin;
467 }
468 inline float Gain::RedGainMax() const
469 {
470  float redGainMax;
471 
473  return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_GetRedGainMax(m_backendHandle, reinterpret_cast<float*>(&redGainMax));
474  });
475 
476  return redGainMax;
477 }
478 inline void Gain::SetGreenGainValue(float greenGainValue)
479 {
482  m_backendHandle, reinterpret_cast<float*>(&greenGainValue));
483  });
484 }
485 inline float Gain::GreenGainValue() const
486 {
487  float greenGainValue;
488 
491  m_backendHandle, reinterpret_cast<float*>(&greenGainValue));
492  });
493 
494  return greenGainValue;
495 }
496 inline float Gain::GreenGainMin() const
497 {
498  float greenGainMin;
499 
502  m_backendHandle, reinterpret_cast<float*>(&greenGainMin));
503  });
504 
505  return greenGainMin;
506 }
507 inline float Gain::GreenGainMax() const
508 {
509  float greenGainMax;
510 
513  m_backendHandle, reinterpret_cast<float*>(&greenGainMax));
514  });
515 
516  return greenGainMax;
517 }
518 inline void Gain::SetBlueGainValue(float blueGainValue)
519 {
522  m_backendHandle, reinterpret_cast<float*>(&blueGainValue));
523  });
524 }
525 inline float Gain::BlueGainValue() const
526 {
527  float blueGainValue;
528 
531  m_backendHandle, reinterpret_cast<float*>(&blueGainValue));
532  });
533 
534  return blueGainValue;
535 }
536 inline float Gain::BlueGainMin() const
537 {
538  float blueGainMin;
539 
542  m_backendHandle, reinterpret_cast<float*>(&blueGainMin));
543  });
544 
545  return blueGainMin;
546 }
547 inline float Gain::BlueGainMax() const
548 {
549  float blueGainMax;
550 
553  m_backendHandle, reinterpret_cast<float*>(&blueGainMax));
554  });
555 
556  return blueGainMax;
557 }
558 inline bool Gain::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
559 {
560  PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
561 
564  static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
565  reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
566  });
567 
568  return isPixelFormatSupported > 0;
569 }
570 inline void Gain::ProcessInPlace(Image& image) const
571 {
574  m_backendHandle, ImageBackendAccessor::BackendHandle(image));
575  });
576 }
577 inline Image Gain::Process(const Image& inputImage) const
578 {
579  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
582  m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
583  });
584 
585  return ImageBackendAccessor::CreateImage(outputImageHandle);
586 }
587 
588 } /* namespace ipl */
589 } /* namespace peak */
#define PEAK_IPL_NO_DISCARD
Definition: peak_ipl_backend.h:26
PEAK_IPL_C_API PEAK_IPL_Gain_GetMasterGainMin(PEAK_IPL_GAIN_HANDLE gainHandle, float *masterGainMin)
Returns the minimum master gain value which can be set.
PEAK_IPL_NO_DISCARD bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the gain supports the given pixel format.
Definition: peak_ipl_gain.hpp:558
PEAK_IPL_C_API PEAK_IPL_Gain_GetRedGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *redGainValue)
Returns the red gain value.
void SetBlueGainValue(float blueGainValue)
Sets the values of the blue Gain.
Definition: peak_ipl_gain.hpp:518
PEAK_IPL_C_API PEAK_IPL_Gain_SetGreenGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *greenGainValue)
Sets the value of the green gain.
PEAK_IPL_C_API PEAK_IPL_Gain_GetRedGainMin(PEAK_IPL_GAIN_HANDLE gainHandle, float *redGainMin)
Returns the minimum red gain value which can be set.
PEAK_IPL_C_API PEAK_IPL_Gain_GetMasterGainMax(PEAK_IPL_GAIN_HANDLE gainHandle, float *masterGainMax)
Returns the maximum master gain value which can be set.
#define PEAK_IPL_C_ABI_PREFIX
Definition: peak_ipl_dll_defines.h:16
~Gain()
Destructor for the Gain instance.
Definition: peak_ipl_gain.hpp:346
PEAK_IPL_C_API PEAK_IPL_Gain_SetRedGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *redGainValue)
Sets the value of the red gain.
PixelFormatName
Enum holding the possible pixel format names.
Definition: peak_ipl_simple_types.hpp:38
PEAK_IPL_NO_DISCARD float MasterGainValue() const
Returns the value of the master gain.
Definition: peak_ipl_gain.hpp:407
PEAK_IPL_NO_DISCARD float BlueGainMax() const
Returns the maximum value of the blue gain.
Definition: peak_ipl_gain.hpp:547
PEAK_IPL_C_API PEAK_IPL_Gain_GetGreenGainMax(PEAK_IPL_GAIN_HANDLE gainHandle, float *greenGainMax)
Returns the maximum green gain value which can be set.
PEAK_IPL_NO_DISCARD float GreenGainMax() const
Returns the maximum value of the green gain.
Definition: peak_ipl_gain.hpp:507
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
PEAK_IPL_NO_DISCARD float BlueGainMin() const
Returns the minimum value of the blue gain.
Definition: peak_ipl_gain.hpp:536
void ProcessInPlace(Image &image) const
Applies the gain on the given image in place that is, it will change the input image.
Definition: peak_ipl_gain.hpp:570
void SetMasterGainValue(float masterGainValue)
Sets the values of the master Gain.
Definition: peak_ipl_gain.hpp:400
PEAK_IPL_NO_DISCARD float RedGainMin() const
Returns the minimum value of the red gain.
Definition: peak_ipl_gain.hpp:458
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition: peak_ipl_exception.hpp:182
Stores the pixel format, width and height of an image and the pointer to the image buffer...
Definition: peak_ipl_image.hpp:39
void SetGreenGainValue(float greenGainValue)
Sets the values of the green Gain.
Definition: peak_ipl_gain.hpp:478
PEAK_IPL_C_API PEAK_IPL_Gain_GetBlueGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *blueGainValue)
Returns the blue gain value.
PEAK_IPL_NO_DISCARD float GreenGainValue() const
Returns the value of the green gain.
Definition: peak_ipl_gain.hpp:485
PEAK_IPL_C_API PEAK_IPL_Gain_GetBlueGainMax(PEAK_IPL_GAIN_HANDLE gainHandle, float *blueGainMax)
Returns the maximum blue gain value which can be set.
PEAK_IPL_NO_DISCARD float RedGainMax() const
Returns the maximum value of the red gain.
Definition: peak_ipl_gain.hpp:468
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition: peak_ipl_backend.h:354
PEAK_IPL_C_API PEAK_IPL_Gain_Destruct(PEAK_IPL_GAIN_HANDLE gainHandle)
Destroys the gain associated with the given handle.
PEAK_IPL_NO_DISCARD float GreenGainMin() const
Returns the minimum value of the green gain.
Definition: peak_ipl_gain.hpp:496
PEAK_IPL_NO_DISCARD float RedGainValue() const
Returns the value of the red gain.
Definition: peak_ipl_gain.hpp:447
PEAK_IPL_C_API PEAK_IPL_Gain_SetMasterGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *masterGainValue)
Sets the value of the master gain.
PEAK_IPL_C_API PEAK_IPL_Gain_Process(PEAK_IPL_GAIN_HANDLE gainHandle, PEAK_IPL_IMAGE_HANDLE imageHandle, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Apply the gain on the given image.
PEAK_IPL_C_API PEAK_IPL_Gain_GetIsPixelFormatSupported(PEAK_IPL_GAIN_HANDLE gainHandle, PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_BOOL8 *isPixelFormatSupported)
Asks the given gamma corrector whether it supports the given pixel format.
PEAK_IPL_C_API PEAK_IPL_Gain_Construct(PEAK_IPL_GAIN_HANDLE *gainHandle)
Creates a gain.
struct PEAK_IPL_GAIN * PEAK_IPL_GAIN_HANDLE
Definition: peak_ipl_backend.h:346
PEAK_IPL_C_API PEAK_IPL_Gain_GetGreenGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *greenGainValue)
Returns the green gain value.
PEAK_IPL_C_API PEAK_IPL_Gain_GetGreenGainMin(PEAK_IPL_GAIN_HANDLE gainHandle, float *greenGainMin)
Returns the minimum green gain value which can be set.
int8_t PEAK_IPL_BOOL8
Definition: peak_ipl_backend.h:41
PEAK_IPL_NO_DISCARD float MasterGainMax() const
Returns the maximum value of the master gain.
Definition: peak_ipl_gain.hpp:429
Gain()
Constructor for a new Gain instance.
Definition: peak_ipl_gain.hpp:335
PEAK_IPL_NO_DISCARD Image Process(const Image &inputImage) const
Applies the gain on the given image.
Definition: peak_ipl_gain.hpp:577
PEAK_IPL_C_API PEAK_IPL_Gain_SetBlueGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *blueGainValue)
Sets the value of the blue gain.
PEAK_IPL_C_API PEAK_IPL_Gain_GetMasterGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *masterGainValue)
Returns the master gain value.
PEAK_IPL_C_API PEAK_IPL_Gain_GetRedGainMax(PEAK_IPL_GAIN_HANDLE gainHandle, float *redGainMax)
Returns the maximum red gain value which can be set.
Applies gain to the data.
Definition: peak_ipl_gain.hpp:35
Gain & operator=(const Gain &other)
Copy assigment for Gain instance.
Definition: peak_ipl_gain.hpp:369
PEAK_IPL_C_API PEAK_IPL_Gain_ProcessInPlace(PEAK_IPL_GAIN_HANDLE gainHandle, PEAK_IPL_IMAGE_HANDLE imageHandle)
Apply the gain on the given image.
PEAK_IPL_C_API PEAK_IPL_Gain_GetBlueGainMin(PEAK_IPL_GAIN_HANDLE gainHandle, float *blueGainMin)
Returns the minimum blue gain value which can be set.
PEAK_IPL_NO_DISCARD float MasterGainMin() const
Returns the minimum value of the master gain.
Definition: peak_ipl_gain.hpp:418
PEAK_IPL_C_API PEAK_IPL_Gain_Acquire(PEAK_IPL_GAIN_HANDLE gainHandle)
Increase the reference count of a gain object.
PEAK_IPL_NO_DISCARD float BlueGainValue() const
Returns the value of the blue gain.
Definition: peak_ipl_gain.hpp:525
void SetRedGainValue(float redGainValue)
Sets the values of the red Gain.
Definition: peak_ipl_gain.hpp:440