rgb.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 1996-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 
00019 #if !defined RGB_HEADER
00020 #define RGB_HEADER
00021 
00025 
00027 class WHIPTK_API WT_RGB {
00028     public:
00029         unsigned char   m_red; 
00030         unsigned char   m_green; 
00031         unsigned char   m_blue; 
00033 
00034         WT_RGB () : m_red(0), m_green(0), m_blue(0) {}
00035 
00037         WT_RGB (WT_RGB const & in)
00038           : m_red   (in.m_red)
00039           , m_green (in.m_green)
00040           , m_blue  (in.m_blue)
00041         { }
00042 
00044 
00046         WT_RGB (int red, int green, int blue)
00047           : m_red   (static_cast<unsigned char>(red))
00048           , m_green (static_cast<unsigned char>(green))
00049           , m_blue  (static_cast<unsigned char>(blue))
00050         { }
00051 
00053 
00056         WT_RGB (float const & red, float const & green, float const & blue)
00057           : m_red   ((unsigned char)(red   * 255.99))
00058           , m_green ((unsigned char)(green * 255.99))
00059           , m_blue  ((unsigned char)(blue  * 255.99))
00060         { }
00061 
00063         WT_Boolean operator== (WT_RGB const & test) const
00064         {
00065             return (m_red   == test.m_red   &&
00066                     m_green == test.m_green &&
00067                     m_blue  == test.m_blue     );
00068         }
00069 
00071         WT_Boolean operator!= (WT_RGB const & test) const
00072         {
00073             return (m_red   != test.m_red   ||
00074                     m_green != test.m_green ||
00075                     m_blue  != test.m_blue     );
00076         }
00077 
00079         WT_RGB const & operator= (WT_RGB const & in)
00080         {
00081             m_red   = in.m_red;
00082             m_green = in.m_green;
00083             m_blue  = in.m_blue;
00084             return *this;
00085         }
00086 };
00087 
00089 class WHIPTK_API WT_RGBA32 {
00090     public:
00092         union
00093         {
00094             WT_Integer32        m_whole;
00096             struct
00097             {
00098                 unsigned char   WD_PREFERRED_RGB32;
00099             } m_rgb;
00100         };
00101 
00103         WT_RGBA32 ()
00104           : m_whole(0)
00105         { }
00106 
00108         WT_RGBA32 (WT_RGBA32 const & in)
00109           : m_whole (in.m_whole)
00110         { }
00111 
00113 
00115         WT_RGBA32 (int red, int green, int blue, int alpha = 0xFF) {
00116             m_rgb.r = static_cast<unsigned char>(red);
00117             m_rgb.g = static_cast<unsigned char>(green);
00118             m_rgb.b = static_cast<unsigned char>(blue);
00119             m_rgb.a = static_cast<unsigned char>(alpha);
00120         }
00122 
00125         WT_RGBA32 (float const & red, float const & green, float const & blue, float alpha = 1.0f) {
00126             m_rgb.r = (unsigned char) (red   * 255.99);
00127             m_rgb.g = (unsigned char) (green * 255.99);
00128             m_rgb.b = (unsigned char) (blue  * 255.99);
00129             m_rgb.a = (unsigned char) (alpha * 255.99);
00130         }
00131 
00132 
00134         WT_Boolean operator== (WT_RGBA32 const & test) const
00135                         {return m_whole == test.m_whole;}
00136 
00138         WT_Boolean operator!= (WT_RGBA32 const & test) const
00139                         {return m_whole != test.m_whole;}
00140 
00142         WT_RGBA32 const & operator= (WT_RGBA32 const & in)
00143                         {m_whole = in.m_whole;  return *this;}
00144 
00146         WT_RGBA32 const & operator= (WT_RGB const & in)
00147         {
00148             m_rgb.r = in.m_red;
00149             m_rgb.g = in.m_green;
00150             m_rgb.b = in.m_blue;
00151             m_rgb.a = 0xFF;
00152             return *this;
00153         }
00154 };
00155 
00156 #endif // RGB_HEADER

Generated on Tue Jan 6 22:41:13 2009 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.5