Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpRGBa.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
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 http://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  * Authors:
34  * Eric Marchand
35  * Fabien Spindler
36  *
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 {
70  alpha_default = 255
71  };
72 
79  inline vpRGBa() : R(0), G(0), B(0), A(vpRGBa::alpha_default) {}
80 
92  inline vpRGBa(const unsigned char &r, const unsigned char &g,
93  const unsigned char &b, const unsigned char &a=0)
94  : R(r), G(g), B(b), A(a) {}
95 
96 
105  inline vpRGBa(const unsigned char &v) : R(v), G(v), B(v), A(v) {}
106 
107 
111  inline vpRGBa(const vpRGBa &v) : R(v.R), G(v.G), B(v.B), A(v.A) {}
112 
122  inline vpRGBa(const vpColVector &v) : R(0), G(0), B(0), A(vpRGBa::alpha_default)
123  {
124  *this = v;
125  }
126 
127  // We cannot add here the following destructor without changing the hypothesis that the size of this class is 4.
128  // With the destructor it becomes 16 that does break a lot of things arround image conversions
129  // virtual ~vpRGBa() {}; // Not to implement
130 
131  vpRGBa & operator=(const unsigned char &v) ;
132  vpRGBa & operator=(const vpRGBa &v) ;
133 #ifdef VISP_HAVE_CPP11_COMPATIBILITY
134  vpRGBa & operator=(const vpRGBa &&v);
135 #endif
136  vpRGBa & operator=(const vpColVector &v) ;
137  bool operator==(const vpRGBa &v);
138  bool operator!=(const vpRGBa &v);
139 
140  vpColVector operator-(const vpRGBa &v) const;
141  vpRGBa operator+(const vpRGBa &v) const;
142  vpColVector operator-(const vpColVector &v) const;
143  vpColVector operator+(const vpColVector &v) const;
144  vpColVector operator*(const float &v) const;
145  vpColVector operator*(const double &v) const;
146 
147  bool operator<(const vpRGBa &v) const;
148  bool operator>(const vpRGBa &v) const;
149 
150  friend VISP_EXPORT std::ostream& operator<< (std::ostream &os, const vpRGBa& rgba);
151 
152  public:
153  unsigned char R ;
154  unsigned char G ;
155  unsigned char B ;
156  unsigned char A ;
157 
158  friend VISP_EXPORT vpRGBa operator*(const double &x, const vpRGBa &rgb);
159 
160 } ;
161 
162 #endif
163 
vpRGBa(const unsigned char &r, const unsigned char &g, const unsigned char &b, const unsigned char &a=0)
Definition: vpRGBa.h:92
unsigned char B
Blue component.
Definition: vpRGBa.h:155
vpRGBa()
Definition: vpRGBa.h:79
AlphaDefault
Definition: vpRGBa.h:69
unsigned char G
Green component.
Definition: vpRGBa.h:154
vpRGBa(const vpRGBa &v)
Definition: vpRGBa.h:111
Definition: vpRGBa.h:66
vpColVector operator*(const double &x, const vpColVector &v)
vpRGBa(const vpColVector &v)
Definition: vpRGBa.h:122
unsigned char A
Additionnal component.
Definition: vpRGBa.h:156
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
unsigned char R
Red component.
Definition: vpRGBa.h:153
vpRGBa(const unsigned char &v)
Definition: vpRGBa.h:105