"L. Spiro Engine"
|
00001 00016 #ifndef __LSI_PNG_H__ 00017 #define __LSI_PNG_H__ 00018 00019 #include "../LSIImageLib.h" 00020 #include "Streams/LSSTDExternalByteStream.h" 00021 00022 namespace lsi { 00023 00030 class CPng { 00031 public : 00032 // == Functions. 00044 static LSBOOL LSE_CALL LoadPng( const LSUINT8 * _pui8FileData, LSUINT32 _ui32DataLen, 00045 LSUINT32 &_ui32Width, LSUINT32 &_ui32Height, LSI_PIXEL_FORMAT &_pfFormat, 00046 CImageLib::CTexelBuffer &_tbReturn ); 00047 00048 00049 00050 protected : 00051 // == Enumerations. 00052 enum LSI_PNG_FILTER { 00053 LSI_PF_NONE, 00054 LSI_PF_SUB, 00055 LSI_PF_UP, 00056 LSI_PF_AVG, 00057 LSI_PF_PAETH, 00058 LSI_PF_AVG_FIRST, 00059 LSI_PF_PAETH_FIRST, 00060 }; 00061 00062 00063 // == Types. 00067 typedef struct LSI_PNG_CHUNK { 00071 LSUINT32 ui32Type; 00072 00076 LSUINT32 ui32Length; 00077 } * LPLSI_PNG_CHUNK, * const LPCLSI_PNG_CHUNK; 00078 00082 typedef struct LSI_PNG_FINAL { 00086 LSUINT32 ui32Width; 00087 00091 LSUINT32 ui32Height; 00092 00096 LSUINT32 ui32X; 00097 00101 LSUINT32 ui32Y; 00102 00106 LSUINT8 * puiRawData; 00107 00111 LSUINT32 ui32RawLen; 00112 00116 LSUINT32 ui32Components; 00117 } * LPLSI_PNG_FINAL, * const LPCLSI_PNG_FINAL; 00118 00119 // == Members. 00123 static LSI_PNG_FILTER m_pfFirstRowFilter[]; 00124 00125 00126 // == Functions. 00135 static LSBOOL LSE_CALL CheckHeader( const CExternalByteStream &_ebsStream ); 00136 00144 static LSBOOL LSE_CALL NextChunk( const CExternalByteStream &_ebsStream, LSI_PNG_CHUNK &_pcChunk ); 00145 00153 static LSBOOL LSE_CALL CreatePng( LSI_PNG_FINAL &_pfFinal, CImageLib::CTexelBuffer &_tbReturn ); 00154 00163 static LSBOOL LSE_CALL CreatePng( LSI_PNG_FINAL &_pfFinal, CImageLib::CTexelBuffer &_tbReturn, LSBOOL _bInterlaced ); 00164 00178 static LSBOOL LSE_CALL ExpandPalette( CImageLib::CTexelBuffer &_tbReturn, const LSUINT8 * _pui8Palette, LSUINT32 _ui32Len, 00179 LSUINT32 _ui32Width, LSUINT32 _ui32Height, LSUINT32 _ui32Components, LSBOOL _bSwapRB ); 00180 00187 static LSVOID LSE_CALL FixColors( CImageLib::CTexelBuffer &_tbBuffer, LSUINT32 _ui32Components ); 00188 00196 static LSBOOL LSE_CALL ReadUi8( const CExternalByteStream &_ebsStream, LSUINT8 &_ui8Dst ); 00197 00205 static LSBOOL LSE_CALL ReadUi16( const CExternalByteStream &_ebsStream, LSUINT16 &_ui16Dst ); 00206 00214 static LSBOOL LSE_CALL ReadUi32( const CExternalByteStream &_ebsStream, LSUINT32 &_ui32Dst ); 00215 00222 static LSVOID LSE_CALL Skip( const CExternalByteStream &_ebsStream, LSUINT32 _ui32Length ); 00223 00232 static LSINT32 LSE_CALL Paeth( LSINT32 _i32A, LSINT32 _i32B, LSINT32 _i32C ); 00233 }; 00234 00235 } // namespace lsi 00236 00237 #endif // __LSI_PNG_H__