WXP C++ Library Version 6.74.9
Loading...
Searching...
No Matches
LZWComp.h
1#ifndef _WINC_LZWCOMP
2#define _WINC_LZWCOMP
3
4#include <WXP/File.h>
5#include <WXP/Image.h>
6
7namespace WXP {
8#define MAX_COLOR 256
9
10 class LZWComp {
11 File file; /* The file */
12 int access;
13 bool opened;
14 unsigned char data[1000]; /* Data buffer */
15 unsigned char *ptr; /* Pointer to data array */
16 int width; /* Width of image */
17 int height; /* Height of image */
18 int depth; /* Depth of image */
19 int use_inter;
20 int trans;
21 /*
22 Read parameters
23 */
24 int glob_color_exist; /* Specifies whether global color table exists */
25 int glob_color_size; /* Specifies global color table size */
26 int local_color_exist; /* Specifies whether local color table exists */
27 int local_color_size; /* Specifies local color table size */
28
29 int data_size; /* Data array size */
30 int data_ind; /* Index into data array */
31 /*
32 Data codes
33 */
34 int code_size; /* Initial coded data bit size */
35 int clear_code; /* Clear code */
36 int end_info_code; /* End of information code */
37 int coded_data; /* Current coded information */
38 int coded_prev; /* Previous piece of coded data */
39 int coded_mask; /* Coded data mask used to read in data */
40 int coded_size; /* Current coded data bit size */
41 /*
42 String table
43 */
44 int tab_pfix[4096];
45 int tab_ext[4096];
46 int tab_ind; /* Pointer into the string table */
47 /*
48 Pixel stack
49 */
50 int pix_stack[5000]; /* The pixel stack */
51 int pix_ptr; /* Pointer into the pixel stack */
52
53 unsigned int data_bits; /* Number bits encoded into current byte */
54 unsigned int temp_data; /* Temporary storage for current byte */
55
56 /*
57 Encode hash table
58 */
59 struct HashNode {
60 int hash;
61 int val;
62 HashNode *next;
63 };
64
65 HashNode *htable[4096];
66 int hnodes;
67
68 unsigned int cur_data; /* Current pixel,encoded data */
69 unsigned int prev_data; /* Previous encoded data */
70 int out_bytes; /* Number of bytes written to output file */
71 int num_pixel; /* Number of pixels read in from file */
72
73 int file_num;
74 int loop_end_delay; /* Delay */
75 int loop_delay; /* Delay */
76
77 public:
78 LZWComp();
79 ~LZWComp();
80 int init();
81
82 LZWComp( const char *filename, int access );
83 int open( const char *filename, int access );
84 bool isOpen();
85 int close();
86 int setInterlace( int val );
87 /*
88 Decode routines
89 */
90 int read( Image &image );
91 private:
92 int readData();
93 int pushPix( int val );
94 int popPix();
95 /*
96 Encode routines
97 */
98 public:
99 int write( Image &image );
100 int write( const char *file );
101 private:
102 int outCode( unsigned int code );
103 int clearTable();
104 };
105}
106#endif
This class accesses files.
Definition File.h:15
This class defines an image.
Definition Image.h:19
This class reads and writes GIF files.
Definition LZWComp.h:10
~LZWComp()
Definition LZWComp.cc:48
int write(Image &image)
Definition LZWComp.cc:479
int read(Image &image)
Definition LZWComp.cc:112
int init()
Definition LZWComp.cc:55
int close()
Definition LZWComp.cc:93
LZWComp()
Definition LZWComp.cc:31
int setInterlace(int val)
Definition LZWComp.cc:103
bool isOpen()
Definition LZWComp.cc:86
int open(const char *filename, int access)
Definition LZWComp.cc:69
All WXP classes fall under the WXP namespace.
Definition Angle.h:4