Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages | Examples

rgb.h

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

Generated on Tue May 17 12:07:44 2005 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.1