cmtkImageRGB.h

Go to the documentation of this file.
00001 /*
00002 //
00003 //  Copyright 1997-2009 Torsten Rohlfing
00004 //
00005 //  Copyright 2004-2011 SRI International
00006 //
00007 //  This file is part of the Computational Morphometry Toolkit.
00008 //
00009 //  http://www.nitrc.org/projects/cmtk/
00010 //
00011 //  The Computational Morphometry Toolkit is free software: you can
00012 //  redistribute it and/or modify it under the terms of the GNU General Public
00013 //  License as published by the Free Software Foundation, either version 3 of
00014 //  the License, or (at your option) any later version.
00015 //
00016 //  The Computational Morphometry Toolkit is distributed in the hope that it
00017 //  will be useful, but WITHOUT ANY WARRANTY; without even the implied
00018 //  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 //  GNU General Public License for more details.
00020 //
00021 //  You should have received a copy of the GNU General Public License along
00022 //  with the Computational Morphometry Toolkit.  If not, see
00023 //  <http://www.gnu.org/licenses/>.
00024 //
00025 //  $Revision: 2752 $
00026 //
00027 //  $LastChangedDate: 2011-01-17 11:33:31 -0800 (Mon, 17 Jan 2011) $
00028 //
00029 //  $LastChangedBy: torstenrohlfing $
00030 //
00031 */
00032 
00033 #ifndef __cmtkImageRGB_h_included_
00034 #define __cmtkImageRGB_h_included_
00035 
00036 #include <cmtkconfig.h>
00037 
00038 #include <Pipeline/cmtkPlane.h>
00039 #include <Pipeline/cmtkImage.h>
00040 #include <Pipeline/cmtkRGB.h>
00041 
00042 #include <Base/cmtkTypes.h>
00043 
00044 namespace
00045 cmtk
00046 {
00047 
00050 
00052 typedef enum {
00054   IMAGE_RGB,
00056   IMAGE_RGBA
00057 } ImageAlphaToggle;
00058 
00061 class ImageRGB : 
00063   public Plane 
00064 {
00065 public:
00067   static ImageRGB* New();
00068 
00074   const byte *GetDataPtr() const
00075   { 
00076     return this->Data; 
00077   }
00078 
00086   byte *GetDataPtr( const bool forceAlloc );
00087 
00092   void GetPixel( RGBA& rgb, const int index );
00093 
00098   void SetPixel( const int index, const RGBA& rgb );
00099 
00104   void GetPixel( RGB& rgb, const int index );
00105 
00110   void SetPixel( const int index, const RGB& rgb );
00111 
00115   void SetAlphaChannel( const ImageAlphaToggle alphaChannel,
00116                         const bool convertData = false );
00117 
00120   ImageAlphaToggle GetAlphaChannel() const { return AlphaChannel; }
00121 
00123   bool IsGreyscale() const;
00124 
00125 protected:
00127   ImageRGB();
00128   
00132   ~ImageRGB();
00133 
00134 private:
00139   byte *Data;
00140 
00143   ImageAlphaToggle AlphaChannel;
00144 
00148   unsigned int BytesPerPixel;
00149 
00155   unsigned int DataSize;
00156 };
00157 
00159 
00160 } // namespace cmtk
00161 
00162 #endif // #ifndef __cmtkImageRGB_h_included_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines