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 __CSIBCPixMap_H__
00028 #define __CSIBCPixMap_H__
00029
00030
00031
00032
00033 #include <SIBCUtil.h>
00034 #include <SIBCNode.h>
00035 #include <SIBCString.h>
00036 #include <SIBCSearchPath.h>
00037
00038
00039 class CSIBCPixMap;
00040
00042 class XSICOREEXPORT CSIBCPixMapDriver
00043 {
00044 private:
00045 SI_Void *m_pUnused;
00046
00047 public:
00048
00052 CSIBCPixMapDriver();
00053
00056 virtual ~CSIBCPixMapDriver();
00057
00064 virtual SI_Bool Supported( CSIBCString &in_Filename ) = 0;
00065
00074 virtual SI_Error Load( CSIBCString &in_filename, CSIBCPixMap &in_PixMap ) = 0;
00075
00085 virtual SI_Error LoadFromMemory( void *in_pMemoryBlock, SI_Int in_lCount, CSIBCPixMap &in_PixMap ) { return SI_FILE_NOT_FOUND; }
00086 };
00087
00088
00089
00090 class XSICOREEXPORT CSIBCPixMap : public CSIBCNode
00091 {
00092 public:
00093
00095 enum
00096 {
00097 RED,
00098 GREEN,
00099 BLUE,
00100 ALPHA
00101 };
00102
00104 enum
00105 {
00106
00107 RGB,
00108 RGBA,
00109 PALETIZED
00110 };
00111
00113 enum
00114 {
00115 INVALID_TEXTURE_ID = 0xffffffff
00116 };
00117
00119 enum
00120 {
00121 RESIZE_LOWER,
00122 RESIZE_HIGHER,
00123 RESIZE_NEAREST
00124 };
00125
00129 CSIBCPixMap();
00130
00133 virtual ~CSIBCPixMap();
00134
00135
00139 SI_Int GetCLUTSize(){return (1<<m_ClutWidth);};
00140
00144 SI_Int GetWidth();
00145
00149 SI_Int GetHeight();
00150
00157 SI_Int GetType();
00158
00159
00163 SI_Int GetDepth();
00164
00169 SI_Int GetDepth( SI_Int in_lComponent);
00170
00176 SI_Error SetDepth( SI_Int *i_pDepth);
00177
00181 SI_Int GetTotalPixelDepthByte();
00182
00186 SI_UByte *GetMap();
00187
00196 SI_Error GetPixel( SI_Int x, SI_Int y, SI_UByte *pVal );
00208 SI_Error GetPixel( SI_Int x, SI_Int y, SI_Int &r, SI_Int &g, SI_Int &b, SI_Int &a );
00209
00217 SI_Error SetPixel( SI_Int x, SI_Int y, SI_UByte *pVal );
00218
00229 SI_Error SetPixel( SI_Int x, SI_Int y, SI_Int r, SI_Int g, SI_Int b, SI_Int a );
00230
00238 SI_Error SetPixel( SI_Int x, SI_Int y, SI_Int index );
00239
00247 SI_Error GetPixelColourIndex( SI_Int x, SI_Int y, SI_UByte *pVal );
00248
00255 SI_Error GetColour( SI_UByte i, SI_UByte *out_pRGBA );
00256
00266 SI_Error GetColour( SI_UByte i, SI_Int *r, SI_Int *g, SI_Int *b, SI_Int *a );
00267
00274 SI_Error SetColour( SI_UByte i, SI_UByte *in_pRGBA );
00275
00285 SI_Error SetColour( SI_UByte i, SI_Int r, SI_Int g, SI_Int b, SI_Int a = 255 );
00286
00287
00291 SI_Int ComputeCRC();
00292
00301 void PackPixel( SI_Int r, SI_Int g, SI_Int b, SI_Int a, SI_UByte *pVal );
00302
00311 void UnPackPixel( SI_Int &r, SI_Int &g, SI_Int &b, SI_Int &a, SI_UByte *pVal );
00312
00318 SI_Int Index( SI_Int x, SI_Int y );
00319
00320
00321 SI_UInt &TextureID() { return m_TextureID; }
00322
00331 SI_Error CreateNew( SI_Int i_Width, SI_Int i_Height,
00332 SI_Int i_Type, SI_Int *i_pDepth );
00333
00334
00340 SI_Error ResizeToPowerOfTwo( SI_Int method);
00341
00346 SI_Error DisposeData();
00347
00353 SI_Error ConvertToRGB( CSIBCPixMap & );
00354
00355
00356
00360 virtual SI_UInt UsedMemory();
00361
00365 virtual SI_UInt AllocatedMemory();
00366
00370 virtual SI_UInt LocalSize();
00371
00372
00373
00378 static CSIBCSearchPath *GetSearchPath();
00379
00386 static SI_Error AddDriver( CSIBCPixMapDriver * );
00387
00396 static SI_Error Load( CSIBCString &in_Filename, CSIBCPixMap &in_PixMap, SI_Bool in_ResizeToPowerOfTwo = TRUE );
00397
00406 static SI_Error Load( const SI_Char *in_Filename, CSIBCPixMap &in_PixMap, SI_Bool in_ResizeToPowerOfTwo = TRUE );
00407
00417 static SI_Error Load( CSIBCString &, void *pMemoryBlock, SI_Int nSize, CSIBCPixMap &i_OutMap);
00418
00428 static SI_Error Load( const SI_Char *, void *pMemoryBlock, SI_Int nSize, CSIBCPixMap &i_OutMap);
00429
00435 static SI_Error Cleanup();
00436
00437 protected:
00438
00439
00440 private:
00441 SI_Int m_Width;
00442 SI_Int m_Height;
00443 SI_Int m_Type;
00444 SI_Int m_Depth[4];
00445 SI_Int m_TotalDepth;
00446 SI_UInt m_TextureID;
00447 SI_Int m_ClutDepth;
00448 SI_Int m_ClutWidth;
00449
00450 SI_UByte *m_pMap;
00451 SI_UByte *m_pCLUT;
00452 CSIBCString m_Filename;
00453
00454
00455 static CSIBCSearchPath s_Path;
00456 static CSIBCArray< CSIBCPixMapDriver * > s_Drivers;
00457
00458 SI_Void *m_pUnused;
00459 };
00460
00461
00462
00463 #endif
00464