Visual Servoing Platform  version 3.6.1 under development (2025-03-17)
vpRGBf.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4  *
5  * This software is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See https://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * 32-bit floating point RGB pixel.
32  */
33 
40 #ifndef VP_RGBF_H
41 #define VP_RGBF_H
42 
43 #include <visp3/core/vpConfig.h>
44 #include <visp3/core/vpColVector.h>
45 
46 #if ((__cplusplus >= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)))
47 #include <type_traits>
48 #endif
49 
50 BEGIN_VISP_NAMESPACE
51 
63 class VISP_EXPORT vpRGBf
64 {
65 public:
71  inline vpRGBf() : R(0), G(0), B(0) { }
72 
82  inline vpRGBf(float r, float g, float b)
83  : R(r), G(g), B(b)
84  { }
85 
93  VP_EXPLICIT inline vpRGBf(float v) : R(v), G(v), B(v) { }
94 
102  VP_EXPLICIT inline vpRGBf(int v)
103  {
104  *this = v;
105  }
106 
110 #if ((__cplusplus >= 201103L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L))) // Check if cxx11 or higher
111  inline vpRGBf(const vpRGBf &v) = default;
112 #else
113  inline vpRGBf(const vpRGBf &v) : R(v.R), G(v.G), B(v.B) { }
114 #endif
122  VP_EXPLICIT inline vpRGBf(const vpColVector &v) : R(0), G(0), B(0) { *this = v; }
123 
124  vpRGBf &operator=(float v);
125  vpRGBf &operator=(int v);
126 #if ((__cplusplus >= 201103L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L))) // Check if cxx11 or higher
127  vpRGBf &operator=(const vpRGBf &v) = default;
128  vpRGBf &operator=(vpRGBf &&v) = default;
129 #else
130  vpRGBf &operator=(const vpRGBf &v)
131  {
132  this->R = v.R;
133  this->G = v.G;
134  this->B = v.B;
135  return *this;
136  }
137 #endif
138  vpRGBf &operator=(const vpColVector &v);
139  bool operator==(const vpRGBf &v) const;
140  bool operator!=(const vpRGBf &v) const;
141 
142  vpColVector operator-(const vpRGBf &v) const;
143  vpRGBf operator+(const vpRGBf &v) const;
144  vpColVector operator-(const vpColVector &v) const;
145  vpColVector operator+(const vpColVector &v) const;
146  vpColVector operator*(float v) const;
147  vpColVector operator*(double v) const;
148 
149  bool operator<(const vpRGBf &v) const;
150  bool operator>(const vpRGBf &v) const;
151 
152  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRGBf &rgb);
153 
154 public:
155  float R;
156  float G;
157  float B;
158 
159  friend VISP_EXPORT vpRGBf operator*(double x, const vpRGBf &rgb);
160  friend VISP_EXPORT vpRGBf operator*(float x, const vpRGBf &rgb);
161 };
162 
163 #if ((__cplusplus >= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)))
164 static_assert(std::is_trivially_assignable_v<vpRGBf, vpRGBf>);
165 static_assert(std::is_trivially_copyable_v<vpRGBf>);
166 #endif
167 
168 END_VISP_NAMESPACE
169 
170 #endif
Implementation of column vector and the associated operations.
Definition: vpColVector.h:191
Definition: vpRGBf.h:64
vpRGBf()
Definition: vpRGBf.h:71
vpRGBf & operator=(const vpRGBf &v)=default
float B
Blue component.
Definition: vpRGBf.h:157
VP_EXPLICIT vpRGBf(const vpColVector &v)
Definition: vpRGBf.h:122
vpRGBf(float r, float g, float b)
Definition: vpRGBf.h:82
vpRGBf & operator=(vpRGBf &&v)=default
VP_EXPLICIT vpRGBf(int v)
Definition: vpRGBf.h:102
vpRGBf(const vpRGBf &v)=default
VP_EXPLICIT vpRGBf(float v)
Definition: vpRGBf.h:93
float G
Green component.
Definition: vpRGBf.h:156
float R
Red component.
Definition: vpRGBf.h:155
vpMatrix operator*(const double &x, const vpMatrix &A)