00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef OSDL_IMAGE_H_
00028 #define OSDL_IMAGE_H_
00029
00030
00031 #include "OSDLPixel.h"
00032 #include "OSDLVideoTypes.h"
00033
00034 #include "Ceylan.h"
00035
00036
00037 #include <string>
00038
00039
00040
00041
00042 #include "OSDLIncludeCorrecter.h"
00043
00044
00045
00046
00047 namespace OSDL
00048 {
00049
00050
00051 namespace Video
00052 {
00053
00054
00055
00056
00057 class Surface ;
00058
00059
00060
00061 namespace TwoDimensional
00062 {
00063
00064
00065
00067 class OSDL_DLL ImageException : public OSDL::Video::VideoException
00068 {
00069 public:
00070
00071 ImageException( const std::string & reason ) ;
00072
00073 virtual ~ImageException() throw() ;
00074
00075 } ;
00076
00077
00078
00079
00080 class Image ;
00081
00082
00084 typedef Ceylan::CountedPointer<Image> ImageCountedPtr ;
00085
00086
00087
00088
00121 class OSDL_DLL Image : public Ceylan::TextDisplayable,
00122 public Ceylan::LoadableWithContent<Surface>
00123 {
00124
00125
00126
00127 public:
00128
00129
00130
00166 explicit Image(
00167 const std::string & imageFilename,
00168 bool preload = true,
00169 bool convertToDisplayFormat = true,
00170 bool convertWithAlpha = true ) ;
00171
00172
00173
00179 virtual ~Image() throw() ;
00180
00181
00182
00183
00184
00185
00186
00187
00198 virtual bool load() ;
00199
00200
00201
00213 virtual bool unload() ;
00214
00215
00216
00229 virtual const std::string toString(
00230 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00231
00232
00233
00234
00235
00236
00237
00238
00256 static Surface & LoadIcon( const std::string & filename,
00257 Pixels::ColorElement ** mask ) ;
00258
00259
00260
00261
00262
00263
00264
00265
00266
00308 static void Load( Surface & targetSurface,
00309 const std::string & filename,
00310 bool blitOnly = false,
00311 bool convertToDisplay = true,
00312 bool convertWithAlpha = true ) ;
00313
00314
00315
00359 static void LoadJPG(
00360 Surface & targetSurface,
00361 const std::string & filename,
00362 bool blitOnly = false,
00363 bool convertToDisplay = true,
00364 bool convertWithAlpha = true ) ;
00365
00366
00367
00411 static void LoadPNG( Surface & targetSurface,
00412 const std::string & filename,
00413 bool blitOnly = false,
00414 bool convertToDisplay = true,
00415 bool convertWithAlpha = true ) ;
00416
00417
00418
00462 static void LoadBMP( Surface & targetSurface,
00463 const std::string & filename,
00464 bool blitOnly = false,
00465 bool convertToDisplay = true,
00466 bool convertWithAlpha = true ) ;
00467
00468
00469
00513 static void LoadGIF( Surface & targetSurface,
00514 const std::string & filename,
00515 bool blitOnly = false,
00516 bool convertToDisplay = true,
00517 bool convertWithAlpha = true ) ;
00518
00519
00520
00564 static void LoadLBM( Surface & targetSurface,
00565 const std::string & filename,
00566 bool blitOnly = false,
00567 bool convertToDisplay = true,
00568 bool convertWithAlpha = true ) ;
00569
00570
00571
00615 static void LoadPCX( Surface & targetSurface,
00616 const std::string & filename,
00617 bool blitOnly = false,
00618 bool convertToDisplay = true,
00619 bool convertWithAlpha = true ) ;
00620
00621
00622
00666 static void LoadPNM( Surface & targetSurface,
00667 const std::string & filename,
00668 bool blitOnly = false,
00669 bool convertToDisplay = true,
00670 bool convertWithAlpha = true ) ;
00671
00672
00673
00717 static void LoadTGA( Surface & targetSurface,
00718 const std::string & filename,
00719 bool blitOnly = false,
00720 bool convertToDisplay = true,
00721 bool convertWithAlpha = true ) ;
00722
00723
00724
00768 static void LoadXPM( Surface & targetSurface,
00769 const std::string & filename,
00770 bool blitOnly = false,
00771 bool convertToDisplay = true,
00772 bool convertWithAlpha = true ) ;
00773
00774
00775
00776
00777
00778
00779
00780
00781
00809 static void SavePNG( Surface & targetSurface,
00810 const std::string & filename,
00811 bool overwrite = true ) ;
00812
00813
00814
00840 static void SaveBMP( Surface & targetSurface,
00841 const std::string & filename,
00842 bool overwrite = true ) ;
00843
00844
00845
00846
00847 protected:
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00863 bool _convertToDisplayFormat ;
00864
00865
00866
00874 bool _convertWithAlpha ;
00875
00876
00877
00878
00879 private:
00880
00881
00882
00891 explicit Image( const Image & source ) ;
00892
00893
00894
00903 Image & operator = ( const Image & source ) ;
00904
00905
00906
00907
00908
00913 static const std::string JPGTag ;
00914
00915
00916
00921 static const std::string PNGTag ;
00922
00923
00924
00930 static const std::string BMPTag ;
00931
00932
00933
00939 static const std::string GIFTag ;
00940
00941
00942
00948 static const std::string LBMTag ;
00949
00950
00951
00957 static const std::string PCXTag ;
00958
00959
00965 static const std::string PNMTag ;
00966
00967
00968
00974 static const std::string TGATag ;
00975
00976
00977
00983 static const std::string XPMTag ;
00984
00985
00986
00987 } ;
00988
00989
00990
00991
00993 typedef struct
00994 {
00995
00996
00998 Ceylan::Uint16 type ;
00999
01000
01002 Ceylan::Uint32 size ;
01003
01004
01006 Ceylan::Uint16 firstReserved ;
01007
01008
01010 Ceylan::Uint16 secondReserved ;
01011
01012
01014 Ceylan::Uint32 offset ;
01015
01016
01017 }
01018
01019 #ifndef CEYLAN_RUNS_ON_WINDOWS
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029 __attribute__ ((packed))
01030
01031 #endif // CEYLAN_RUNS_ON_WINDOWS
01032
01033 BMPHeader ;
01034
01035
01036
01038 typedef struct
01039 {
01040
01041
01043 Ceylan::Uint32 size ;
01044
01045
01047 Ceylan::Uint32 width ;
01048
01049
01051 Ceylan::Uint32 height ;
01052
01053
01055 Ceylan::Uint16 planes ;
01056
01057
01059 Ceylan::Uint16 bits ;
01060
01061
01063 Ceylan::Uint32 compression ;
01064
01065
01067 Ceylan::Uint32 imagesize ;
01068
01069
01071 Ceylan::Uint32 xresolution ;
01072
01073
01075 Ceylan::Uint32 yresolution ;
01076
01077
01079 Ceylan::Uint32 ncolours ;
01080
01081
01083 Ceylan::Uint32 importantcolours ;
01084
01085
01086 }
01087
01088 #ifndef CEYLAN_RUNS_ON_WINDOWS
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098 __attribute__ ((packed))
01099
01100 #endif // CEYLAN_RUNS_ON_WINDOWS
01101
01102 BMPInfoHeader ;
01103
01104
01105 }
01106
01107 }
01108
01109 }
01110
01111
01112
01113 #endif // OSDL_IMAGE_H_
01114