pixel_format.H

00001 /*
00002  * This file is part of the "Archon" framework.
00003  * (http://files3d.sourceforge.net)
00004  *
00005  * Copyright © 2006 by Kristian Spangsege and Brian Kristiansen.
00006  *
00007  * Permission to use, copy, modify, and distribute this software and
00008  * its documentation under the terms of the GNU General Public License is
00009  * hereby granted. No representations are made about the suitability of
00010  * this software for any purpose. It is provided "as is" without express
00011  * or implied warranty. See the GNU General Public License
00012  * (http://www.gnu.org/copyleft/gpl.html) for more details.
00013  *
00014  * The characters in this file are ISO8859-1 encoded.
00015  *
00016  * The documentation in this file is in "Doxygen" style
00017  * (http://www.doxygen.org).
00018  */
00019 
00020 #ifndef ARCHON_UTILITIES_PIXEL_FORMAT_H
00021 #define ARCHON_UTILITIES_PIXEL_FORMAT_H
00022 
00023 #include <inttypes.h>
00024 
00025 #include <vector>
00026 
00027 #include <archon/util/exception.H>
00028 
00029 namespace Archon
00030 {
00031   namespace Utilities
00032   {
00033     using namespace std;
00034 
00061     struct PixelFormat
00062     {
00067       struct UnsupportedWordTypeException: virtual Exception
00068       {
00069         UnsupportedWordTypeException(string l): Exception(l) {}
00070       };
00071 
00078       struct InconsistencyException: virtual Exception
00079       {
00080         InconsistencyException(string l): Exception(l) {}
00081         InconsistencyException(string l, string m): Exception(l, m) {}
00082       };
00083 
00084 
00085       typedef uintmax_t MaxInt;
00086 
00087 
00091       enum FormatType
00092       {
00097         direct,
00098 
00103         packed,
00104 
00109         tight
00110       };
00111 
00112       FormatType formatType;
00113 
00126       int pixelSize;
00127 
00128 
00142       enum WordType
00143       {
00144         std_char,        
00145         std_short,       
00146         std_int,         
00147         std_long,        
00148         std_max_int,     
00149         std_float,       
00150         std_double,      
00151         std_long_double, 
00152         custom_int,      
00153         custom_float     
00154       };
00155 
00156       WordType wordType;
00157 
00166       int bitsPerWord;
00167 
00250       bool mostSignificantBitsFirst;
00251 
00252 
00253 
00254 
00258       struct Channel
00259       {
00265         int offset;
00266 
00271         int width;
00272 
00273         bool operator==(const Channel &c) const
00274         {
00275           return offset == c.offset && width == c.width;
00276         }
00277       };
00278 
00284       vector<Channel> channelLayout;
00285 
00301       enum ColorScheme
00302       {
00303         implied,   
00304         custom,    
00305         luminance, 
00306         rgb,       
00307         hsv        
00308       };
00309 
00310       ColorScheme colorScheme;
00311 
00319       bool hasAlphaChannel;
00320 
00321 
00340       PixelFormat getExpandedFormat() const throw(UnsupportedWordTypeException, InconsistencyException);
00341 
00347       PixelFormat getReducedFormat() const throw(UnsupportedWordTypeException, InconsistencyException);
00348 
00403       string toString() const;
00404 
00405       bool operator==(const PixelFormat &f) const
00406       {
00407         return
00408           formatType               == f.formatType               &&
00409           pixelSize                == f.pixelSize                &&
00410           wordType                 == f.wordType                 &&
00411           bitsPerWord              == f.bitsPerWord              &&
00412           mostSignificantBitsFirst == f.mostSignificantBitsFirst &&
00413           channelLayout            == f.channelLayout            &&
00414           colorScheme              == f.colorScheme              &&
00415           hasAlphaChannel          == f.hasAlphaChannel;
00416       }
00417 
00418       PixelFormat():
00419         formatType(direct),
00420         pixelSize(0),
00421         wordType(std_char),
00422         bitsPerWord(0),
00423         mostSignificantBitsFirst(false),
00424         colorScheme(implied),
00425         hasAlphaChannel(false) {}
00426     };
00427   }
00428 }
00429 
00430 #endif // ARCHON_UTILITIES_PIXEL_FORMAT_H

Generated on Sun Jul 30 22:55:45 2006 for Archon by  doxygen 1.4.4