xref: /utopia/UTPA2-700.0.x/modules/gpd/drv/gpd/gif_lib.h (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1*53ee8cc1Swenshuai.xi //<MStar Software>
2*53ee8cc1Swenshuai.xi //******************************************************************************
3*53ee8cc1Swenshuai.xi // MStar Software
4*53ee8cc1Swenshuai.xi // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5*53ee8cc1Swenshuai.xi // All software, firmware and related documentation herein ("MStar Software") are
6*53ee8cc1Swenshuai.xi // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7*53ee8cc1Swenshuai.xi // law, including, but not limited to, copyright law and international treaties.
8*53ee8cc1Swenshuai.xi // Any use, modification, reproduction, retransmission, or republication of all
9*53ee8cc1Swenshuai.xi // or part of MStar Software is expressly prohibited, unless prior written
10*53ee8cc1Swenshuai.xi // permission has been granted by MStar.
11*53ee8cc1Swenshuai.xi //
12*53ee8cc1Swenshuai.xi // By accessing, browsing and/or using MStar Software, you acknowledge that you
13*53ee8cc1Swenshuai.xi // have read, understood, and agree, to be bound by below terms ("Terms") and to
14*53ee8cc1Swenshuai.xi // comply with all applicable laws and regulations:
15*53ee8cc1Swenshuai.xi //
16*53ee8cc1Swenshuai.xi // 1. MStar shall retain any and all right, ownership and interest to MStar
17*53ee8cc1Swenshuai.xi //    Software and any modification/derivatives thereof.
18*53ee8cc1Swenshuai.xi //    No right, ownership, or interest to MStar Software and any
19*53ee8cc1Swenshuai.xi //    modification/derivatives thereof is transferred to you under Terms.
20*53ee8cc1Swenshuai.xi //
21*53ee8cc1Swenshuai.xi // 2. You understand that MStar Software might include, incorporate or be
22*53ee8cc1Swenshuai.xi //    supplied together with third party`s software and the use of MStar
23*53ee8cc1Swenshuai.xi //    Software may require additional licenses from third parties.
24*53ee8cc1Swenshuai.xi //    Therefore, you hereby agree it is your sole responsibility to separately
25*53ee8cc1Swenshuai.xi //    obtain any and all third party right and license necessary for your use of
26*53ee8cc1Swenshuai.xi //    such third party`s software.
27*53ee8cc1Swenshuai.xi //
28*53ee8cc1Swenshuai.xi // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29*53ee8cc1Swenshuai.xi //    MStar`s confidential information and you agree to keep MStar`s
30*53ee8cc1Swenshuai.xi //    confidential information in strictest confidence and not disclose to any
31*53ee8cc1Swenshuai.xi //    third party.
32*53ee8cc1Swenshuai.xi //
33*53ee8cc1Swenshuai.xi // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34*53ee8cc1Swenshuai.xi //    kind. Any warranties are hereby expressly disclaimed by MStar, including
35*53ee8cc1Swenshuai.xi //    without limitation, any warranties of merchantability, non-infringement of
36*53ee8cc1Swenshuai.xi //    intellectual property rights, fitness for a particular purpose, error free
37*53ee8cc1Swenshuai.xi //    and in conformity with any international standard.  You agree to waive any
38*53ee8cc1Swenshuai.xi //    claim against MStar for any loss, damage, cost or expense that you may
39*53ee8cc1Swenshuai.xi //    incur related to your use of MStar Software.
40*53ee8cc1Swenshuai.xi //    In no event shall MStar be liable for any direct, indirect, incidental or
41*53ee8cc1Swenshuai.xi //    consequential damages, including without limitation, lost of profit or
42*53ee8cc1Swenshuai.xi //    revenues, lost or damage of data, and unauthorized system use.
43*53ee8cc1Swenshuai.xi //    You agree that this Section 4 shall still apply without being affected
44*53ee8cc1Swenshuai.xi //    even if MStar Software has been modified by MStar in accordance with your
45*53ee8cc1Swenshuai.xi //    request or instruction for your use, except otherwise agreed by both
46*53ee8cc1Swenshuai.xi //    parties in writing.
47*53ee8cc1Swenshuai.xi //
48*53ee8cc1Swenshuai.xi // 5. If requested, MStar may from time to time provide technical supports or
49*53ee8cc1Swenshuai.xi //    services in relation with MStar Software to you for your use of
50*53ee8cc1Swenshuai.xi //    MStar Software in conjunction with your or your customer`s product
51*53ee8cc1Swenshuai.xi //    ("Services").
52*53ee8cc1Swenshuai.xi //    You understand and agree that, except otherwise agreed by both parties in
53*53ee8cc1Swenshuai.xi //    writing, Services are provided on an "AS IS" basis and the warranty
54*53ee8cc1Swenshuai.xi //    disclaimer set forth in Section 4 above shall apply.
55*53ee8cc1Swenshuai.xi //
56*53ee8cc1Swenshuai.xi // 6. Nothing contained herein shall be construed as by implication, estoppels
57*53ee8cc1Swenshuai.xi //    or otherwise:
58*53ee8cc1Swenshuai.xi //    (a) conferring any license or right to use MStar name, trademark, service
59*53ee8cc1Swenshuai.xi //        mark, symbol or any other identification;
60*53ee8cc1Swenshuai.xi //    (b) obligating MStar or any of its affiliates to furnish any person,
61*53ee8cc1Swenshuai.xi //        including without limitation, you and your customers, any assistance
62*53ee8cc1Swenshuai.xi //        of any kind whatsoever, or any information; or
63*53ee8cc1Swenshuai.xi //    (c) conferring any license or right under any intellectual property right.
64*53ee8cc1Swenshuai.xi //
65*53ee8cc1Swenshuai.xi // 7. These terms shall be governed by and construed in accordance with the laws
66*53ee8cc1Swenshuai.xi //    of Taiwan, R.O.C., excluding its conflict of law rules.
67*53ee8cc1Swenshuai.xi //    Any and all dispute arising out hereof or related hereto shall be finally
68*53ee8cc1Swenshuai.xi //    settled by arbitration referred to the Chinese Arbitration Association,
69*53ee8cc1Swenshuai.xi //    Taipei in accordance with the ROC Arbitration Law and the Arbitration
70*53ee8cc1Swenshuai.xi //    Rules of the Association by three (3) arbitrators appointed in accordance
71*53ee8cc1Swenshuai.xi //    with the said Rules.
72*53ee8cc1Swenshuai.xi //    The place of arbitration shall be in Taipei, Taiwan and the language shall
73*53ee8cc1Swenshuai.xi //    be English.
74*53ee8cc1Swenshuai.xi //    The arbitration award shall be final and binding to both parties.
75*53ee8cc1Swenshuai.xi //
76*53ee8cc1Swenshuai.xi //******************************************************************************
77*53ee8cc1Swenshuai.xi //<MStar Software>
78*53ee8cc1Swenshuai.xi /******************************************************************************
79*53ee8cc1Swenshuai.xi * In order to make life a little bit easier when using the GIF file format,   *
80*53ee8cc1Swenshuai.xi * this library was written, and which does all the dirty work...              *
81*53ee8cc1Swenshuai.xi *                                                                             *
82*53ee8cc1Swenshuai.xi *                                        Written by Gershon Elber,  Jun. 1989 *
83*53ee8cc1Swenshuai.xi *                                        Hacks by Eric S. Raymond,  Sep. 1992 *
84*53ee8cc1Swenshuai.xi *******************************************************************************
85*53ee8cc1Swenshuai.xi * History:                                                                    *
86*53ee8cc1Swenshuai.xi * 14 Jun 89 - Version 1.0 by Gershon Elber.                                   *
87*53ee8cc1Swenshuai.xi *  3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names)  *
88*53ee8cc1Swenshuai.xi * 15 Sep 90 - Version 2.0 by Eric S. Raymond (Changes to suoport GIF slurp)   *
89*53ee8cc1Swenshuai.xi * 26 Jun 96 - Version 3.0 by Eric S. Raymond (Full GIF89 support)             *
90*53ee8cc1Swenshuai.xi * 17 Dec 98 - Version 4.0 by Toshio Kuratomi (Fix extension writing code)     *
91*53ee8cc1Swenshuai.xi ******************************************************************************/
92*53ee8cc1Swenshuai.xi 
93*53ee8cc1Swenshuai.xi #ifndef _GIF_LIB_H
94*53ee8cc1Swenshuai.xi #define _GIF_LIB_H
95*53ee8cc1Swenshuai.xi 
96*53ee8cc1Swenshuai.xi #include "gpd.h"
97*53ee8cc1Swenshuai.xi 
98*53ee8cc1Swenshuai.xi #define GIF_LIB_VERSION	" Version 4.0, "
99*53ee8cc1Swenshuai.xi 
100*53ee8cc1Swenshuai.xi //#define SW_DEC
101*53ee8cc1Swenshuai.xi 
102*53ee8cc1Swenshuai.xi #define	GIF_ERROR	0
103*53ee8cc1Swenshuai.xi #define GIF_OK		1
104*53ee8cc1Swenshuai.xi 
105*53ee8cc1Swenshuai.xi #ifndef SUPPORT_MGIF
106*53ee8cc1Swenshuai.xi #define SUPPORT_MGIF 1
107*53ee8cc1Swenshuai.xi #endif
108*53ee8cc1Swenshuai.xi 
109*53ee8cc1Swenshuai.xi #ifndef NO_SUPPORT_MGIF
110*53ee8cc1Swenshuai.xi #define NO_SUPPORT_MGIF 0
111*53ee8cc1Swenshuai.xi #endif
112*53ee8cc1Swenshuai.xi 
113*53ee8cc1Swenshuai.xi #ifndef TRUE
114*53ee8cc1Swenshuai.xi #define TRUE		1
115*53ee8cc1Swenshuai.xi #define FALSE		0
116*53ee8cc1Swenshuai.xi #endif
117*53ee8cc1Swenshuai.xi 
118*53ee8cc1Swenshuai.xi #ifndef NULL
119*53ee8cc1Swenshuai.xi #define NULL		0
120*53ee8cc1Swenshuai.xi #endif /* NULL */
121*53ee8cc1Swenshuai.xi 
122*53ee8cc1Swenshuai.xi #define GIF_STAMP "GIFVER"          /* First chars in file - GIF stamp.  */
123*53ee8cc1Swenshuai.xi #define GIF_STAMP_LEN sizeof(GIF_STAMP) - 1
124*53ee8cc1Swenshuai.xi #define GIF_VERSION_POS	3           /* Version first character in stamp. */
125*53ee8cc1Swenshuai.xi #define GIF87_STAMP	"GIF87a"        /* First chars in file - GIF stamp.  */
126*53ee8cc1Swenshuai.xi #define GIF89_STAMP	"GIF89a"        /* First chars in file - GIF stamp.  */
127*53ee8cc1Swenshuai.xi 
128*53ee8cc1Swenshuai.xi #define GIF_FILE_BUFFER_SIZE 16384  /* Files uses bigger buffers than usual. */
129*53ee8cc1Swenshuai.xi 
130*53ee8cc1Swenshuai.xi typedef	int		GifBooleanType;
131*53ee8cc1Swenshuai.xi typedef	MS_U8	GifPixelType;
132*53ee8cc1Swenshuai.xi typedef MS_U8 *	GifRowType;
133*53ee8cc1Swenshuai.xi typedef MS_U8	GifByteType;
134*53ee8cc1Swenshuai.xi 
135*53ee8cc1Swenshuai.xi #ifdef SYSV
136*53ee8cc1Swenshuai.xi #define VoidPtr char *
137*53ee8cc1Swenshuai.xi #else
138*53ee8cc1Swenshuai.xi #define VoidPtr void *
139*53ee8cc1Swenshuai.xi #endif /* SYSV */
140*53ee8cc1Swenshuai.xi 
141*53ee8cc1Swenshuai.xi typedef struct GifColorType {
142*53ee8cc1Swenshuai.xi     GifByteType Red, Green, Blue;
143*53ee8cc1Swenshuai.xi } GifColorType;
144*53ee8cc1Swenshuai.xi 
145*53ee8cc1Swenshuai.xi typedef struct ColorMapObject
146*53ee8cc1Swenshuai.xi {
147*53ee8cc1Swenshuai.xi     int	ColorCount;
148*53ee8cc1Swenshuai.xi     MS_U32 BitsPerPixel;
149*53ee8cc1Swenshuai.xi     GifColorType *Colors;		/* on malloc(3) heap */
150*53ee8cc1Swenshuai.xi }
151*53ee8cc1Swenshuai.xi ColorMapObject;
152*53ee8cc1Swenshuai.xi 
153*53ee8cc1Swenshuai.xi typedef struct GifImageDesc {
154*53ee8cc1Swenshuai.xi     MS_U32 Left, Top, Width, Height,	/* Current image dimensions. */
155*53ee8cc1Swenshuai.xi 	Interlace;			/* Sequential/Interlaced lines. */
156*53ee8cc1Swenshuai.xi     ColorMapObject *ColorMap;		/* The local color map */
157*53ee8cc1Swenshuai.xi } GifImageDesc;
158*53ee8cc1Swenshuai.xi 
159*53ee8cc1Swenshuai.xi typedef struct GifGraphicCtrl {
160*53ee8cc1Swenshuai.xi     MS_U32 enable;
161*53ee8cc1Swenshuai.xi     MS_U32 disposal_method;
162*53ee8cc1Swenshuai.xi     MS_U32 time;
163*53ee8cc1Swenshuai.xi     MS_U32 trans_bit;
164*53ee8cc1Swenshuai.xi     MS_U32 trans_idx;
165*53ee8cc1Swenshuai.xi } GifGraphicCtrl;
166*53ee8cc1Swenshuai.xi 
167*53ee8cc1Swenshuai.xi typedef struct GifFileType {
168*53ee8cc1Swenshuai.xi     MS_U32 SWidth, SHeight;		/* Screen dimensions. */
169*53ee8cc1Swenshuai.xi 	MS_U32 SColorResolution, 		/* How many colors can we generate? */
170*53ee8cc1Swenshuai.xi 	SBackGroundColor,		/* I hope you understand this one... */
171*53ee8cc1Swenshuai.xi 	AspectRatio;            /* from 89a*/
172*53ee8cc1Swenshuai.xi     ColorMapObject *SColorMap;		/* NULL if not exists. */
173*53ee8cc1Swenshuai.xi     MS_U32 ImageCount;			/* Number of current image */
174*53ee8cc1Swenshuai.xi     GifImageDesc Image;			/* Block describing current image */
175*53ee8cc1Swenshuai.xi     GifGraphicCtrl GraphicCtrl;
176*53ee8cc1Swenshuai.xi     struct SavedImage *SavedImages;	/* Use this to accumulate file state */
177*53ee8cc1Swenshuai.xi     MS_VIRT UserData;           /* hook to attach user data (TVT) */
178*53ee8cc1Swenshuai.xi     VoidPtr Private;	  		/* Don't mess with this! */
179*53ee8cc1Swenshuai.xi     MS_U32  GifState;     /*record the decode state*/
180*53ee8cc1Swenshuai.xi     MS_U32 isMGIF;                 /*record the current GIF picture is animate or static*/
181*53ee8cc1Swenshuai.xi } GifFileType;
182*53ee8cc1Swenshuai.xi 
183*53ee8cc1Swenshuai.xi typedef enum {
184*53ee8cc1Swenshuai.xi     UNDEFINED_RECORD_TYPE,
185*53ee8cc1Swenshuai.xi     SCREEN_DESC_RECORD_TYPE,
186*53ee8cc1Swenshuai.xi     IMAGE_DESC_RECORD_TYPE,		/* Begin with ',' */
187*53ee8cc1Swenshuai.xi     EXTENSION_RECORD_TYPE,		/* Begin with '!' */
188*53ee8cc1Swenshuai.xi     TERMINATE_RECORD_TYPE		/* Begin with ';' */
189*53ee8cc1Swenshuai.xi } GifRecordType;
190*53ee8cc1Swenshuai.xi 
191*53ee8cc1Swenshuai.xi 
192*53ee8cc1Swenshuai.xi typedef enum {
193*53ee8cc1Swenshuai.xi     STATE_MGIF_TERMINATE,
194*53ee8cc1Swenshuai.xi     STATE_GIF_ERROR,
195*53ee8cc1Swenshuai.xi     STATE_MGIF_WAIT_BUFFFER,
196*53ee8cc1Swenshuai.xi     STATE_GIF_SUCCESS
197*53ee8cc1Swenshuai.xi } GifState;
198*53ee8cc1Swenshuai.xi 
199*53ee8cc1Swenshuai.xi /* DumpScreen2Gif routine constants identify type of window/screen to dump.  */
200*53ee8cc1Swenshuai.xi /* Note all values below 1000 are reserved for the IBMPC different display   */
201*53ee8cc1Swenshuai.xi /* devices (it has many!) and are compatible with the numbering TC2.0        */
202*53ee8cc1Swenshuai.xi /* (Turbo C 2.0 compiler for IBM PC) gives to these devices.		     */
203*53ee8cc1Swenshuai.xi typedef enum {
204*53ee8cc1Swenshuai.xi     GIF_DUMP_SGI_WINDOW = 1000,
205*53ee8cc1Swenshuai.xi     GIF_DUMP_X_WINDOW = 1001
206*53ee8cc1Swenshuai.xi } GifScreenDumpType;
207*53ee8cc1Swenshuai.xi 
208*53ee8cc1Swenshuai.xi /* func type to read gif data from arbitrary sources (TVT) */
209*53ee8cc1Swenshuai.xi typedef MS_U32 (*InputFunc)(GifFileType*,GifByteType*,int);
210*53ee8cc1Swenshuai.xi 
211*53ee8cc1Swenshuai.xi /* func type to write gif data ro arbitrary targets.
212*53ee8cc1Swenshuai.xi  * Returns count of bytes written. (MRB)
213*53ee8cc1Swenshuai.xi  */
214*53ee8cc1Swenshuai.xi typedef MS_U32 (*OutputFunc)(GifFileType *, const GifByteType *, int);
215*53ee8cc1Swenshuai.xi /******************************************************************************
216*53ee8cc1Swenshuai.xi *  GIF89 extension function codes                                             *
217*53ee8cc1Swenshuai.xi ******************************************************************************/
218*53ee8cc1Swenshuai.xi 
219*53ee8cc1Swenshuai.xi #define COMMENT_EXT_FUNC_CODE		0xfe	/* comment */
220*53ee8cc1Swenshuai.xi #define GRAPHICS_EXT_FUNC_CODE		0xf9	/* graphics control */
221*53ee8cc1Swenshuai.xi #define PLAINTEXT_EXT_FUNC_CODE		0x01	/* plaintext */
222*53ee8cc1Swenshuai.xi #define APPLICATION_EXT_FUNC_CODE	0xff	/* application block */
223*53ee8cc1Swenshuai.xi 
224*53ee8cc1Swenshuai.xi /******************************************************************************
225*53ee8cc1Swenshuai.xi * O.K., here are the routines one can access in order to encode GIF file:     *
226*53ee8cc1Swenshuai.xi * (GIF_LIB file EGIF_LIB.C).						      *
227*53ee8cc1Swenshuai.xi ******************************************************************************/
228*53ee8cc1Swenshuai.xi 
229*53ee8cc1Swenshuai.xi GifFileType *EGifOpenFileName(const char *GifFileName, MS_U32 GifTestExistance);
230*53ee8cc1Swenshuai.xi GifFileType *EGifOpenFileHandle(MS_U32 GifFileHandle);
231*53ee8cc1Swenshuai.xi GifFileType *EgifOpen(void *userPtr, OutputFunc writeFunc);
232*53ee8cc1Swenshuai.xi MS_U32 EGifSpew(GifFileType *GifFile);
233*53ee8cc1Swenshuai.xi void EGifSetGifVersion(const char *Version);
234*53ee8cc1Swenshuai.xi MS_U32 EGifPutScreenDesc(GifFileType *GifFile,
235*53ee8cc1Swenshuai.xi 	MS_U32 GifWidth, MS_U32 GifHeight, MS_U32 GifColorRes, MS_U32 GifBackGround,
236*53ee8cc1Swenshuai.xi 	const ColorMapObject *GifColorMap);
237*53ee8cc1Swenshuai.xi MS_U32 EGifPutImageDesc(GifFileType *GifFile,
238*53ee8cc1Swenshuai.xi 	MS_U32 GifLeft, MS_U32 GifTop, MS_U32 Width, MS_U32 GifHeight, MS_U32 GifInterlace,
239*53ee8cc1Swenshuai.xi 	const ColorMapObject *GifColorMap);
240*53ee8cc1Swenshuai.xi MS_U32 EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine, MS_U32 GifLineLen);
241*53ee8cc1Swenshuai.xi MS_U32 EGifPutPixel(GifFileType *GifFile, GifPixelType GifPixel);
242*53ee8cc1Swenshuai.xi MS_U32 EGifPutComment(GifFileType *GifFile, const char *GifComment);
243*53ee8cc1Swenshuai.xi MS_U32 EGifPutExtensionFirst(GifFileType *GifFile, MS_U32 GifExtCode, MS_U32 GifExtLen,
244*53ee8cc1Swenshuai.xi                            const VoidPtr GifExtension);
245*53ee8cc1Swenshuai.xi MS_U32 EGifPutExtensionNext(GifFileType *GifFile, MS_U32 GifExtCode, MS_U32 GifExtLen,
246*53ee8cc1Swenshuai.xi                            const VoidPtr GifExtension);
247*53ee8cc1Swenshuai.xi MS_U32 EGifPutExtensionLast(GifFileType *GifFile, MS_U32 GifExtCode, MS_U32 GifExtLen,
248*53ee8cc1Swenshuai.xi                            const VoidPtr GifExtension);
249*53ee8cc1Swenshuai.xi MS_U32 EGifPutExtension(GifFileType *GifFile, MS_U32 GifExtCode, MS_U32 GifExtLen,
250*53ee8cc1Swenshuai.xi 							const VoidPtr GifExtension);
251*53ee8cc1Swenshuai.xi MS_U32 EGifPutCode(GifFileType *GifFile, MS_U32 GifCodeSize,
252*53ee8cc1Swenshuai.xi 					  const GifByteType *GifCodeBlock);
253*53ee8cc1Swenshuai.xi MS_U32 EGifPutCodeNext(GifFileType *GifFile, const GifByteType *GifCodeBlock);
254*53ee8cc1Swenshuai.xi MS_U32 EGifCloseFile(GifFileType *GifFile);
255*53ee8cc1Swenshuai.xi 
256*53ee8cc1Swenshuai.xi #define	E_GIF_ERR_OPEN_FAILED	1		/* And EGif possible errors. */
257*53ee8cc1Swenshuai.xi #define	E_GIF_ERR_WRITE_FAILED	2
258*53ee8cc1Swenshuai.xi #define E_GIF_ERR_HAS_SCRN_DSCR	3
259*53ee8cc1Swenshuai.xi #define E_GIF_ERR_HAS_IMAG_DSCR	4
260*53ee8cc1Swenshuai.xi #define E_GIF_ERR_NO_COLOR_MAP	5
261*53ee8cc1Swenshuai.xi #define E_GIF_ERR_DATA_TOO_BIG	6
262*53ee8cc1Swenshuai.xi #define E_GIF_ERR_NOT_ENOUGH_MEM 7
263*53ee8cc1Swenshuai.xi #define E_GIF_ERR_DISK_IS_FULL	8
264*53ee8cc1Swenshuai.xi #define E_GIF_ERR_CLOSE_FAILED	9
265*53ee8cc1Swenshuai.xi #define E_GIF_ERR_NOT_WRITEABLE	10
266*53ee8cc1Swenshuai.xi 
267*53ee8cc1Swenshuai.xi /******************************************************************************
268*53ee8cc1Swenshuai.xi * O.K., here are the routines one can access in order to decode GIF file:     *
269*53ee8cc1Swenshuai.xi * (GIF_LIB file DGIF_LIB.C).						      *
270*53ee8cc1Swenshuai.xi ******************************************************************************/
271*53ee8cc1Swenshuai.xi 
272*53ee8cc1Swenshuai.xi 
273*53ee8cc1Swenshuai.xi GifFileType *MstDGifProcess(void* ptr,MS_U32 ocolor_typ,MS_U32 mode,void *roi);
274*53ee8cc1Swenshuai.xi GifFileType *MstDGifOpenFileHandle(MS_U32 GifFileHandle,InputFunc read_fun, GifByteType* bitstream);
275*53ee8cc1Swenshuai.xi GifFileType *MstDGifOpen( void* userPtr, InputFunc readFunc );  /* new one (TVT) */
276*53ee8cc1Swenshuai.xi MS_U32 MstDGifSlurp(GifFileType *GifFile);
277*53ee8cc1Swenshuai.xi MS_U32 MstDGifGetScreenDesc(GifFileType *GifFile);
278*53ee8cc1Swenshuai.xi MS_U32 MstDGifGetRecordType(GifFileType *GifFile, GifRecordType *GifType);
279*53ee8cc1Swenshuai.xi MS_U32 MstDGifGetImageDesc(GifFileType *GifFile);
280*53ee8cc1Swenshuai.xi MS_U32 MstDGifGetLine(GifFileType *GifFile, GifPixelType *GifLine, MS_U32 GifLineLen);
281*53ee8cc1Swenshuai.xi MS_U32 MstDGifGetPixel(GifFileType *GifFile, GifPixelType GifPixel);
282*53ee8cc1Swenshuai.xi MS_U32 MstDGifGetComment(GifFileType *GifFile, char *GifComment);
283*53ee8cc1Swenshuai.xi MS_U32 MstDGifGetExtension(GifFileType *GifFile, MS_U32 *GifExtCode,
284*53ee8cc1Swenshuai.xi 						GifByteType **GifExtension);
285*53ee8cc1Swenshuai.xi MS_U32 MstDGifGetExtensionNext(GifFileType *GifFile, GifByteType **GifExtension);
286*53ee8cc1Swenshuai.xi MS_U32 MstDGifGetCode(GifFileType *GifFile, MS_U32 *GifCodeSize,
287*53ee8cc1Swenshuai.xi 						GifByteType **GifCodeBlock);
288*53ee8cc1Swenshuai.xi MS_U32 MstDGifGetCodeNext(GifFileType *GifFile, GifByteType **GifCodeBlock);
289*53ee8cc1Swenshuai.xi MS_U32 MstDGifGetLZCodes(GifFileType *GifFile, MS_U32 *GifCode);
290*53ee8cc1Swenshuai.xi MS_U32 MstDGifCloseFile(GifFileType *GifFile);
291*53ee8cc1Swenshuai.xi void MstDGifSetMode (MS_U32 mode);
292*53ee8cc1Swenshuai.xi MS_U32 MstDGifGetDuration(void);
293*53ee8cc1Swenshuai.xi 
294*53ee8cc1Swenshuai.xi 
295*53ee8cc1Swenshuai.xi #define	D_GIF_ERR_OPEN_FAILED	101		/* And DGif possible errors. */
296*53ee8cc1Swenshuai.xi #define	D_GIF_ERR_READ_FAILED	102
297*53ee8cc1Swenshuai.xi #define	D_GIF_ERR_NOT_GIF_FILE	103
298*53ee8cc1Swenshuai.xi #define D_GIF_ERR_NO_SCRN_DSCR	104
299*53ee8cc1Swenshuai.xi #define D_GIF_ERR_NO_IMAG_DSCR	105
300*53ee8cc1Swenshuai.xi #define D_GIF_ERR_NO_COLOR_MAP	106
301*53ee8cc1Swenshuai.xi #define D_GIF_ERR_WRONG_RECORD	107
302*53ee8cc1Swenshuai.xi #define D_GIF_ERR_DATA_TOO_BIG	108
303*53ee8cc1Swenshuai.xi #define D_GIF_ERR_NOT_ENOUGH_MEM 109
304*53ee8cc1Swenshuai.xi #define D_GIF_ERR_CLOSE_FAILED	110
305*53ee8cc1Swenshuai.xi #define D_GIF_ERR_NOT_READABLE	111
306*53ee8cc1Swenshuai.xi #define D_GIF_ERR_IMAGE_DEFECT	112
307*53ee8cc1Swenshuai.xi #define D_GIF_ERR_EOF_TOO_SOON	113
308*53ee8cc1Swenshuai.xi 
309*53ee8cc1Swenshuai.xi #if 0
310*53ee8cc1Swenshuai.xi /******************************************************************************
311*53ee8cc1Swenshuai.xi * O.K., here are the routines from GIF_LIB file QUANTIZE.C.		      *
312*53ee8cc1Swenshuai.xi ******************************************************************************/
313*53ee8cc1Swenshuai.xi MS_U32 QuantizeBuffer(MS_U32 Width, MS_U32 Height, MS_U32 *ColorMapSize,
314*53ee8cc1Swenshuai.xi 	GifByteType *RedInput, GifByteType *GreenInput, GifByteType *BlueInput,
315*53ee8cc1Swenshuai.xi 	GifByteType *OutputBuffer, GifColorType *OutputColorMap);
316*53ee8cc1Swenshuai.xi #endif
317*53ee8cc1Swenshuai.xi 
318*53ee8cc1Swenshuai.xi 
319*53ee8cc1Swenshuai.xi /******************************************************************************
320*53ee8cc1Swenshuai.xi * O.K., here are the routines from GIF_LIB file GIF_ERR.C.		      *
321*53ee8cc1Swenshuai.xi ******************************************************************************/
322*53ee8cc1Swenshuai.xi  void PrintGifError(void);
323*53ee8cc1Swenshuai.xi  MS_U32 MstGifLastError(void);
324*53ee8cc1Swenshuai.xi 
325*53ee8cc1Swenshuai.xi /******************************************************************************
326*53ee8cc1Swenshuai.xi * O.K., here are the routines from GIF_LIB file DEV2GIF.C.		      *
327*53ee8cc1Swenshuai.xi ******************************************************************************/
328*53ee8cc1Swenshuai.xi  MS_U32 DumpScreen2Gif(const char *FileName,
329*53ee8cc1Swenshuai.xi 			  MS_U32 ReqGraphDriver,
330*53ee8cc1Swenshuai.xi 			  MS_U32 ReqGraphMode1,
331*53ee8cc1Swenshuai.xi 			  MS_U32 ReqGraphMode2,
332*53ee8cc1Swenshuai.xi 			  MS_U32 ReqGraphMode3);
333*53ee8cc1Swenshuai.xi 
334*53ee8cc1Swenshuai.xi /*****************************************************************************
335*53ee8cc1Swenshuai.xi  *
336*53ee8cc1Swenshuai.xi  * Everything below this point is new after version 1.2, supporting `slurp
337*53ee8cc1Swenshuai.xi  * mode' for doing I/O in two big belts with all the image-bashing in core.
338*53ee8cc1Swenshuai.xi  *
339*53ee8cc1Swenshuai.xi  *****************************************************************************/
340*53ee8cc1Swenshuai.xi 
341*53ee8cc1Swenshuai.xi /******************************************************************************
342*53ee8cc1Swenshuai.xi * Color Map handling from ALLOCGIF.C					      *
343*53ee8cc1Swenshuai.xi ******************************************************************************/
344*53ee8cc1Swenshuai.xi 
345*53ee8cc1Swenshuai.xi  ColorMapObject *MstMakeMapObject(MS_U32 ColorCount, const GifColorType *ColorMap);
346*53ee8cc1Swenshuai.xi  void MstFreeMapObject(ColorMapObject *Object);
347*53ee8cc1Swenshuai.xi  ColorMapObject *UnionColorMap(
348*53ee8cc1Swenshuai.xi 				const ColorMapObject *ColorIn1,
349*53ee8cc1Swenshuai.xi 				const ColorMapObject *ColorIn2,
350*53ee8cc1Swenshuai.xi 				GifPixelType ColorTransIn2[]);
351*53ee8cc1Swenshuai.xi  MS_U32 MstBitSize(MS_U32 n);
352*53ee8cc1Swenshuai.xi 
353*53ee8cc1Swenshuai.xi /******************************************************************************
354*53ee8cc1Swenshuai.xi * Support for the in-core structures allocation (slurp mode).		      *
355*53ee8cc1Swenshuai.xi ******************************************************************************/
356*53ee8cc1Swenshuai.xi 
357*53ee8cc1Swenshuai.xi /* This is the in-core version of an extension record */
358*53ee8cc1Swenshuai.xi typedef struct {
359*53ee8cc1Swenshuai.xi     int		ByteCount;
360*53ee8cc1Swenshuai.xi     char	*Bytes;		/* on malloc(3) heap */
361*53ee8cc1Swenshuai.xi     MS_U32 Function;       /* Holds the type of the Extension block. */
362*53ee8cc1Swenshuai.xi } ExtensionBlock;
363*53ee8cc1Swenshuai.xi 
364*53ee8cc1Swenshuai.xi /* This holds an image header, its unpacked raster bits, and extensions */
365*53ee8cc1Swenshuai.xi typedef struct SavedImage {
366*53ee8cc1Swenshuai.xi     GifImageDesc	ImageDesc;
367*53ee8cc1Swenshuai.xi 
368*53ee8cc1Swenshuai.xi     char		*RasterBits;		/* on malloc(3) heap */
369*53ee8cc1Swenshuai.xi 
370*53ee8cc1Swenshuai.xi     int			Function; /* DEPRECATED: Use ExtensionBlocks[x].Function
371*53ee8cc1Swenshuai.xi                            * instead */
372*53ee8cc1Swenshuai.xi     int			ExtensionBlockCount;
373*53ee8cc1Swenshuai.xi     ExtensionBlock	*ExtensionBlocks;	/* on malloc(3) heap */
374*53ee8cc1Swenshuai.xi } SavedImage;
375*53ee8cc1Swenshuai.xi 
376*53ee8cc1Swenshuai.xi extern void ApplyTranslation(SavedImage *Image, GifPixelType Translation[]);
377*53ee8cc1Swenshuai.xi 
378*53ee8cc1Swenshuai.xi extern void MakeExtension(SavedImage *New, MS_U32 Function);
379*53ee8cc1Swenshuai.xi extern MS_U32 AddExtensionBlock(SavedImage *New, MS_U32 Len, char ExtData[]);
380*53ee8cc1Swenshuai.xi extern void FreeExtension(SavedImage *Image);
381*53ee8cc1Swenshuai.xi 
382*53ee8cc1Swenshuai.xi extern SavedImage *MakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom);
383*53ee8cc1Swenshuai.xi extern void FreeSavedImages(GifFileType *GifFile);
384*53ee8cc1Swenshuai.xi 
385*53ee8cc1Swenshuai.xi /******************************************************************************
386*53ee8cc1Swenshuai.xi * The library's internal utility font					      *
387*53ee8cc1Swenshuai.xi ******************************************************************************/
388*53ee8cc1Swenshuai.xi #if 0
389*53ee8cc1Swenshuai.xi #define GIF_FONT_WIDTH	8
390*53ee8cc1Swenshuai.xi #define GIF_FONT_HEIGHT	8
391*53ee8cc1Swenshuai.xi extern MS_U8 AsciiTable[][GIF_FONT_WIDTH];
392*53ee8cc1Swenshuai.xi 
393*53ee8cc1Swenshuai.xi extern void DrawText(SavedImage *Image,
394*53ee8cc1Swenshuai.xi 		     const MS_U32 x, const MS_U32 y,
395*53ee8cc1Swenshuai.xi 		     const char *legend,
396*53ee8cc1Swenshuai.xi 		     const MS_U32 color);
397*53ee8cc1Swenshuai.xi 
398*53ee8cc1Swenshuai.xi extern void DrawBox(SavedImage *Image,
399*53ee8cc1Swenshuai.xi 		     const MS_U32 x, const MS_U32 y,
400*53ee8cc1Swenshuai.xi 		     const MS_U32 w, const MS_U32 d,
401*53ee8cc1Swenshuai.xi 		     const MS_U32 color);
402*53ee8cc1Swenshuai.xi 
403*53ee8cc1Swenshuai.xi void DrawRectangle(SavedImage *Image,
404*53ee8cc1Swenshuai.xi 		     const MS_U32 x, const MS_U32 y,
405*53ee8cc1Swenshuai.xi 		     const MS_U32 w, const MS_U32 d,
406*53ee8cc1Swenshuai.xi 		     const MS_U32 color);
407*53ee8cc1Swenshuai.xi 
408*53ee8cc1Swenshuai.xi extern void DrawBoxedText(SavedImage *Image,
409*53ee8cc1Swenshuai.xi 		     const MS_U32 x, const MS_U32 y,
410*53ee8cc1Swenshuai.xi 		     const char *legend,
411*53ee8cc1Swenshuai.xi 		     const MS_U32 border,
412*53ee8cc1Swenshuai.xi 		     const MS_U32 bg,
413*53ee8cc1Swenshuai.xi 		     const MS_U32 fg);
414*53ee8cc1Swenshuai.xi #endif
415*53ee8cc1Swenshuai.xi 
416*53ee8cc1Swenshuai.xi #endif /* _GIF_LIB_H */
417