ViSP  2.8.0
vpColor.h
1 /****************************************************************************
2  *
3  * $Id: vpColor.h 4243 2013-05-07 07:58:55Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Color definition.
36  *
37  * Authors:
38  * Eric Marchand
39  * Fabien Spindler
40  *
41  *****************************************************************************/
42 
43 
44 #ifndef vpColor_hh
45 #define vpColor_hh
46 
47 
48 #include <visp/vpConfig.h>
49 #include <visp/vpRGBa.h>
50 
125 class VISP_EXPORT vpColor : public vpRGBa
126 {
127  public:
129  typedef enum {
130  id_black=0,
149  id_unknown
154  } vpColorIdentifier;
155 
160  /* Predefined colors. */
161  static const vpColor black ;
162  static const vpColor white ;
163  static const vpColor lightGray;
164  static const vpColor gray;
165  static const vpColor darkGray;
166  static const vpColor lightRed;
167  static const vpColor red ;
168  static const vpColor darkRed;
169  static const vpColor lightGreen;
170  static const vpColor green;
171  static const vpColor darkGreen;
172  static const vpColor lightBlue;
173  static const vpColor blue ;
174  static const vpColor darkBlue;
175  static const vpColor yellow ;
176  static const vpColor cyan;
177  static const vpColor orange;
178  static const vpColor purple;
179  static const vpColor none;
180 
181  static const unsigned int nbColors;
182  static const vpColor allColors[];
183 
191  inline vpColor()
192  : vpRGBa(), id(id_unknown)
193  {};
204  inline vpColor(unsigned char R, unsigned char G, unsigned char B,
206  : vpRGBa(R, G, B), id(id)
207  {};
208 
220  inline void setColor(unsigned char R, unsigned char G, unsigned char B) {
221  this->R = R;
222  this->G = G;
223  this->B = B;
224  this->A = 0;
225  id = id_unknown;
226  };
227 
234  static inline vpColor getColor(const unsigned int &i) {return vpColor::allColors[i % vpColor::nbColors];};
235 
236 };
237 
245 VISP_EXPORT inline bool operator==( const vpColor &c1, const vpColor &c2 ) {
246  return ( ( c1.R == c2.R ) && ( c1.G == c2.G ) && ( c1.B == c2.B) );
247 }
248 
257 VISP_EXPORT inline bool operator!=( const vpColor &c1, const vpColor &c2 ) {
258  return ( ( c1.R != c2.R ) || ( c1.G != c2.G ) || ( c1.B == c2.B) );
259 }
260 
261 #endif
262 
263 /*
264  * Local variables:
265  * c-basic-offset: 2
266  * End:
267  */
vpColor()
Definition: vpColor.h:191
static const vpColor allColors[]
Definition: vpColor.h:182
void setColor(unsigned char R, unsigned char G, unsigned char B)
Definition: vpColor.h:220
unsigned char B
Blue component.
Definition: vpRGBa.h:155
static const vpColor black
Definition: vpColor.h:161
static const vpColor darkRed
Definition: vpColor.h:168
Class to define colors available for display functionnalities.
Definition: vpColor.h:125
static const vpColor none
Definition: vpColor.h:179
static const vpColor lightGray
Definition: vpColor.h:163
static const vpColor darkBlue
Definition: vpColor.h:174
unsigned char G
Green component.
Definition: vpRGBa.h:154
static const vpColor green
Definition: vpColor.h:170
VISP_EXPORT bool operator!=(const vpImagePoint &ip1, const vpImagePoint &ip2)
Definition: vpImagePoint.h:314
static const vpColor lightRed
Definition: vpColor.h:166
Class that defines a RGB 32 bits structure.
Definition: vpRGBa.h:68
static const vpColor red
Definition: vpColor.h:167
static const vpColor orange
Definition: vpColor.h:177
vpColorIdentifier id
Definition: vpColor.h:156
static const vpColor cyan
Definition: vpColor.h:176
static const vpColor lightGreen
Definition: vpColor.h:169
VISP_EXPORT bool operator==(const vpImagePoint &ip1, const vpImagePoint &ip2)
Definition: vpImagePoint.h:291
vpColorIdentifier
Definition: vpColor.h:129
static const vpColor gray
Definition: vpColor.h:164
static const vpColor darkGray
Definition: vpColor.h:165
vpColor(unsigned char R, unsigned char G, unsigned char B, vpColor::vpColorIdentifier id=vpColor::id_unknown)
Definition: vpColor.h:204
unsigned char R
Red component.
Definition: vpRGBa.h:153
static const vpColor darkGreen
Definition: vpColor.h:171
static vpColor getColor(const unsigned int &i)
Definition: vpColor.h:234
static const vpColor yellow
Definition: vpColor.h:175
static const vpColor lightBlue
Definition: vpColor.h:172
static const vpColor purple
Definition: vpColor.h:178
static const vpColor white
Definition: vpColor.h:162
static const unsigned int nbColors
Definition: vpColor.h:181
static const vpColor blue
Definition: vpColor.h:173