00001 #ifndef OSDL_PALETTE_H_
00002 #define OSDL_PALETTE_H_
00003
00004
00005 #include "OSDLPixel.h"
00006
00007 #include "Ceylan.h"
00008
00009 #include <string>
00010
00011
00012
00013 namespace OSDL
00014 {
00015
00016 namespace Video
00017 {
00018
00019
00021 typedef Ceylan::Uint32 ColorCount ;
00022
00023
00025 class OSDL_DLL PaletteException : public VideoException
00026 {
00027
00028 public:
00029 explicit PaletteException( const std::string & message )
00030 throw() ;
00031 virtual ~PaletteException() throw() ;
00032
00033 } ;
00034
00035
00036
00060 class OSDL_DLL Palette : public Ceylan::TextDisplayable
00061 {
00062
00063 public:
00064
00065
00067 static const Ceylan::Flags Logical ;
00068
00070 static const Ceylan::Flags Physical ;
00071
00072
00084 Palette( ColorCount numberOfColors,
00085 Pixels::ColorDefinition * colors,
00086 Pixels::PixelFormat * format = 0 )
00087 throw( PaletteException ) ;
00088
00089
00098 explicit Palette( SDL_Palette & palette )
00099 throw( PaletteException ) ;
00100
00101
00103 virtual ~Palette() throw() ;
00104
00105
00121 virtual void load( ColorCount numberOfColors,
00122 Pixels::ColorDefinition * colors )
00123 throw( PaletteException ) ;
00124
00125
00127 virtual ColorCount getNumberOfColors() const throw() ;
00128
00129
00141 virtual const Pixels::PixelColor & getPixelColorAt(
00142 ColorCount index )
00143 const throw( PaletteException ) ;
00144
00145
00152 virtual Pixels::PixelColor * getPixelColors() const throw() ;
00153
00154
00167 virtual const Pixels::ColorDefinition & getColorDefinitionAt(
00168 ColorCount index )
00169 const throw( PaletteException ) ;
00170
00171
00178 virtual Pixels::ColorDefinition * getColorDefinitions()
00179 const throw() ;
00180
00181
00190 virtual void updatePixelColorsFrom(
00191 Pixels::PixelFormat & format ) throw() ;
00192
00193
00209 virtual bool draw( Surface & targetSurface,
00210 Pixels::ColorDefinition backgroundColor = Pixels::White )
00211 throw() ;
00212
00213
00225 virtual const std::string toString(
00226 Ceylan::VerbosityLevels level = Ceylan::high )
00227 const throw() ;
00228
00229
00230
00231
00232
00233
00240 static Palette & CreateGreyScalePalette(
00241 ColorCount numberOfColors = 256 ) throw() ;
00242
00243
00252 static Palette & CreateGradationPalette(
00253 Pixels::ColorDefinition colorStart,
00254 Pixels::ColorDefinition colorEnd,
00255 ColorCount numberOfColors = 256 ) throw() ;
00256
00257
00265 static Palette & CreateLandscapePalette(
00266 ColorCount numberOfColors = 256 ) throw() ;
00267
00268
00269
00270 protected:
00271
00272
00274 ColorCount _numberOfColors ;
00275
00276
00282 Pixels::ColorDefinition * _colorDefs ;
00283
00284
00290 Pixels::PixelColor * _pixelColors ;
00291
00292
00298 bool _converted ;
00299
00300
00301
00302 private:
00303
00304
00313 explicit Palette( const Palette & source ) throw() ;
00314
00315
00324 Palette & operator = ( const Palette & source ) throw() ;
00325
00326
00327 } ;
00328
00329 }
00330
00331 }
00332
00333
00334 #endif // OSDL_PALETTE_H_
00335