⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compress.h

📁 用FREE BASIC做的演示程序
💻 H
字号:
//Blue Dream Engine V1.1
//Compress class
//by Kylinx

#ifndef BLUE_DREAM_COMPRESS_H_
#define BLUE_DREAM_COMPRESS_H_
#include<assert.h>
#define WINDOW_SIZE			(4096)
#define FORWORD_BUF_SIZE	(18)
#define MINMATCH			(2)
#define UNUSE				(WINDOW_SIZE)
class GCompressLZSS
{
public:
	static bool Compress(void*pOrgData,unsigned long dwOrgDataSize,void**ppCompressData,unsigned long & dwCompressedDataSize);
	static bool Decompress(void*pCompressedData,unsigned long dwCompressedDataSize,void*pDestAddr);	
	static bool DecompressAutoSize(void*pCompressedData,unsigned long dwCompressedDataSize,void**ppOrgData,unsigned long & dwOrgDataSize);	
private:
	static void InitTree();
	static void Insert(int index);
	static void Remove(int index);
	
	static unsigned char	s_pBuf[WINDOW_SIZE+FORWORD_BUF_SIZE-1];
	static int				s_pParent[WINDOW_SIZE+1];
	static int				s_pLeftChild[WINDOW_SIZE+1];
	static int				s_pRightChild[WINDOW_SIZE+257];
	static int				s_nMatchLength;
	static int				s_nMatchPos;
};
class GCompressNone
{
public:
	static bool Compress(void*pOrgData,unsigned long dwOrgDataSize,void**ppCompressData,unsigned long & dwCompressedDataSize);
	static bool DecompressAutoSize(void*pCompressedData,unsigned long dwCompressedDataSize,void**ppOrgData,unsigned long & dwOrgDataSize);
	static bool Decompress(void*pCompressedData,unsigned long dwCompressedDataSize,void*pDestAddr);		
};
class GCompress8BitRLE
{
public:
	static bool Compress(void*pOrgData,unsigned long dwOrgDataSize,void**ppCompressData,unsigned long & dwCompressedDataSize);
	static bool DecompressAutoSize(void*pCompressedData,unsigned long dwCompressedDataSize,void**ppOrgData,unsigned long & dwOrgDataSize);
	static bool Decompress(void*pCompressedData,unsigned long dwCompressedDataSize,void*pDestAddr);		
};
class GCompress16BitRLE
{
public:
	static bool Compress(void*pOrgData,unsigned long dwOrgDataSize,void**ppCompressData,unsigned long & dwCompressedDataSize);
	static bool DecompressAutoSize(void*pCompressedData,unsigned long dwCompressedDataSize,void**ppOrgData,unsigned long & dwOrgDataSize);	
	static bool Decompress(void*pCompressedData,unsigned long dwCompressedDataSize,void*pDestAddr);		
};

template<class GCompress=GCompressNone>
class GTCompress
{
public:
	inline bool operator ()(void*pOrgData,unsigned long dwOrgDataSize,void**ppCompressedData,unsigned long & dwCompressedDataSize)
	{
		assert(pOrgData && ppCompressedData);
		return GCompress::Compress(pOrgData,dwOrgDataSize,ppCompressedData,dwCompressedDataSize);
	}
};
template<class GDecompress=GCompressNone>
class GTDecompressAutoSize
{
public:
	inline bool operator ()(void*pCompressedData,unsigned long dwCompressedDataSize,void**ppOrgData,unsigned long & dwOrgDataSize)
	{
		assert(pCompressedData && ppOrgData);
		return GDecompress::DecompressAutoSize(pCompressedData,dwCompressedDataSize,ppOrgData,dwOrgDataSize);
	}
};
template<class GDecompress=GCompressNone>
class GTDecompress
{
public:
	inline bool operator ()(void*pCompressedData,unsigned long dwCompressedDataSize,void*pDestAddr)
	{
		assert(pCompressedData && pDestAddr);
		return GDecompress::Decompress(pCompressedData,dwCompressedDataSize,pDestAddr);
	}
};
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -