File: HTGIFStr.html

package info (click to toggle)
xmhtml 1.1.7-18
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 6,576 kB
  • sloc: ansic: 68,174; makefile: 438; sh: 158; perl: 36
file content (211 lines) | stat: -rw-r--r-- 7,269 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
	<TITLE>XmHTML Programmers Manual: XmHTMLGIFStream Structure</TITLE>
	<META HTTP-EQUIV="Keywords" CONTENT="XmHTML, HTML, Motif, Widget, eXode, XntHelp, Linux">
	<META HTTP-EQUIV="Reply-to" CONTENT="ripley@xs4all.nl">
	<META HTTP-EQUIV="Description" CONTENT = "XmHTMLGIFStream - XmHTML External GIF Decoder Interface Definition.">
	<META NAME="Author" CONTENT="Koen D'Hondt">
	<META NAME="Copyright" content="1995-1997 by Ripley Software Development">
	<META NAME="Source" content="$Source$">
	<META NAME="Revision" content="$Revision$">
	<META NAME="Font" content="helvetica">
	<link rev="made" href="mailto:ripley@xs4all.nl">
	<link rel="home" href="index.html">
	<link rel="previous" href="HTPLCStr.html">
	<link rel="up" href="../man.html">
	<link rel="copyright" href="copyrights.html">
</HEAD>

<BODY BGCOLOR="#FFFFFF" text="#000000">
<h3><font face="helvetica,arial">Name</font></h3>

<blockquote>
	XmHTMLGIFStream structure - XmHTML External GIF Decoder Interface
	Definition.
</blockquote>

<h3><font face="helvetica,arial">Description</font></h3>

<blockquote>
	The XmHTMLGIFStream structure is the sole argument to any function
	installed on the XmNdecodeGIFProc resource of a XmHTML Widget or the
	gif_proc field of the XmImage structure.
	<p>

	This interface definition allows one to override the default GIF
	decoder employed by a XmHTML Widget.
	<p>

	You might ask yourself: Why is this beast even present?
	The answer is that the
	image data in a GIF image is stored using the LZW (Lev-Zempel-Welch)
	compression method, the patent of which is owned by Unisys Corp.
	In order to use this algorithm (for either compression or decompression
	of compressed data), Unisys Corp. requires one to obtain a (costly)
	license. The default GIF decoded used by a XmHTML widget employs a
	work-around method (which involves the use of <tt>compress(1)</tt> or
	<tt>gzip(1)</tt>) that is a tad slower when compared with a real
	LZW decoder.
	<p>

	The XmHTMLGIFStream structure and XmImageGifProc prototype allow holders
	of a LZW patent and authors of free software to surpass this workaround
	and hence achieve a (small to considerable) performance increase.
	<p>

</blockquote>

<h3><font face="helvetica,arial">Structures</font></h3>

<pre>
	/* Prototype for the XmNdecodeGIFProc resource */
	typedef int (*XmImageGifProc)(XmHTMLGIFStream*);

	/*
	 * Possible return values for the XmNdecodeGIFProc resource and 
	 * values for the XmHTMLGIFStream state field.
	 */

	#define GIF_STREAM_OK		 2
	#define GIF_STREAM_END		 1
	#define GIF_STREAM_ERR		 0
	#define GIF_STREAM_INIT		-1
	#define GIF_STREAM_FINAL	-2

	/* XmHTMLGIFStream definition */

	typedef struct _XmHTMLGIFStream{
	    /* read-only fields */
	    int state;                  /* decoder state                        */
	    int codesize;               /* initial LZW codesize                 */
	    Boolean is_progressive;     /* when used by a progressive loader    */
	    unsigned char *next_in;     /* next input byte                      */
	    Cardinal avail_in;          /* number of bytes available at next_in */
	    Cardinal total_in;          /* total nb of input bytes read so far  */

	    /* fields to be updated by caller */
	    unsigned char *next_out;    /* next output byte should be put here  */
	    Cardinal avail_out;         /* remaining free space at next_out     */
	    Cardinal total_out;         /* total nb of bytes outputted so far   */

	    String msg;                 /* last error message, or NULL          */
	    XtPointer external_state;   /* room for decoder-specific data       */
	}XmHTMLGIFStream;

</pre>

<h3><font face="helvetica,arial">Examples</font></h3>

<blockquote>
	Shown below is a typical example of a custom GIF decoder that
	demonstrates the proper use of the XmHTMLGIFStream structure.
</blockquote>
<pre>
	int decodeGIF(XmHTMLGIFStream *gstream)
	{
	    int v;
	    unsigned char *dp;

	    /* XmHTML is initializing itself */
	    if(gstream-&gt;state == GIF_STREAM_INIT )
	    {
	        gstream-&gt;external_state = some_LZW_init_func(gstream-&gt;codesize);
	        /* and return OK */
	        return(GIF_STREAM_OK);
	    }

	    /* end-of-data ? */
	    if(gstream-&gt;state == GIF_STREAM_FINAL ||
	        gstream-&gt;state == GIF_STREAM_END )
	    {
	        some_LZW_cleanup_func(gstream-&gt;external_state);
	        return(GIF_STREAM_END);
	    }

	    /* current position in decoded output buffer */
	    dp = gstream-&gt;next_out;

	    for( ; gstream-&gt;avail_out ; gstream-&gt;total_out++,
	        gstream-&gt;avail_out-- )
	    {
	        if((v = some_LZW_decoder_func(gstream-&gt;external_state))
	            &lt; some_valid_value)
	        {
	            if(v == some_end_of_data_signal)
	                return(GIF_STREAM_END);
	            /* processed all current data */
	            return(GIF_STREAM_OK);
	        }
	        *dp++ = v;
	    }
	    /* end if we run out of data */
	    return(gstream-&gt;avail_out ? GIF_STREAM_OK : GIF_STREAM_END);
	}
</pre>
	

<h3><font face="helvetica,arial">Disclaimer</font></h3>

<blockquote>
	<tt>
    THIS INFORMATION IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND.  THE
	AUTHOR
    SHALL HAVE NO LIABILITY WITH RESPECT TO THE INFRINGEMENT OF COPYRIGHTS,
    TRADE SECRETS OR ANY PATENTS BY THIS FILE OR ANY PART THEREOF.  IN NO
    EVENT WILL THE AUTHOR BE LIABLE FOR ANY LOST REVENUE OR PROFITS OR
    OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL DAMAGES.
	</tt>
	<p>

	<tt>
    IF YOU DECIDE TO USE THE INFORMATION CONTAINED IN THIS FILE TO CONSTRUCT
    AND USE THE LZW ALGORITHM YOU AGREE TO ACCEPT FULL RESPONSIBILITY WITH
    RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRECTS OR ANY PATENTS.
    IN NO EVENT WILL THE AUTHOR BE LIABLE FOR ANY LOST REVENUE OR PROFITS OR
    OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL DAMAGES, INCLUDING BUT NOT
    LIMITED TO ANY DAMAGES RESULTING FROM ANY ACTIONS IN A COURT OF LAW.
	</tt>
	<p>

	<tt>
    YOU ARE HEREBY WARNED THAT USE OF THE LZW ALGORITHM WITHOUT HAVING
    OBTAINED A PROPER LICENSE FROM UNISYS CONSTITUTES A VIOLATION OF
    APPLICABLE PATENT LAW. AS SUCH YOU WILL BE HELD LEGALLY RESPONSIBLE FOR
    ANY INFRINGEMENT OF THE UNISYS LZW PATENT.
	</tt>
	<p>

	<tt>
    UNISYS REQUIRES YOU TO HAVE A LZW LICENSE FOR EVERY TASK IN WHICH THE
    LZW ALGORITHM IS BEING USED (WHICH INCLUDES DECODING THE LZW COMPRESSED
    RASTER DATA AS FOUND IN GIF IMAGES). THE FACT THAT YOUR APPLICATION MAY
    OR MAY NOT BE DISTRIBUTED AS SHAREWARE IS OF NO CONCERN TO UNISYS.
	</tt>
	<p>

	<tt>
    IF YOU RESIDE IN A COUNTRY WHERE SOFTWARE PATENT LAWS DO NOT APPLY,
    PLEASE BE WARNED THAT EXPORTING SOFTWARE CONTAINING THE LZW ALGORITHM TO
    COUNTRIES WHERE SOFTWARE PATENT LAW *DOES* APPLY WITHOUT A VALID LICENSE
    ALSO CONSTITUTES A VIOLATION OF PATENT LAW IN THE COUNTRY OF DESTINATION.
	</tt>
	<p>

	The Unisys Corporation Licensing Department can be contacted at
	lzw_info@unisys.com.
</blockquote>
    
<h3><font face="helvetica,arial">See Also</font></h3>

<blockquote>
	XmHTML(3X), XmImage(3X), U.S. Patent 4,558,302
</blockquote>

<hr noshade size="2" width="25%">
<i><font size="-1">
XmHTML, October 7, 1997
</font></i>
</body>
</html>