Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkRGBAPixel.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkRGBAPixel.h,v $
00005   Language:  C++
00006   Date:      $Date: 2003/02/17 15:50:26 $
00007   Version:   $Revision: 1.10 $
00008 
00009   Copyright (c) 2002 Insight Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkRGBAPixel_h
00018 #define __itkRGBAPixel_h
00019 
00020 // Undefine an eventual RGBAPixel macro
00021 #ifdef RGBAPixel
00022 #undef RGBAPixel
00023 #endif
00024 
00025 #include <itkIndent.h>
00026 #include <itkFixedArray.h>
00027 #include "vnl/vnl_math.h"
00028 
00029 namespace itk
00030 {
00031 
00051 template < typename TComponent = unsigned short >
00052 class RGBAPixel: public FixedArray<TComponent,4>
00053 {
00054 public:
00056   typedef RGBAPixel  Self;
00057   typedef FixedArray<TComponent, 4> Super;
00058     
00060   typedef FixedArray<TComponent, 4> BaseArray;
00061   
00063   typedef TComponent ComponentType;
00064 
00066   RGBAPixel() {Fill(0);}
00067   RGBAPixel (const ComponentType& r)
00068   { Fill(r) ;}
00069   
00071   RGBAPixel(const Self& r): BaseArray(r) {}
00072   RGBAPixel(const ComponentType  r[4]): BaseArray(r) {}  
00073     
00075   RGBAPixel& operator= (const Self& r);
00076   RGBAPixel& operator= (const ComponentType r[4]);
00077   
00079   static int GetNumberOfComponents(){ return 4;}
00080 
00082   ComponentType GetNthComponent(int c) const
00083     { return this->operator[](c); }
00084 
00086   ComponentType GetScalarValue() const
00087     {
00088       return static_cast<ComponentType> (vnl_math_sqrt(
00089     static_cast<double>(this->operator[](0)) * static_cast<double>(this->operator[](0)) +
00090           static_cast<double>(this->operator[](1)) * static_cast<double>(this->operator[](1)) +
00091           static_cast<double>(this->operator[](2)) * static_cast<double>(this->operator[](2)))); 
00092     }
00093 
00095   void SetNthComponent(int c, const ComponentType& v)  
00096     {  this->operator[](c) = v; }
00097 
00099   void SetRed( ComponentType red ) { this->operator[](0) = red;}
00100 
00102   void SetGreen( ComponentType green ) {this->operator[](1) = green;}
00103 
00105   void SetBlue( ComponentType blue ) {this->operator[](2) = blue;}
00106 
00108   void SetAlpha( ComponentType alpha ) {this->operator[](3) = alpha;}
00109 
00111   void Set( ComponentType red, ComponentType green, ComponentType blue, ComponentType alpha )
00112     { this->operator[](0) = red; this->operator[](1) = green; this->operator[](2) = blue; this->operator[](3) = alpha;}
00113 
00115   const ComponentType & GetRed( void ) const { return this->operator[](0);}
00116 
00118   const ComponentType & GetGreen( void ) const { return this->operator[](1);}
00119 
00121   const ComponentType & GetBlue( void ) const { return this->operator[](2);}
00122 
00124   const ComponentType & GetAlpha( void ) const { return this->operator[](3);}
00125 };
00126 
00127 
00128 template< typename TComponent  >  
00129 ITK_EXPORT std::ostream& operator<<(std::ostream& os, 
00130                                     const RGBAPixel<TComponent> & c); 
00131 
00132 template< typename TComponent  >  
00133 ITK_EXPORT std::istream& operator>>(std::istream& is, 
00134                                           RGBAPixel<TComponent> & c); 
00135 
00136 } // end namespace itk
00137 
00138 #ifndef ITK_MANUAL_INSTANTIATION
00139 #include "itkRGBAPixel.txx"
00140 #endif
00141 
00142 #endif

Generated at Fri May 21 01:15:15 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000