ViSP
 All Classes Functions Variables Enumerations Enumerator Friends Groups Pages
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  */