ViSP  2.6.2
vpColor.h
1 /****************************************************************************
2  *
3  * $Id: vpColor.h 3530 2012-01-03 10:52:12Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2012 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 
123 class VISP_EXPORT vpColor : public vpRGBa
124 {
125  public:
127  typedef enum {
128  id_black=0,
147  id_unknown
152  } vpColorIdentifier;
153 
158  /* Predefined colors. */
159  static const vpColor black ;
160  static const vpColor white ;
161  static const vpColor lightGray;
162  static const vpColor gray;
163  static const vpColor darkGray;
164  static const vpColor lightRed;
165  static const vpColor red ;
166  static const vpColor darkRed;
167  static const vpColor lightGreen;
168  static const vpColor green;
169  static const vpColor darkGreen;
170  static const vpColor lightBlue;
171  static const vpColor blue ;
172  static const vpColor darkBlue;
173  static const vpColor yellow ;
174  static const vpColor cyan;
175  static const vpColor orange;
176  static const vpColor purple;
177  static const vpColor none;
178 
179  static const unsigned int nbColors;
180  static const vpColor allColors[];
181 
189  inline vpColor()
190  : vpRGBa(), id(id_unknown)
191  {};
202  inline vpColor(unsigned char R, unsigned char G, unsigned char B,
204  : vpRGBa(R, G, B), id(id)
205  {};
206 
218  inline void setColor(unsigned char R, unsigned char G, unsigned char B) {
219  this->R = R;
220  this->G = G;
221  this->B = B;
222  this->A = 0;
223  id = id_unknown;
224  };
225 
232  static inline vpColor getColor(const unsigned int &i) {return vpColor::allColors[i % vpColor::nbColors];};
233 
234 };
235 
243 VISP_EXPORT inline bool operator==( const vpColor &c1, const vpColor &c2 ) {
244  return ( ( c1.R == c2.R ) && ( c1.G == c2.G ) && ( c1.B == c2.B) );
245 }
246 
255 VISP_EXPORT inline bool operator!=( const vpColor &c1, const vpColor &c2 ) {
256  return ( ( c1.R != c2.R ) || ( c1.G != c2.G ) || ( c1.B == c2.B) );
257 }
258 
259 #endif
260 
261 /*
262  * Local variables:
263  * c-basic-offset: 2
264  * End:
265  */
vpColor()
Definition: vpColor.h:189
static const vpColor allColors[]
Definition: vpColor.h:180
void setColor(unsigned char R, unsigned char G, unsigned char B)
Definition: vpColor.h:218
unsigned char B
Blue component.
Definition: vpRGBa.h:155
static const vpColor black
Definition: vpColor.h:159
static const vpColor darkRed
Definition: vpColor.h:166
Class to define colors available for display functionnalities.
Definition: vpColor.h:123
static const vpColor none
Definition: vpColor.h:177
static const vpColor lightGray
Definition: vpColor.h:161
static const vpColor darkBlue
Definition: vpColor.h:172
unsigned char G
Green component.
Definition: vpRGBa.h:154
static const vpColor green
Definition: vpColor.h:168
VISP_EXPORT bool operator!=(const vpImagePoint &ip1, const vpImagePoint &ip2)
Definition: vpImagePoint.h:314
static const vpColor lightRed
Definition: vpColor.h:164
Class that defines a RGB 32 bits structure.
Definition: vpRGBa.h:68
static const vpColor red
Definition: vpColor.h:165
static const vpColor orange
Definition: vpColor.h:175
vpColorIdentifier id
Definition: vpColor.h:154
static const vpColor cyan
Definition: vpColor.h:174
static const vpColor lightGreen
Definition: vpColor.h:167
VISP_EXPORT bool operator==(const vpImagePoint &ip1, const vpImagePoint &ip2)
Definition: vpImagePoint.h:291
vpColorIdentifier
Definition: vpColor.h:127
static const vpColor gray
Definition: vpColor.h:162
static const vpColor darkGray
Definition: vpColor.h:163
vpColor(unsigned char R, unsigned char G, unsigned char B, vpColor::vpColorIdentifier id=vpColor::id_unknown)
Definition: vpColor.h:202
unsigned char R
Red component.
Definition: vpRGBa.h:153
static const vpColor darkGreen
Definition: vpColor.h:169
static vpColor getColor(const unsigned int &i)
Definition: vpColor.h:232
static const vpColor yellow
Definition: vpColor.h:173
static const vpColor lightBlue
Definition: vpColor.h:170
static const vpColor purple
Definition: vpColor.h:176
static const vpColor white
Definition: vpColor.h:160
static const unsigned int nbColors
Definition: vpColor.h:179
static const vpColor blue
Definition: vpColor.h:171