dvi2bitmap  dvi2bitmap1.0
GIFBitmap.h
Go to the documentation of this file.
1 /* This file is part of dvi2bitmap; see README for copyrights and licence */
2 
3 #ifndef GIFBITMAP_HEADER_READ
4 #define GIFBITMAP_HEADER_READ 1
5 
6 #include "BitmapImage.h"
7 #ifdef HAVE_CSTD_INCLUDE
8 #include <cstdio>
9 #else
10 #include <stdio.h>
11 #endif
12 
13 typedef int code_int;
14 #ifdef SIGNED_COMPARE_SLOW
15 typedef unsigned long int count_int;
16 typedef unsigned short int count_short;
17 #else /*SIGNED_COMPARE_SLOW*/
18 typedef long int count_int;
19 #endif /*SIGNED_COMPARE_SLOW*/
20 
21 class GIFBitmap : public BitmapImage {
22  public:
23  //GIFBitmap (int w, int h, Byte *b, int bpp=1);
24  GIFBitmap (const int w, const int h, const int bpp=1);
25  ~GIFBitmap ();
26  void setBitmap (const Byte *b);
27  void setBitmapRow (const Byte *b);
28  //void setTransparent (const bool sw) { transparent_ = sw; }
29  void write (const string filename);
30  string fileExtension() const { return "gif"; }
31 
32  private:
33  //const Byte *bitmap_;
34  //Byte *allocBitmap_;
35  //const int w_, h_;
36  //const int bpp_;
37  //int bitmapRows_;
38  //bool transparent_;
39  //bool myBitmap_;
40  void GIFEncode(FILE* fp,
41  int GWidth, int GHeight,
42  int GInterlace,
43  int Background,
44  int Transparent,
45  int BitsPerPixel,
46  int *Red, int *Green, int *Blue);
47  void BumpPixel(void);
48  int GIFNextPixel(void);
49  void Putword(int w, FILE* fp);
50  void compress(int init_bits, FILE* outfile);
51  void output(code_int code);
52  void cl_block (void);
53  void cl_hash(count_int hsize);
54  void char_init(void);
55  void char_out( int c );
56  void flush_char();
57 
58  // remainder are the static globals which were in
59  // the original GIFENCOD routine
60  int Width, Height;
61  int curx, cury;
62  long CountDown;
63  int Pass;
64  int Interlace;
65 
66 #if 0
67  const int BITS = 12;
68  const int HSIZE = 5003; /* 80% occupancy */
69 #endif
70 #define BITS 12
71 #define HSIZE 5003
72 
73  int n_bits; /* number of bits/code */
74  int maxbits; /* user settable max # bits/code */
75  code_int maxcode; /* maximum code, given n_bits */
76  code_int maxmaxcode; /* should NEVER generate this code */
77 
78  count_int htab [HSIZE];
79  unsigned short codetab [HSIZE];
80  code_int hsize; /* for dynamic table sizing */
81 
82  code_int free_ent; /* first unused entry */
83 
84  int clear_flg;
85 
86  int offset;
87  long int in_count; /* length of input */
88  long int out_count; /* # of codes output (for debugging) */
89 
90  int g_init_bits;
91  FILE* g_outfile;
92 
93  int ClearCode;
94  int EOFCode;
95 
96  unsigned long cur_accum;
97  int cur_bits;
98 
99  int a_count;
100  char accum[ 256 ];
101 
102  static const unsigned long masks[];
103 };
104 #endif // #ifndef GIFBITMAP_HEADER_READ