Visual Servoing Platform  version 3.5.1 under development (2023-05-30)
vpRGBa.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * RGBA pixel.
33  *
34  * Authors:
35  * Eric Marchand
36  * Fabien Spindler
37  *
38  *****************************************************************************/
39 
40 #ifndef vpRGBa_h
41 #define vpRGBa_h
42 
49 #include <visp3/core/vpColVector.h>
50 
66 class VISP_EXPORT vpRGBa
67 {
68 public:
69  enum AlphaDefault { alpha_default = 255 };
70 
76  inline vpRGBa() : R(0), G(0), B(0), A(vpRGBa::alpha_default) {}
77 
88  inline vpRGBa(unsigned char r, unsigned char g, unsigned char b, unsigned char a = vpRGBa::alpha_default)
89  : R(r), G(g), B(b), A(a)
90  {
91  }
92 
100  inline vpRGBa(unsigned char v) : R(v), G(v), B(v), A(v) {}
101 
105  inline vpRGBa(const vpRGBa &v) : R(v.R), G(v.G), B(v.B), A(v.A) {}
106 
115  inline vpRGBa(const vpColVector &v) : R(0), G(0), B(0), A(vpRGBa::alpha_default) { *this = v; }
116 
117  // We cannot add here the following destructor without changing the
118  // hypothesis that the size of this class is 4. With the destructor it
119  // becomes 16 that does break a lot of things around image conversions
120  // virtual ~vpRGBa() {}; // Not to implement
121 
122  vpRGBa &operator=(const unsigned char &v);
123  vpRGBa &operator=(const vpRGBa &v);
124 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
125  vpRGBa &operator=(const vpRGBa &&v);
126 #endif
127  vpRGBa &operator=(const vpColVector &v);
128  bool operator==(const vpRGBa &v) const;
129  bool operator!=(const vpRGBa &v) const;
130 
131  vpColVector operator-(const vpRGBa &v) const;
132  vpRGBa operator+(const vpRGBa &v) const;
133  vpColVector operator-(const vpColVector &v) const;
134  vpColVector operator+(const vpColVector &v) const;
135  vpColVector operator*(const float &v) const;
136  vpColVector operator*(const double &v) const;
137 
138  bool operator<(const vpRGBa &v) const;
139  bool operator>(const vpRGBa &v) const;
140 
141  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRGBa &rgba);
142 
143 public:
144  unsigned char R;
145  unsigned char G;
146  unsigned char B;
147  unsigned char A;
148 
149  friend VISP_EXPORT vpRGBa operator*(const double &x, const vpRGBa &rgb);
150 };
151 
152 #endif
Implementation of column vector and the associated operations.
Definition: vpColVector.h:172
Definition: vpRGBa.h:67
vpRGBa(const vpColVector &v)
Definition: vpRGBa.h:115
unsigned char B
Blue component.
Definition: vpRGBa.h:146
vpRGBa(unsigned char r, unsigned char g, unsigned char b, unsigned char a=vpRGBa::alpha_default)
Definition: vpRGBa.h:88
unsigned char R
Red component.
Definition: vpRGBa.h:144
vpRGBa(const vpRGBa &v)
Definition: vpRGBa.h:105
vpRGBa()
Definition: vpRGBa.h:76
vpRGBa(unsigned char v)
Definition: vpRGBa.h:100
unsigned char G
Green component.
Definition: vpRGBa.h:145
AlphaDefault
Definition: vpRGBa.h:69
@ alpha_default
Definition: vpRGBa.h:69
unsigned char A
Additionnal component.
Definition: vpRGBa.h:147
vpColVector operator*(const double &x, const vpColVector &v)