[Tizen] Add codes for Dali Windows Backend
[platform/core/uifw/dali-adaptor.git] / dali-windows-backend / ExInclude / gif_lib.h
1 /******************************************************************************\r
2  \r
3 gif_lib.h - service library for decoding and encoding GIF images\r
4                                                                              \r
5 *****************************************************************************/\r
6 \r
7 #ifndef _GIF_LIB_H_\r
8 #define _GIF_LIB_H_ 1\r
9 \r
10 #ifdef __cplusplus\r
11 extern "C" {\r
12 #endif /* __cplusplus */\r
13 \r
14 #define GIFLIB_MAJOR 5\r
15 #define GIFLIB_MINOR 1\r
16 #define GIFLIB_RELEASE 4\r
17 \r
18 #define GIF_ERROR   0\r
19 #define GIF_OK      1\r
20 \r
21 #include <stddef.h>\r
22 #include <stdbool.h>\r
23 \r
24 #define GIF_STAMP "GIFVER"          /* First chars in file - GIF stamp.  */\r
25 #define GIF_STAMP_LEN sizeof(GIF_STAMP) - 1\r
26 #define GIF_VERSION_POS 3           /* Version first character in stamp. */\r
27 #define GIF87_STAMP "GIF87a"        /* First chars in file - GIF stamp.  */\r
28 #define GIF89_STAMP "GIF89a"        /* First chars in file - GIF stamp.  */\r
29 \r
30 typedef unsigned char GifPixelType;\r
31 typedef unsigned char *GifRowType;\r
32 typedef unsigned char GifByteType;\r
33 typedef unsigned int GifPrefixType;\r
34 typedef int GifWord;\r
35 \r
36 typedef struct GifColorType {\r
37     GifByteType Red, Green, Blue;\r
38 } GifColorType;\r
39 \r
40 typedef struct ColorMapObject {\r
41     int ColorCount;\r
42     int BitsPerPixel;\r
43     bool SortFlag;\r
44     GifColorType *Colors;    /* on malloc(3) heap */\r
45 } ColorMapObject;\r
46 \r
47 typedef struct GifImageDesc {\r
48     GifWord Left, Top, Width, Height;   /* Current image dimensions. */\r
49     bool Interlace;                     /* Sequential/Interlaced lines. */\r
50     ColorMapObject *ColorMap;           /* The local color map */\r
51 } GifImageDesc;\r
52 \r
53 typedef struct ExtensionBlock {\r
54     int ByteCount;\r
55     GifByteType *Bytes; /* on malloc(3) heap */\r
56     int Function;       /* The block function code */\r
57 #define CONTINUE_EXT_FUNC_CODE    0x00    /* continuation subblock */\r
58 #define COMMENT_EXT_FUNC_CODE     0xfe    /* comment */\r
59 #define GRAPHICS_EXT_FUNC_CODE    0xf9    /* graphics control (GIF89) */\r
60 #define PLAINTEXT_EXT_FUNC_CODE   0x01    /* plaintext */\r
61 #define APPLICATION_EXT_FUNC_CODE 0xff    /* application block */\r
62 } ExtensionBlock;\r
63 \r
64 typedef struct SavedImage {\r
65     GifImageDesc ImageDesc;\r
66     GifByteType *RasterBits;         /* on malloc(3) heap */\r
67     int ExtensionBlockCount;         /* Count of extensions before image */    \r
68     ExtensionBlock *ExtensionBlocks; /* Extensions before image */    \r
69 } SavedImage;\r
70 \r
71 typedef struct GifFileType {\r
72     GifWord SWidth, SHeight;         /* Size of virtual canvas */\r
73     GifWord SColorResolution;        /* How many colors can we generate? */\r
74     GifWord SBackGroundColor;        /* Background color for virtual canvas */\r
75     GifByteType AspectByte;          /* Used to compute pixel aspect ratio */\r
76     ColorMapObject *SColorMap;       /* Global colormap, NULL if nonexistent. */\r
77     int ImageCount;                  /* Number of current image (both APIs) */\r
78     GifImageDesc Image;              /* Current image (low-level API) */\r
79     SavedImage *SavedImages;         /* Image sequence (high-level API) */\r
80     int ExtensionBlockCount;         /* Count extensions past last image */\r
81     ExtensionBlock *ExtensionBlocks; /* Extensions past last image */    \r
82     int Error;                       /* Last error condition reported */\r
83     void *UserData;                  /* hook to attach user data (TVT) */\r
84     void *Private;                   /* Don't mess with this! */\r
85 } GifFileType;\r
86 \r
87 #define GIF_ASPECT_RATIO(n)     ((n)+15.0/64.0)\r
88 \r
89 typedef enum {\r
90     UNDEFINED_RECORD_TYPE,\r
91     SCREEN_DESC_RECORD_TYPE,\r
92     IMAGE_DESC_RECORD_TYPE, /* Begin with ',' */\r
93     EXTENSION_RECORD_TYPE,  /* Begin with '!' */\r
94     TERMINATE_RECORD_TYPE   /* Begin with ';' */\r
95 } GifRecordType;\r
96 \r
97 /* func type to read gif data from arbitrary sources (TVT) */\r
98 typedef int (*InputFunc) (GifFileType *, GifByteType *, int);\r
99 \r
100 /* func type to write gif data to arbitrary targets.\r
101  * Returns count of bytes written. (MRB)\r
102  */\r
103 typedef int (*OutputFunc) (GifFileType *, const GifByteType *, int);\r
104 \r
105 /******************************************************************************\r
106  GIF89 structures\r
107 ******************************************************************************/\r
108 \r
109 typedef struct GraphicsControlBlock {\r
110     int DisposalMode;\r
111 #define DISPOSAL_UNSPECIFIED      0       /* No disposal specified. */\r
112 #define DISPOSE_DO_NOT            1       /* Leave image in place */\r
113 #define DISPOSE_BACKGROUND        2       /* Set area too background color */\r
114 #define DISPOSE_PREVIOUS          3       /* Restore to previous content */\r
115     bool UserInputFlag;      /* User confirmation required before disposal */\r
116     int DelayTime;           /* pre-display delay in 0.01sec units */\r
117     int TransparentColor;    /* Palette index for transparency, -1 if none */\r
118 #define NO_TRANSPARENT_COLOR    -1\r
119 } GraphicsControlBlock;\r
120 \r
121 /******************************************************************************\r
122  GIF encoding routines\r
123 ******************************************************************************/\r
124 \r
125 /* Main entry points */\r
126 GifFileType *EGifOpenFileName(const char *GifFileName,\r
127                               const bool GifTestExistence, int *Error);\r
128 GifFileType *EGifOpenFileHandle(const int GifFileHandle, int *Error);\r
129 GifFileType *EGifOpen(void *userPtr, OutputFunc writeFunc, int *Error);\r
130 int EGifSpew(GifFileType * GifFile);\r
131 const char *EGifGetGifVersion(GifFileType *GifFile); /* new in 5.x */\r
132 int EGifCloseFile(GifFileType *GifFile, int *ErrorCode);\r
133 \r
134 #define E_GIF_SUCCEEDED          0\r
135 #define E_GIF_ERR_OPEN_FAILED    1    /* And EGif possible errors. */\r
136 #define E_GIF_ERR_WRITE_FAILED   2\r
137 #define E_GIF_ERR_HAS_SCRN_DSCR  3\r
138 #define E_GIF_ERR_HAS_IMAG_DSCR  4\r
139 #define E_GIF_ERR_NO_COLOR_MAP   5\r
140 #define E_GIF_ERR_DATA_TOO_BIG   6\r
141 #define E_GIF_ERR_NOT_ENOUGH_MEM 7\r
142 #define E_GIF_ERR_DISK_IS_FULL   8\r
143 #define E_GIF_ERR_CLOSE_FAILED   9\r
144 #define E_GIF_ERR_NOT_WRITEABLE  10\r
145 \r
146 /* These are legacy.  You probably do not want to call them directly */\r
147 int EGifPutScreenDesc(GifFileType *GifFile,\r
148                       const int GifWidth, const int GifHeight, \r
149                       const int GifColorRes,\r
150                       const int GifBackGround,\r
151                       const ColorMapObject *GifColorMap);\r
152 int EGifPutImageDesc(GifFileType *GifFile, \r
153                      const int GifLeft, const int GifTop,\r
154                      const int GifWidth, const int GifHeight, \r
155                      const bool GifInterlace,\r
156                      const ColorMapObject *GifColorMap);\r
157 void EGifSetGifVersion(GifFileType *GifFile, const bool gif89);\r
158 int EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine,\r
159                 int GifLineLen);\r
160 int EGifPutPixel(GifFileType *GifFile, const GifPixelType GifPixel);\r
161 int EGifPutComment(GifFileType *GifFile, const char *GifComment);\r
162 int EGifPutExtensionLeader(GifFileType *GifFile, const int GifExtCode);\r
163 int EGifPutExtensionBlock(GifFileType *GifFile,\r
164                          const int GifExtLen, const void *GifExtension);\r
165 int EGifPutExtensionTrailer(GifFileType *GifFile);\r
166 int EGifPutExtension(GifFileType *GifFile, const int GifExtCode, \r
167                      const int GifExtLen,\r
168                      const void *GifExtension);\r
169 int EGifPutCode(GifFileType *GifFile, int GifCodeSize,\r
170                 const GifByteType *GifCodeBlock);\r
171 int EGifPutCodeNext(GifFileType *GifFile,\r
172                     const GifByteType *GifCodeBlock);\r
173 \r
174 /******************************************************************************\r
175  GIF decoding routines\r
176 ******************************************************************************/\r
177 \r
178 /* Main entry points */\r
179 GifFileType *DGifOpenFileName(const char *GifFileName, int *Error);\r
180 GifFileType *DGifOpenFileHandle(int GifFileHandle, int *Error);\r
181 int DGifSlurp(GifFileType * GifFile);\r
182 GifFileType *DGifOpen(void *userPtr, InputFunc readFunc, int *Error);    /* new one (TVT) */\r
183     int DGifCloseFile(GifFileType * GifFile, int *ErrorCode);\r
184 \r
185 #define D_GIF_SUCCEEDED          0\r
186 #define D_GIF_ERR_OPEN_FAILED    101    /* And DGif possible errors. */\r
187 #define D_GIF_ERR_READ_FAILED    102\r
188 #define D_GIF_ERR_NOT_GIF_FILE   103\r
189 #define D_GIF_ERR_NO_SCRN_DSCR   104\r
190 #define D_GIF_ERR_NO_IMAG_DSCR   105\r
191 #define D_GIF_ERR_NO_COLOR_MAP   106\r
192 #define D_GIF_ERR_WRONG_RECORD   107\r
193 #define D_GIF_ERR_DATA_TOO_BIG   108\r
194 #define D_GIF_ERR_NOT_ENOUGH_MEM 109\r
195 #define D_GIF_ERR_CLOSE_FAILED   110\r
196 #define D_GIF_ERR_NOT_READABLE   111\r
197 #define D_GIF_ERR_IMAGE_DEFECT   112\r
198 #define D_GIF_ERR_EOF_TOO_SOON   113\r
199 \r
200 /* These are legacy.  You probably do not want to call them directly */\r
201 int DGifGetScreenDesc(GifFileType *GifFile);\r
202 int DGifGetRecordType(GifFileType *GifFile, GifRecordType *GifType);\r
203 int DGifGetImageDesc(GifFileType *GifFile);\r
204 int DGifGetLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen);\r
205 int DGifGetPixel(GifFileType *GifFile, GifPixelType GifPixel);\r
206 int DGifGetComment(GifFileType *GifFile, char *GifComment);\r
207 int DGifGetExtension(GifFileType *GifFile, int *GifExtCode,\r
208                      GifByteType **GifExtension);\r
209 int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **GifExtension);\r
210 int DGifGetCode(GifFileType *GifFile, int *GifCodeSize,\r
211                 GifByteType **GifCodeBlock);\r
212 int DGifGetCodeNext(GifFileType *GifFile, GifByteType **GifCodeBlock);\r
213 int DGifGetLZCodes(GifFileType *GifFile, int *GifCode);\r
214 \r
215 \r
216 /******************************************************************************\r
217  Color table quantization (deprecated)\r
218 ******************************************************************************/\r
219 int GifQuantizeBuffer(unsigned int Width, unsigned int Height,\r
220                    int *ColorMapSize, GifByteType * RedInput,\r
221                    GifByteType * GreenInput, GifByteType * BlueInput,\r
222                    GifByteType * OutputBuffer,\r
223                    GifColorType * OutputColorMap);\r
224 \r
225 /******************************************************************************\r
226  Error handling and reporting.\r
227 ******************************************************************************/\r
228 extern const char *GifErrorString(int ErrorCode);     /* new in 2012 - ESR */\r
229 \r
230 /*****************************************************************************\r
231  Everything below this point is new after version 1.2, supporting `slurp\r
232  mode' for doing I/O in two big belts with all the image-bashing in core.\r
233 ******************************************************************************/\r
234 \r
235 /******************************************************************************\r
236  Color map handling from gif_alloc.c\r
237 ******************************************************************************/\r
238 \r
239 extern ColorMapObject *GifMakeMapObject(int ColorCount,\r
240                                      const GifColorType *ColorMap);\r
241 extern void GifFreeMapObject(ColorMapObject *Object);\r
242 extern ColorMapObject *GifUnionColorMap(const ColorMapObject *ColorIn1,\r
243                                      const ColorMapObject *ColorIn2,\r
244                                      GifPixelType ColorTransIn2[]);\r
245 extern int GifBitSize(int n);\r
246 \r
247 extern void *\r
248 reallocarray(void *optr, size_t nmemb, size_t size);\r
249 \r
250 /******************************************************************************\r
251  Support for the in-core structures allocation (slurp mode).              \r
252 ******************************************************************************/\r
253 \r
254 extern void GifApplyTranslation(SavedImage *Image, GifPixelType Translation[]);\r
255 extern int GifAddExtensionBlock(int *ExtensionBlock_Count,\r
256                                 ExtensionBlock **ExtensionBlocks, \r
257                                 int Function, \r
258                                 unsigned int Len, unsigned char ExtData[]);\r
259 extern void GifFreeExtensions(int *ExtensionBlock_Count,\r
260                               ExtensionBlock **ExtensionBlocks);\r
261 extern SavedImage *GifMakeSavedImage(GifFileType *GifFile,\r
262                                   const SavedImage *CopyFrom);\r
263 extern void GifFreeSavedImages(GifFileType *GifFile);\r
264 \r
265 /******************************************************************************\r
266  5.x functions for GIF89 graphics control blocks\r
267 ******************************************************************************/\r
268 \r
269 int DGifExtensionToGCB(const size_t GifExtensionLength,\r
270                        const GifByteType *GifExtension,\r
271                        GraphicsControlBlock *GCB);\r
272 size_t EGifGCBToExtension(const GraphicsControlBlock *GCB,\r
273                        GifByteType *GifExtension);\r
274 \r
275 int DGifSavedExtensionToGCB(GifFileType *GifFile, \r
276                             int ImageIndex, \r
277                             GraphicsControlBlock *GCB);\r
278 int EGifGCBToSavedExtension(const GraphicsControlBlock *GCB, \r
279                             GifFileType *GifFile, \r
280                             int ImageIndex);\r
281 \r
282 /******************************************************************************\r
283  The library's internal utility font                          \r
284 ******************************************************************************/\r
285 \r
286 #define GIF_FONT_WIDTH  8\r
287 #define GIF_FONT_HEIGHT 8\r
288 extern const unsigned char GifAsciiTable8x8[][GIF_FONT_WIDTH];\r
289 \r
290 extern void GifDrawText8x8(SavedImage *Image,\r
291                      const int x, const int y,\r
292                      const char *legend, const int color);\r
293 \r
294 extern void GifDrawBox(SavedImage *Image,\r
295                     const int x, const int y,\r
296                     const int w, const int d, const int color);\r
297 \r
298 extern void GifDrawRectangle(SavedImage *Image,\r
299                    const int x, const int y,\r
300                    const int w, const int d, const int color);\r
301 \r
302 extern void GifDrawBoxedText8x8(SavedImage *Image,\r
303                           const int x, const int y,\r
304                           const char *legend,\r
305                           const int border, const int bg, const int fg);\r
306 \r
307 #ifdef __cplusplus\r
308 }\r
309 #endif /* __cplusplus */\r
310 #endif /* _GIF_LIB_H */\r
311 \r
312 /* end */\r