|
#pragma once
// This code was written by Daniel Cohen Gindi (danielgindi@gmail.com)
// You can use it fo whatever needs, but please keep the credits :-)
// NOTE: The code is using a 'minimal' version of ZLIB,
// with only the unzip functionality
// IMPORTANT NOTE: The FILE passes must be opened in BINARY MODE!!!
// And for a good reason:
// The fseek reliability is not guaranteed in text mode... (MSDN... And tests)
#include "zlib_unzip.h"
typedef struct tagSWF_RECT
{ // TWIPS! 1 TWIP = 20 PIXELS
int xMin;
int xMax;
int yMin;
int yMax;
} SWF_RECT;
typedef struct tagSWF_HEADER
{
BOOL bCompressed;
BYTE bVer;
float fFrameRate;
SWF_RECT rcFrameSize;
WORD wFrameCount;
} SWF_HEADER;
class CSWFReader
{
public:
CSWFReader(FILE * file = NULL);
virtual ~CSWFReader();
void SetFile(FILE * file);
BOOL ReadHeader();
SWF_HEADER& GetHeader();
private:
FILE * m_fFile;
BOOL m_bHeaderRead;
static const UINT DECOMPRESS_BUFFER_SIZE=16;
BOOL m_bReadCompressed;
z_stream m_zStream;
BYTE m_zInBytes[DECOMPRESS_BUFFER_SIZE];
SWF_HEADER m_header;
UINT m_iBitPos;
BYTE m_bCurByte;
BOOL ReadByte(BYTE & bOut);
BOOL ReadBytes(BYTE * bOut, UINT iCount);
BOOL ReadBit(BOOL & bBit);
BOOL ReadUI8(unsigned __int8 & value);
BOOL ReadSI8(signed __int8 & value);
BOOL ReadUI16(unsigned __int16 & value);
BOOL ReadSI16(signed __int16 & value);
BOOL ReadUI32(unsigned __int32 & value);
BOOL ReadSI32(signed __int32 & value);
BOOL Read8_8(float & value);
BOOL Read16_16(float & value);
BOOL ReadUB(unsigned __int8 & value, int iBits);
BOOL ReadUB(unsigned __int16 & value, int iBits);
BOOL ReadUB(unsigned __int32 & value, int iBits);
BOOL ReadSB(signed __int8 & value, int iBits);
BOOL ReadSB(signed __int16 & value, int iBits);
BOOL ReadSB(signed __int32 & value, int iBits);
};
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.