欢迎来到天天文库
浏览记录
ID:20489812
大小:17.38 KB
页数:15页
时间:2018-10-10
《lzw压缩算法的c语言实现.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、lzw压缩算法的c语言实现1程序由五个模块组成。(1) lzw.h 定义了一些基本的数据结构,常量,还有变量的初始化等。#ifndef__LZW_H__#define__LZW_H__//------------------------------------------------------------------------------#include#include#include#include//---------------------------------------------
2、---------------------------------#defineLZW_BASE 0x102// Thecodebase#defineCODE_LEN 12 // Maxcodelength#defineTABLE_LEN 4099//Itmustbeprimenumberandbiggerthan2^CODE_LEN=4096. //Suchas5051isalsook.#defineBUFFERSIZE 1024//-------------------------------------------------
3、-----------------------------typedefstruct{ HANDLE h_sour; //Sourcefilehandle. HANDLE h_dest; //Destinationfilehandle. HANDLE h_suffix;//Suffixtablehandle. HANDLE h_prefix;//Prefixtablehandle. HANDLE h_code; //Codetablehandle. LPWORD lp_p
4、refix;//Prefixtableheadpointer. LPBYTE lp_suffix;//Suffixtableheadpointer. LPWORD lp_code;//Codetableheadpointer. WORD code; WORD prefix; BYTE suffix; BYTE cur_code_len;//Currentcodelength.[usedinDynamic-Code-Lengthmode]}LZW_DATA,*PLZW_DATA;
5、typedefstruct{ WORD top; WORD index; LPBYTE lp_buffer; HANDLE h_buffer; BYTE by_left; DWORD dw_buffer; BOOL end_flag;}BUFFER_DATA,*PBUFFER_DATA;typedefstruct //Stackusedindecode{WORD index;HANDLE h_s
6、tack;LPBYTE lp_stack;}STACK_DATA,*PSTACK_DATA;//------------------------------------------------------------------------------VOIDstack_create(PSTACK_DATAstack){stack->h_stack =GlobalAlloc(GHND,TABLE_LEN*sizeof(BYTE));stack->lp_stack=GlobalLock(stack->h_stack);stack->index=0;}//------------
7、------------------------------------------------------------------VOIDstack_destory(PSTACK_DATAstack){GlobalUnlock(stack->h_stack); GlobalFree (stack->h_stack);}//---------------------------------------------------
此文档下载收益归作者所有