nrgb.hh

00001 // Copyright (C) 2001, 2002, 2003, 2004 EPITA Research and Development
00002 // Laboratory
00003 //
00004 // This file is part of the Olena Library.  This library is free
00005 // software; you can redistribute it and/or modify it under the terms
00006 // of the GNU General Public License version 2 as published by the
00007 // Free Software Foundation.
00008 //
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this library; see the file COPYING.  If not, write to
00016 // the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017 // Boston, MA 02110-1301, USA.
00018 //
00019 // As a special exception, you may use this file as part of a free
00020 // software library without restriction.  Specifically, if other files
00021 // instantiate templates or use macros or inline functions from this
00022 // file, or you compile this file and link it with other files to
00023 // produce an executable, this file does not by itself cause the
00024 // resulting executable to be covered by the GNU General Public
00025 // License.  This exception does not however invalidate any other
00026 // reasons why the executable file might be covered by the GNU General
00027 // Public License.
00028 
00029 #ifndef NTG_NRGB_HH
00030 # define NTG_NRGB_HH
00031 
00032 # include <ntg/color/color.hh>
00033 
00034 namespace ntg
00035 {
00036 
00041   enum nrgb_comp
00042     {
00043       nrgb_R = 0,
00044       nrgb_G = 1,
00045       nrgb_B = 2
00046     };
00047 
00048   template<unsigned icomp> struct nrgb_traits;
00049   template<>
00050   struct nrgb_traits<nrgb_R>
00051   {
00052     static float lower_bound() { return 0;}
00053     static float upper_bound() { return 1.0885004;}
00054   };
00055 
00056 
00057   template<>
00058   struct nrgb_traits<nrgb_G>
00059   {
00060     static float lower_bound() { return -0.3321984;}
00061     static float upper_bound() { return  1.3189264;}
00062   };
00063 
00064 
00065   template<>
00066   struct nrgb_traits<nrgb_B>
00067   {
00068     static float lower_bound() { return -0.0688480;}
00069     static float upper_bound() { return 0.904727;}
00070   };
00071 
00072 
00073   typedef color<3,8,nrgb_traits>  nrgb_8;
00074   typedef color<3,16,nrgb_traits> nrgb_16;
00075   typedef color<3,32,nrgb_traits> nrgb_32;
00076 
00077   // FIXME: not thread safe !
00078 # define DEFINE_COLOR(Type, Name, V1, V2, V3)   \
00079   inline const Type& Name() {                   \
00080     static const Type tmp(V1, V2, V3);          \
00081     return tmp;                                 \
00082   }
00083 
00084   namespace nrgb_8_color
00085   {
00086 
00087     DEFINE_COLOR(nrgb_8, white, 255, 255, 255)
00088     DEFINE_COLOR(nrgb_8, gray,  128, 128, 128)
00089     DEFINE_COLOR(nrgb_8, black, 0,   0,   0)
00090     DEFINE_COLOR(nrgb_8, red,   255, 0,   0)
00091     DEFINE_COLOR(nrgb_8, green, 0,   255, 0)
00092     DEFINE_COLOR(nrgb_8, blue,  0,   0,   255)
00093     DEFINE_COLOR(nrgb_8, yellow,255, 255, 0)
00094     DEFINE_COLOR(nrgb_8, cyan,  0,   255, 255)
00095     DEFINE_COLOR(nrgb_8, pink,  255, 0,   255)
00096 
00097   } // end of nrgb_8_color
00098 
00099   namespace nrgb_16_color
00100   {
00101 
00102     DEFINE_COLOR(nrgb_16, white, 255, 255, 255)
00103     DEFINE_COLOR(nrgb_16, gray,  128, 128, 128)
00104     DEFINE_COLOR(nrgb_16, black, 0,   0,   0)
00105     DEFINE_COLOR(nrgb_16, red,   255, 0,   0)
00106     DEFINE_COLOR(nrgb_16, green, 0,   255, 0)
00107     DEFINE_COLOR(nrgb_16, blue,  0,   0,   255)
00108     DEFINE_COLOR(nrgb_16, yellow,255, 255, 0)
00109     DEFINE_COLOR(nrgb_16, cyan,  0,   255, 255)
00110     DEFINE_COLOR(nrgb_16, pink,  255, 0,   255)
00111 
00112   } // end of nrgb_16_color
00113 
00114   namespace nrgb_32_color
00115   {
00116 
00117     DEFINE_COLOR(nrgb_32, white, 255, 255, 255)
00118     DEFINE_COLOR(nrgb_32, gray,  128, 128, 128)
00119     DEFINE_COLOR(nrgb_32, black, 0,   0,   0)
00120     DEFINE_COLOR(nrgb_32, red,   255, 0,   0)
00121     DEFINE_COLOR(nrgb_32, green, 0,   255, 0)
00122     DEFINE_COLOR(nrgb_32, blue,  0,   0,   255)
00123     DEFINE_COLOR(nrgb_32, yellow,255, 255, 0)
00124     DEFINE_COLOR(nrgb_32, cyan,  0,   255, 255)
00125     DEFINE_COLOR(nrgb_32, pink,  255, 0,   255)
00126 
00127   } // end of nrgb_32_color.
00128 
00129 } // end of ntg.
00130 
00131 #endif // !NTG_COLOR_NRGB_HH

Generated on Tue Feb 20 20:20:13 2007 for Olena by  doxygen 1.5.1