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

📄 lzw.h

📁 LZW compression example with java
💻 H
字号:
/*The LZW Lib, Included as a part of the compression tutorial
 *Written By Martin Zolnieryk (c) 2004
 *
 *Thanks Goes to Mark Nelson and ever other person whos tutorials
 *aided in the writing of this.
 *
 *This code is freeware, however if you use this some credit
 *be nice.
*/
//This is our table
typedef struct LZW_STRUCT
{
    //The actual LZW table
    unsigned short int *prefix; //The Prefix, first code
    short int  *character;  //The char that is added to a code, always -1-255 so no need for unsigned
    unsigned short int codes_used;    //How many CODES of Size are used
    unsigned short int codes_reserved; //Which codes not used, usually 0-255 for ASCII
    unsigned short int lzw_size;      //Tells us how many LZW's were allocated
    
    //This is for Write and Get codes
    unsigned int buffer;     //32 bits of space, up to 16bit compression
    char buffer_bits;        //lets save some mem, we dont need a compression greater than 128 bits.
    int bits;                //How many bits per code
    unsigned short int buffer_size; //Used for gif, and other possible lzw implentations
    unsigned short int to_nbuffer;  //Used for gif, how much before new buffer must be allocated
    
    //The string buffer
    unsigned char *string;
}LZW;


//These are all related to memory managment of the LZW table
int create_lzw_table (LZW *table, int bits);
int delete_lzw_table (LZW *table);
int clear_lzw_table(LZW *table);
int clear_lzw_tablef(LZW *table,int bits);

//Do what they say
int lzw_compress_file(LZW *table,const char *file_in, const char *file_out);
int lzw_decompress_file(LZW *table,const char*file_in, const char *file_out);

//Get String, and finds any available code, internal use
int lzw_get_string(LZW *table, int code_number);
int lzw_find_code(LZW *table, int string_buffer, int character);

//These deal with retrieving and sending codes,
//Bit manipulation fone here, internal use
int lzw_write_code(LZW *table,FILE *fp, unsigned int code);
int lzw_get_code(LZW *table,FILE *fp);
int lzw_flush_write_code(LZW *table,FILE *fp);

⌨️ 快捷键说明

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