Main MRPT website > C++ reference
MRPT logo
TColor.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2014, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #ifndef mrpt_utils_tcolor_H
11 #define mrpt_utils_tcolor_H
12 
13 #include <mrpt/utils/mrpt_stdint.h> // compiler-independent version of "stdint.h"
14 #include <mrpt/utils/mrpt_inttypes.h> // compiler-independent version of "inttypes.h"
15 
16 namespace mrpt
17 {
18  namespace utils
19  {
20  class CStream;
21 
22  /** A RGB color - 8bit
23  * \ingroup mrpt_base_grp */
25  {
26  inline TColor() : R(0),G(0),B(0),A(255) { }
27  inline TColor(uint8_t r,uint8_t g,uint8_t b, uint8_t alpha=255) : R(r),G(g),B(b),A(alpha) { }
28  inline explicit TColor(const unsigned int color_RGB_24bit) : R(uint8_t(color_RGB_24bit>>16)),G(uint8_t(color_RGB_24bit>>8)),B(uint8_t(color_RGB_24bit)),A(255) { }
29  inline TColor(const unsigned int color_RGB_24bit, const uint8_t alpha) : R(uint8_t(color_RGB_24bit>>16)),G(uint8_t(color_RGB_24bit>>8)),B(uint8_t(color_RGB_24bit)),A(alpha) { }
30  uint8_t R,G,B,A;
31 
32  /** Operator for implicit conversion into an int binary representation 0xRRGGBB */
33  inline operator unsigned int(void) const { return (((unsigned int)R)<<16) | (((unsigned int)G)<<8) | B; }
34 
35  static TColor red; //!< Predefined colors
36  static TColor green;//!< Predefined colors
37  static TColor blue;//!< Predefined colors
38  static TColor white;//!< Predefined colors
39  static TColor black;//!< Predefined colors
40  static TColor gray; //!< Predefined colors
41  };
42  // Text streaming:
43  std::ostream BASE_IMPEXP & operator << (std::ostream& o, const TColor & c);
44  // Binary streaming:
47 
48 
49  /** A RGB color - floats in the range [0,1]
50  * \ingroup mrpt_base_grp */
52  {
53  TColorf(float r=0,float g=0,float b=0, float alpha=1.0f) : R(r),G(g),B(b),A(alpha) { }
54  explicit TColorf(const TColor &col) : R(col.R*(1.f/255)),G(col.G*(1.f/255)),B(col.B*(1.f/255)),A(col.A*(1.f/255)) { }
55  float R,G,B,A;
56  };
57  // Text streaming:
58  std::ostream BASE_IMPEXP & operator << (std::ostream& o, const TColorf & c);
59  // Binary streaming:
62 
63  } // end namespace
64 }
65 
66 #endif
67 
static TColor green
Predefined colors.
Definition: TColor.h:36
TColorf(float r=0, float g=0, float b=0, float alpha=1.0f)
Definition: TColor.h:53
static TColor gray
Predefined colors.
Definition: TColor.h:40
class BASE_IMPEXP CStream
Definition: math_frwds.h:28
static TColor white
Predefined colors.
Definition: TColor.h:38
::mrpt::utils::CStream & operator>>(mrpt::utils::CStream &in, CImagePtr &pObj)
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:36
A RGB color - 8bit.
Definition: TColor.h:24
TColor(const unsigned int color_RGB_24bit, const uint8_t alpha)
Definition: TColor.h:29
static TColor red
Predefined colors.
Definition: TColor.h:35
TColor(uint8_t r, uint8_t g, uint8_t b, uint8_t alpha=255)
Definition: TColor.h:27
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
CStream BASE_IMPEXP & operator<<(CStream &s, const char *a)
TColorf(const TColor &col)
Definition: TColor.h:54
A RGB color - floats in the range [0,1].
Definition: TColor.h:51
TColor(const unsigned int color_RGB_24bit)
Definition: TColor.h:28
static TColor blue
Predefined colors.
Definition: TColor.h:37
static TColor black
Predefined colors.
Definition: TColor.h:39



Page generated by Doxygen 1.8.14 for MRPT 1.1.0 SVN: at lun oct 28 00:54:49 CET 2019 Hosted on:
SourceForge.net Logo