NetBurner 3.5.6
PDF Version
Web/GifCanvas/src/gifCompress.h
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
5/*-----------------------------------------------------------------------
6 *
7 * miGIF Compression - mouse and ivo's GIF-compatible compression
8 *
9 * -run length encoding compression routines-
10 *
11 * Copyright (C) 1998 Hutchison Avenue Software Corporation
12 * http://www.hasc.com
14 *
15 * Permission to use, copy, modify, and distribute this software and its
16 * documentation for any purpose and without fee is hereby granted, provided
17 * that the above copyright notice appear in all copies and that both that
18 * copyright notice and this permission notice appear in supporting
19 * documentation. This software is provided "AS IS." The Hutchison Avenue
20 * Software Corporation disclaims all warranties, either express or implied,
21 * including but not limited to implied warranties of merchantability and
22 * fitness for a particular purpose, with respect to this code and accompanying
23 * documentation.
24 *
25 * The miGIF compression routines do not, strictly speaking, generate files
26 * conforming to the GIF spec, since the image data is not LZW-compressed
27 * (this is the point: in order to avoid transgression of the Unisys patent
28 * on the LZW algorithm.) However, miGIF generates data streams that any
29 * reasonably sane LZW decompresser will decompress to what we want.
30 *
31 * miGIF compression uses run length encoding. It compresses horizontal runs
32 * of pixels of the same color. This type of compression gives good results
33 * on images with many runs, for example images with lines, text and solid
34 * shapes on a solid-colored background. It gives little or no compression
35 * on images with few runs, for example digital or scanned photos.
36 *
37 * der Mouse
39 * 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
40 *
42 *
43 * The Graphics Interchange Format(c) is the Copyright property of
44 * CompuServe Incorporated. GIF(sm) is a Service Mark property of
45 * CompuServe Incorporated.
46 */
47
48#ifndef _GIT_COMPRESS_H_
49#define _GIT_COMPRESS_H_
50#pragma once
51
52#define GIFBITS 12
53
54//#include "drawimage.h"
55
56class DrawImageObject;
57
58class GitCompress
59{
60 public:
61 GitCompress();
62 void ResetStatistics();
63 void compress(DrawImageObject &dio, int init_bits, int fd);
64
65 private:
66 void write_block(void);
67 void block_out(unsigned char c);
68 void block_flush(void);
69 void output(int val);
70 void output_flush(void);
71 void did_clear(void);
72 void output_plain(int c);
73 unsigned int isqrt(unsigned int x);
74 unsigned int compute_triangle_count(unsigned int count, unsigned int nrepcodes);
75 void max_out_clear(void);
76 void reset_out_clear(void);
77 void rl_flush_fromclear(int count);
78 void rl_flush_clearorrep(int count);
79 void rl_flush_withtable(int count);
80 void rl_flush(void);
81
82 int rl_pixel = 0;
83 int rl_basecode = 0;
84 int rl_count = 0;
85 int rl_table_pixel = 0;
86 int rl_table_max = 0;
87 int just_cleared = 0;
88 int out_bits = 0;
89 int out_bits_init = 0;
90 int out_count = 0;
91 int out_bump = 0;
92 int out_bump_init = 0;
93 int out_clear = 0;
94 int out_clear_init = 0;
95 int max_ocodes = 0;
96 int code_clear = 0;
97 int code_eof = 0;
98 unsigned int obuf = 0;
99 int obits = 0;
100 int ofd = 0;
101 int oblen = 0;
102 unsigned char oblock[256];
103 bool m_transparent = false;
104};
105
106#endif /* _GIT_COMPRESS_H_ */
107
108/*-----------------------------------------------------------------------
109 *
110 * End of miGIF section - See copyright notice at start of section.
111 *
112 *-----------------------------------------------------------------------*/