nrgb.hh

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

Generated on Thu Apr 15 20:13:13 2004 for Olena by doxygen 1.3.6-20040222