Visual Servoing Platform version 3.5.0
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
66class VISP_EXPORT vpRGBa
67{
68public:
69 enum AlphaDefault { alpha_default = 255 };
70
77 inline vpRGBa() : R(0), G(0), B(0), A(vpRGBa::alpha_default) {}
78
90 inline vpRGBa(unsigned char r, unsigned char g, unsigned char b, unsigned char a = vpRGBa::alpha_default)
91 : R(r), G(g), B(b), A(a)
92 {
93 }
94
103 inline vpRGBa(unsigned char v) : R(v), G(v), B(v), A(v) {}
104
108 inline vpRGBa(const vpRGBa &v) : R(v.R), G(v.G), B(v.B), A(v.A) {}
109
119 inline vpRGBa(const vpColVector &v) : R(0), G(0), B(0), A(vpRGBa::alpha_default) { *this = v; }
120
121 // We cannot add here the following destructor without changing the
122 // hypothesis that the size of this class is 4. With the destructor it
123 // becomes 16 that does break a lot of things arround image conversions
124 // virtual ~vpRGBa() {}; // Not to implement
125
126 vpRGBa &operator=(const unsigned char &v);
127 vpRGBa &operator=(const vpRGBa &v);
128#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
129 vpRGBa &operator=(const vpRGBa &&v);
130#endif
131 vpRGBa &operator=(const vpColVector &v);
132 bool operator==(const vpRGBa &v);
133 bool operator!=(const vpRGBa &v);
134
135 vpColVector operator-(const vpRGBa &v) const;
136 vpRGBa operator+(const vpRGBa &v) const;
137 vpColVector operator-(const vpColVector &v) const;
138 vpColVector operator+(const vpColVector &v) const;
139 vpColVector operator*(const float &v) const;
140 vpColVector operator*(const double &v) const;
141
142 bool operator<(const vpRGBa &v) const;
143 bool operator>(const vpRGBa &v) const;
144
145 friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRGBa &rgba);
146
147public:
148 unsigned char R;
149 unsigned char G;
150 unsigned char B;
151 unsigned char A;
152
153 friend VISP_EXPORT vpRGBa operator*(const double &x, const vpRGBa &rgb);
154};
155
156#endif
Implementation of column vector and the associated operations.
Definition: vpColVector.h:131
Definition: vpRGBa.h:67
vpRGBa(const vpColVector &v)
Definition: vpRGBa.h:119
unsigned char B
Blue component.
Definition: vpRGBa.h:150
vpRGBa(unsigned char r, unsigned char g, unsigned char b, unsigned char a=vpRGBa::alpha_default)
Definition: vpRGBa.h:90
unsigned char R
Red component.
Definition: vpRGBa.h:148
vpRGBa(const vpRGBa &v)
Definition: vpRGBa.h:108
vpRGBa()
Definition: vpRGBa.h:77
vpRGBa(unsigned char v)
Definition: vpRGBa.h:103
unsigned char G
Green component.
Definition: vpRGBa.h:149
AlphaDefault
Definition: vpRGBa.h:69
@ alpha_default
Definition: vpRGBa.h:69
unsigned char A
Additionnal component.
Definition: vpRGBa.h:151
vpColVector operator*(const double &x, const vpColVector &v)