Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
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
60class VISP_EXPORT vpRGBa
61{
62public:
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 }
86
94 inline vpRGBa(unsigned char v) : R(v), G(v), B(v), A(v) {}
95
99 inline vpRGBa(const vpRGBa &v) : R(v.R), G(v.G), B(v.B), A(v.A) {}
100
109 inline vpRGBa(const vpColVector &v) : R(0), G(0), B(0), A(vpRGBa::alpha_default) { *this = v; }
110
111 // We cannot add here the following destructor without changing the
112 // hypothesis that the size of this class is 4. With the destructor it
113 // becomes 16 that does break a lot of things around image conversions
114 // virtual ~vpRGBa() {}; // Not to implement
115
116 vpRGBa &operator=(const unsigned char &v);
117 vpRGBa &operator=(const vpRGBa &v);
118#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
119 vpRGBa &operator=(const vpRGBa &&v);
120#endif
121 vpRGBa &operator=(const vpColVector &v);
122 bool operator==(const vpRGBa &v) const;
123 bool operator!=(const vpRGBa &v) const;
124
125 vpColVector operator-(const vpRGBa &v) const;
126 vpRGBa operator+(const vpRGBa &v) const;
127 vpColVector operator-(const vpColVector &v) const;
128 vpColVector operator+(const vpColVector &v) const;
129 vpColVector operator*(const float &v) const;
130 vpColVector operator*(const double &v) const;
131
132 bool operator<(const vpRGBa &v) const;
133 bool operator>(const vpRGBa &v) const;
134
135 friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRGBa &rgba);
136
137public:
138 unsigned char R;
139 unsigned char G;
140 unsigned char B;
141 unsigned char A;
142
143 friend VISP_EXPORT vpRGBa operator*(const double &x, const vpRGBa &rgb);
144};
145
146#endif
Implementation of column vector and the associated operations.
vpRGBa(const vpColVector &v)
Definition vpRGBa.h:109
unsigned char B
Blue component.
Definition vpRGBa.h:140
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:138
vpRGBa(const vpRGBa &v)
Definition vpRGBa.h:99
vpRGBa()
Definition vpRGBa.h:70
vpRGBa(unsigned char v)
Definition vpRGBa.h:94
unsigned char G
Green component.
Definition vpRGBa.h:139
AlphaDefault
Definition vpRGBa.h:63
@ alpha_default
Definition vpRGBa.h:63
unsigned char A
Additionnal component.
Definition vpRGBa.h:141
vpColVector operator*(const double &x, const vpColVector &v)