Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

/ray/src/lib/pixmap/format.h

Go to the documentation of this file.
00001 /*
00002  * lib/pixmap/format.h
00003  * 
00004  * Image format description class (channels, bits). 
00005  * 
00006  * Copyright (c) 2004 by Wolfgang Wieser ] wwieser (a) gmx <*> de [ 
00007  * 
00008  * This file may be distributed and/or modified under the terms of the 
00009  * GNU General Public License version 2 as published by the Free Software 
00010  * Foundation. (See COPYING.GPL for details.)
00011  * 
00012  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014  * 
00015  */
00016 
00017 #ifndef _PIXMAP_FORMAT_H_
00018 #define _PIXMAP_FORMAT_H_ 1
00019 
00046 #include <lib/sconfig.h>    /* MUST be first */
00047 
00048 
00059 class PixmapFormat
00060 {
00061     public:
00062         // Max number of channels an image can have. 
00063         static const int MaxChannels=6;
00064         
00065     public:
00070         enum Format
00071         {
00072             // When adding entries here, do not forget to add an entry to the 
00073             // _nchannels[] array in format.cc. 
00074             None=0,     
00075             Gray,       
00076             GrayA,      
00077             RGB,        
00078             //VUY,      ///< VUY image, 3 channels
00079             RGBA,       
00080             RGBFT,      
00081             _LASTF      
00082         };
00083         
00089         enum CommonID
00090         {
00091             // NOTE: The order of the letters represents the order of the 
00092             //       cannels in the channels[] array which is meant to 
00093             //       specify the order in the data array. 
00094             // When adding entries here, do not forget to add an entry to the 
00095             // commons[] array in format.cc. 
00096             Gray_1,       
00097             Gray_8,       
00098             Gray_16,      
00099             GrayA_8,      
00100             GrayA_16,     
00101             RGB_8,        
00102             RGB_16,       
00103             RGBA_8,       
00104             RGBA_16,      
00105             RGB_555,      
00106             RGB_565,      
00107             RGBFT_f,      
00108             _LASTID       
00109         };
00110         
00112         static const signed char FloatBits=-1;
00113         
00115         static const short int _nchannels[_LASTF];
00116         
00118         struct FMT
00119         {
00121             Format format;
00125             signed char bits[MaxChannels];
00126             
00128         };
00129         
00130     private:
00132         FMT f;
00133         
00135         void _set(CommonID cid);
00136         void _set(Format fmt,const signed char *bits);
00137     public:
00139         inline PixmapFormat(CommonID cid)        // e.g. PixmapFormat::RGB_8
00140             {  _set(cid);  }
00148         inline PixmapFormat(Format id,const signed char *bits)
00149             {  _set(id,bits);  }
00151         inline PixmapFormat(const PixmapFormat &pf) : f(pf.f) {}
00152         inline ~PixmapFormat()  {}
00153         
00155         inline void set(CommonID cid)  {  _set(cid);  }
00156         inline void set(Format id,const signed char *bits)
00157             {  _set(id,bits);  }
00158         inline PixmapFormat &operator=(CommonID cid)
00159             {  _set(cid);  return(*this);  }
00160         inline PixmapFormat &operator=(const PixmapFormat &pf)
00161             {  f=pf.f;  return(*this);  }
00162         
00165         inline Format format() const        {  return(f.format);  }
00166         inline short int nchannels() const  {  return(_nchannels[f.format]);  }
00168         inline signed char bits(short int c) const
00169             {  return(f.bits[c]);  }
00170         
00175         signed char SameBitsForAll() const;
00176         
00178         bool operator==(const PixmapFormat &pf) const;
00179         inline bool operator!=(const PixmapFormat &pf) const
00180             {  return(!operator==(pf));  }
00181         
00183         inline bool operator==(Format fmt) const  {  return(f.format==fmt);  }
00184         inline bool operator!=(Format fmt) const  {  return(f.format!=fmt);  }
00185 };
00186 
00187 #endif  /* _PIXMAP_FORMAT_H_ */

Generated on Sat Feb 19 22:33:46 2005 for Ray by doxygen 1.3.5