Main MRPT website > C++ reference
MRPT logo
TColor.h
Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                       http://www.mrpt.org/                                |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 
00029 #ifndef mrpt_utils_tcolor_H
00030 #define mrpt_utils_tcolor_H
00031 
00032 #include <mrpt/utils/mrpt_stdint.h>    // compiler-independent version of "stdint.h"
00033 #include <mrpt/utils/mrpt_inttypes.h>  // compiler-independent version of "inttypes.h"
00034 
00035 namespace mrpt
00036 {
00037         namespace utils
00038         {
00039 
00040                 /** A RGB color - 8bit 
00041                  * \ingroup mrpt_base_grp */
00042                 struct BASE_IMPEXP TColor
00043                 {
00044                         inline TColor() : R(0),G(0),B(0),A(255) { }
00045                         inline TColor(uint8_t r,uint8_t g,uint8_t b, uint8_t alpha=255) : R(r),G(g),B(b),A(alpha) { }
00046                         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) { }
00047                         uint8_t  R,G,B,A;
00048 
00049                         /** Operator for implicit conversion into an int binary representation 0xRRGGBB */
00050                         inline operator unsigned int(void) const { return (((unsigned int)R)<<16) | (((unsigned int)G)<<8) | B; }
00051 
00052                         static TColor red; //!< Predefined colors
00053                         static TColor green;//!< Predefined colors
00054                         static TColor blue;//!< Predefined colors
00055                         static TColor white;//!< Predefined colors
00056                         static TColor black;//!< Predefined colors
00057                         static TColor gray;     //!< Predefined colors
00058                 };
00059 
00060                 /** A RGB color - floats in the range [0,1] 
00061                  * \ingroup mrpt_base_grp */
00062                 struct BASE_IMPEXP TColorf
00063                 {
00064                         TColorf(float r=0,float g=0,float b=0, float alpha=1.0f) : R(r),G(g),B(b),A(alpha) { }
00065                         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)) { }
00066                         float R,G,B,A;
00067                 };
00068 
00069         } // end namespace
00070 }
00071 
00072 #endif
00073 



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011