Visual Servoing Platform  version 3.6.1 under development (2024-04-16)
vpRGBa.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2023 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  * RGBA pixel.
32  */
33 
34 #ifndef vpRGBa_h
35 #define vpRGBa_h
36 
43 #include <visp3/core/vpColVector.h>
44 
60 class VISP_EXPORT vpRGBa
61 {
62 public:
63  enum AlphaDefault { alpha_default = 255 };
64 
70  inline vpRGBa() : R(0), G(0), B(0), A(vpRGBa::alpha_default) { }
71 
82  inline vpRGBa(unsigned char r, unsigned char g, unsigned char b, unsigned char a = vpRGBa::alpha_default)
83  : R(r), G(g), B(b), A(a)
84  { }
85 
93  inline vpRGBa(unsigned char v) : R(v), G(v), B(v), A(v) { }
94 
98  inline vpRGBa(const vpRGBa &v) : R(v.R), G(v.G), B(v.B), A(v.A) { }
99 
108  inline vpRGBa(const vpColVector &v) : R(0), G(0), B(0), A(vpRGBa::alpha_default) { *this = v; }
109 
110  // We cannot add here the following destructor without changing the
111  // hypothesis that the size of this class is 4. With the destructor it
112  // becomes 16 that does break a lot of things around image conversions
113  // virtual ~vpRGBa() {}; // Not to implement
114 
115  vpRGBa &operator=(const unsigned char &v);
116  vpRGBa &operator=(const vpRGBa &v);
117 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
118  vpRGBa &operator=(const vpRGBa &&v);
119 #endif
120  vpRGBa &operator=(const vpColVector &v);
121  bool operator==(const vpRGBa &v) const;
122  bool operator!=(const vpRGBa &v) const;
123 
124  vpColVector operator-(const vpRGBa &v) const;
125  vpRGBa operator+(const vpRGBa &v) const;
126  vpColVector operator-(const vpColVector &v) const;
127  vpColVector operator+(const vpColVector &v) const;
128  vpColVector operator*(const float &v) const;
129  vpColVector operator*(const double &v) const;
130 
131  bool operator<(const vpRGBa &v) const;
132  bool operator>(const vpRGBa &v) const;
133 
134  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRGBa &rgba);
135 
136 public:
137  unsigned char R;
138  unsigned char G;
139  unsigned char B;
140  unsigned char A;
141 
142  friend VISP_EXPORT vpRGBa operator*(const double &x, const vpRGBa &rgb);
143 };
144 
145 #endif
Implementation of column vector and the associated operations.
Definition: vpColVector.h:163
Definition: vpRGBa.h:61
vpRGBa(const vpColVector &v)
Definition: vpRGBa.h:108
unsigned char B
Blue component.
Definition: vpRGBa.h:139
vpRGBa(unsigned char r, unsigned char g, unsigned char b, unsigned char a=vpRGBa::alpha_default)
Definition: vpRGBa.h:82
unsigned char R
Red component.
Definition: vpRGBa.h:137
vpRGBa(const vpRGBa &v)
Definition: vpRGBa.h:98
vpRGBa()
Definition: vpRGBa.h:70
vpRGBa(unsigned char v)
Definition: vpRGBa.h:93
unsigned char G
Green component.
Definition: vpRGBa.h:138
AlphaDefault
Definition: vpRGBa.h:63
@ alpha_default
Definition: vpRGBa.h:63
unsigned char A
Additionnal component.
Definition: vpRGBa.h:140
vpMatrix operator*(const double &x, const vpMatrix &A)