Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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/base/link_pragmas.h>
15 #include <iosfwd>
16 
17 namespace mrpt
18 {
19  namespace utils
20  {
21  class CStream;
22 
23  /** A RGB color - 8bit
24  * \ingroup mrpt_base_grp */
26  {
27  inline TColor() : R(0),G(0),B(0),A(255) { }
28  inline TColor(uint8_t r,uint8_t g,uint8_t b, uint8_t alpha=255) : R(r),G(g),B(b),A(alpha) { }
29  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) { }
30  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) { }
31  uint8_t R,G,B,A;
32 
33  /** Operator for implicit conversion into an int binary representation 0xRRGGBB */
34  inline operator unsigned int(void) const { return (((unsigned int)R)<<16) | (((unsigned int)G)<<8) | B; }
35 
36  static TColor red; //!< Predefined colors
37  static TColor green;//!< Predefined colors
38  static TColor blue;//!< Predefined colors
39  static TColor white;//!< Predefined colors
40  static TColor black;//!< Predefined colors
41  static TColor gray; //!< Predefined colors
42  };
43  // Text streaming:
44  std::ostream BASE_IMPEXP & operator << (std::ostream& o, const TColor & c);
45  // Binary streaming:
48 
49 
50  /** A RGB color - floats in the range [0,1]
51  * \ingroup mrpt_base_grp */
53  {
54  TColorf(float r=0,float g=0,float b=0, float alpha=1.0f) : R(r),G(g),B(b),A(alpha) { }
55  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)) { }
56  float R,G,B,A;
57  };
58  // Text streaming:
59  std::ostream BASE_IMPEXP & operator << (std::ostream& o, const TColorf & c);
60  // Binary streaming:
63 
64  } // end namespace
65 }
66 
67 #endif
68 
CStream BASE_IMPEXP & operator<<(mrpt::utils::CStream &s, const char *a)
static TColor green
Predefined colors.
Definition: TColor.h:37
TColorf(float r=0, float g=0, float b=0, float alpha=1.0f)
Definition: TColor.h:54
static TColor gray
Predefined colors.
Definition: TColor.h:41
static TColor white
Predefined colors.
Definition: TColor.h:39
::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:38
A RGB color - 8bit.
Definition: TColor.h:25
TColor(const unsigned int color_RGB_24bit, const uint8_t alpha)
Definition: TColor.h:30
static TColor red
Predefined colors.
Definition: TColor.h:36
TColor(uint8_t r, uint8_t g, uint8_t b, uint8_t alpha=255)
Definition: TColor.h:28
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
TColorf(const TColor &col)
Definition: TColor.h:55
A RGB color - floats in the range [0,1].
Definition: TColor.h:52
TColor(const unsigned int color_RGB_24bit)
Definition: TColor.h:29
static TColor blue
Predefined colors.
Definition: TColor.h:38
static TColor black
Predefined colors.
Definition: TColor.h:40



Page generated by Doxygen 1.8.13 for MRPT 1.4.0 SVN: at Wed Mar 15 00:43:31 UTC 2017