00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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