Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

gif.h

Go to the documentation of this file.
00001 /* gif.h - Interface to the GIF library.
00002    Copyright (C) 1997-2001 Eddie Kohler, eddietwo@lcs.mit.edu
00003    This file is part of the GIF library.
00004    
00005    The GIF library is free software*. It is distributed under the GNU General
00006    Public License, version 2 or later; you can copy, distribute, or alter it
00007    at will, as long as this notice is kept intact and this source code is made
00008    available. There is no warranty, express or implied.
00009    
00010    *The LZW compression method used by GIFs is patented. Unisys, the patent
00011    holder, allows the compression algorithm to be used without a license in
00012    software distributed at no cost to the user. */
00013 
00014 #ifndef GIF_H /* -*- mode: c -*- */
00015 #define GIF_H
00016 #include <stdio.h>
00017 #include <stdlib.h>
00018 #ifdef __cplusplus
00019 extern "C" {
00020 #endif
00021 
00022 /* NOTE: You should define the types u_int16_t and u_int32_t before #including
00023    this file, probably by #including <sys/types.h>. */
00024   
00025 #define GIF_MAJOR_VERSION       1
00026 #define GIF_MINOR_VERSION       2
00027 #define GIF_VERSION             "1.2"
00028 
00029 #ifndef BYTE
00030 #define BYTE
00031 typedef unsigned char byte;
00032 #endif
00033 
00034 typedef struct Gif_Stream       Gif_Stream;
00035 typedef struct Gif_Image        Gif_Image;
00036 typedef struct Gif_Colormap     Gif_Colormap;
00037 typedef struct Gif_Comment      Gif_Comment;
00038 typedef struct Gif_Extension    Gif_Extension;
00039 typedef struct Gif_Record       Gif_Record;
00040 
00041 
00042 /** GIF_STREAM **/
00043 
00044 struct Gif_Stream {
00045   
00046   Gif_Colormap *global;
00047   byte background;
00048   
00049   u_int16_t screen_width;
00050   u_int16_t screen_height;
00051   long loopcount;               /* -1 means no loop count */
00052   
00053   Gif_Comment *comment;
00054   
00055   Gif_Image **images;
00056   int nimages;
00057   int imagescap;
00058   
00059   Gif_Extension *extensions;
00060   
00061   unsigned errors;
00062   
00063   int userflags;
00064   int refcount;
00065   
00066 };
00067 
00068 Gif_Stream *    Gif_NewStream(void);
00069 void            Gif_DeleteStream(Gif_Stream *);
00070 
00071 Gif_Stream *    Gif_CopyStreamSkeleton(Gif_Stream *);
00072 Gif_Stream *    Gif_CopyStreamImages(Gif_Stream *);
00073 
00074 #define         Gif_ScreenWidth(gfs)            ((gfs)->screen_width)
00075 #define         Gif_ScreenHeight(gfs)           ((gfs)->screen_height)
00076 #define         Gif_ImageCount(gfs)             ((gfs)->nimages)
00077 
00078 void            Gif_CalculateScreenSize(Gif_Stream *, int force);
00079 int             Gif_Unoptimize(Gif_Stream *);
00080 
00081 
00082 /** GIF_IMAGE **/
00083 
00084 struct Gif_Image {
00085   
00086   char *identifier;
00087   Gif_Comment *comment;
00088   
00089   Gif_Colormap *local;
00090   short transparent;            /* -1 means no transparent index */
00091   
00092   u_int16_t delay;
00093   byte disposal;
00094   u_int16_t left;
00095   u_int16_t top;
00096   
00097   u_int16_t width;
00098   u_int16_t height;
00099   
00100   byte interlace;
00101   byte **img;                   /* img[y][x] == image byte (x,y) */
00102   byte *image_data;
00103   void (*free_image_data)(void *);
00104   
00105   u_int32_t compressed_len;
00106   byte *compressed;
00107   void (*free_compressed)(void *);
00108   
00109   void *user_data;
00110   void (*free_user_data)(void *);
00111   int refcount;
00112   
00113 };
00114 
00115 #define         GIF_DISPOSAL_NONE               0
00116 #define         GIF_DISPOSAL_ASIS               1
00117 #define         GIF_DISPOSAL_BACKGROUND         2
00118 #define         GIF_DISPOSAL_PREVIOUS           3
00119   
00120 Gif_Image *     Gif_NewImage(void);
00121 void            Gif_DeleteImage(Gif_Image *);
00122 
00123 int             Gif_AddImage(Gif_Stream *, Gif_Image *);
00124 void            Gif_RemoveImage(Gif_Stream *, int);
00125 Gif_Image *     Gif_CopyImage(Gif_Image *);
00126 
00127 Gif_Image *     Gif_GetImage(Gif_Stream *, int);
00128 Gif_Image *     Gif_GetNamedImage(Gif_Stream *, const char *);
00129 int             Gif_ImageNumber(Gif_Stream *, Gif_Image *);
00130 
00131 #define         Gif_ImageWidth(gfi)             ((gfi)->width)
00132 #define         Gif_ImageHeight(gfi)            ((gfi)->height)
00133 #define         Gif_ImageDelay(gfi)             ((gfi)->delay)
00134 #define         Gif_ImageUserData(gfi)          ((gfi)->userdata)
00135 #define         Gif_SetImageUserData(gfi, v)    ((gfi)->userdata = v)
00136   
00137 typedef         void (*Gif_ReadErrorHandler)(const char *, int, void *);
00138 
00139 #define         Gif_UncompressImage(gfi)     Gif_FullUncompressImage((gfi),0,0)
00140 int             Gif_FullUncompressImage(Gif_Image*,Gif_ReadErrorHandler,void*);
00141 int             Gif_CompressImage(Gif_Stream *, Gif_Image *);
00142 int             Gif_FullCompressImage(Gif_Stream *, Gif_Image *, int);
00143 void            Gif_ReleaseUncompressedImage(Gif_Image *);
00144 void            Gif_ReleaseCompressedImage(Gif_Image *);
00145 int             Gif_SetUncompressedImage(Gif_Image *, byte *data,
00146                         void (*free_data)(void *), int data_interlaced);
00147 int             Gif_CreateUncompressedImage(Gif_Image *);
00148 
00149 int             Gif_ClipImage(Gif_Image *, int l, int t, int w, int h);
00150 
00151 
00152 /** GIF_COLORMAP **/
00153 
00154 typedef struct {
00155   
00156   byte haspixel;
00157   byte red;
00158   byte green;
00159   byte blue;
00160   
00161   u_int32_t pixel;
00162   
00163 } Gif_Color;
00164 
00165 
00166 struct Gif_Colormap {
00167   
00168   int ncol;
00169   int capacity;
00170   u_int32_t userflags;
00171   int refcount;
00172   Gif_Color *col;
00173   
00174 };
00175 
00176 Gif_Colormap *  Gif_NewColormap(void);
00177 Gif_Colormap *  Gif_NewFullColormap(int count, int capacity);
00178 void            Gif_DeleteColormap(Gif_Colormap *);
00179 
00180 Gif_Colormap *  Gif_CopyColormap(Gif_Colormap *);
00181 
00182 int             Gif_ColorEq(Gif_Color *, Gif_Color *);
00183 #define         GIF_COLOREQ(c1, c2) \
00184 ((c1)->red==(c2)->red && (c1)->green==(c2)->green && (c1)->blue==(c2)->blue)
00185 
00186 int             Gif_FindColor(Gif_Colormap *, Gif_Color *);
00187 int             Gif_AddColor(Gif_Colormap *, Gif_Color *, int look_from);
00188 
00189 
00190 /** GIF_COMMENT **/
00191 
00192 struct Gif_Comment {
00193   char **str;
00194   int *len;
00195   int count;
00196   int cap;
00197 };
00198 
00199 Gif_Comment *   Gif_NewComment(void);
00200 void            Gif_DeleteComment(Gif_Comment *);
00201 int             Gif_AddCommentTake(Gif_Comment *, char *, int);
00202 int             Gif_AddComment(Gif_Comment *, char *, int);
00203 
00204 
00205 /** GIF_EXTENSION **/
00206 
00207 struct Gif_Extension {
00208   
00209   int kind;                     /* negative kinds are reserved */
00210   char *application;
00211   byte *data;
00212   u_int32_t length;
00213   int position;
00214   
00215   Gif_Stream *stream;
00216   Gif_Extension *next;
00217   void (*free_data)(void *);
00218   
00219 };
00220 
00221 
00222 Gif_Extension * Gif_NewExtension(int, char *);
00223 void            Gif_DeleteExtension(Gif_Extension *);
00224 int             Gif_AddExtension(Gif_Stream *, Gif_Extension *, int);
00225 Gif_Extension * Gif_GetExtension(Gif_Stream *, int, Gif_Extension *);
00226 
00227 
00228 /** READING AND WRITING **/
00229 
00230 struct Gif_Record {
00231   const unsigned char *data;
00232   u_int32_t length;
00233 };
00234 
00235 #define GIF_READ_COMPRESSED             1
00236 #define GIF_READ_UNCOMPRESSED           2
00237 #define GIF_READ_CONST_RECORD           4
00238 #define GIF_WRITE_CAREFUL_MIN_CODE_SIZE 1
00239 
00240 Gif_Stream *    Gif_ReadFile(FILE *);
00241 Gif_Stream *    Gif_FullReadFile(FILE *, int flags, Gif_ReadErrorHandler,
00242                                  void *);
00243 Gif_Stream *    Gif_ReadRecord(const Gif_Record *);
00244 Gif_Stream *    Gif_FullReadRecord(const Gif_Record *, int flags,
00245                                    Gif_ReadErrorHandler, void *);
00246 int             Gif_WriteFile(Gif_Stream *, FILE *);
00247 int             Gif_FullWriteFile(Gif_Stream *, int flags, FILE *);
00248 
00249 #define Gif_ReadFile(f)         Gif_FullReadFile((f),GIF_READ_UNCOMPRESSED,0,0)
00250 #define Gif_ReadRecord(r)       Gif_FullReadRecord((r),GIF_READ_UNCOMPRESSED,0,0)
00251 #define Gif_CompressImage(s, i) Gif_FullCompressImage((s),(i),0)
00252 #define Gif_WriteFile(s, f)     Gif_FullWriteFile((s),0,(f))
00253 
00254 
00255 /** HOOKS AND MISCELLANEOUS **/
00256 
00257 int             Gif_InterlaceLine(int y, int height);
00258 char *          Gif_CopyString(char *);
00259 
00260 #define GIF_T_STREAM                    (0)
00261 #define GIF_T_IMAGE                     (1)
00262 #define GIF_T_COLORMAP                  (2)
00263 typedef void    (*Gif_DeletionHookFunc)(int, void *, void *);
00264 int             Gif_AddDeletionHook(int, Gif_DeletionHookFunc, void *);
00265 void            Gif_RemoveDeletionHook(int, Gif_DeletionHookFunc, void *);
00266 
00267 #ifdef GIF_DEBUGGING
00268 #define         GIF_DEBUG(x)                    Gif_Debug x
00269 void            Gif_Debug(char *x, ...);
00270 #else
00271 #define         GIF_DEBUG(x)
00272 #endif
00273 
00274 typedef u_int16_t Gif_Code;
00275 #define GIF_MAX_CODE_BITS       12
00276 #define GIF_MAX_CODE            0x1000
00277 #define GIF_MAX_BLOCK           255
00278 
00279 #ifndef Gif_New
00280 # ifndef xmalloc
00281 #  define xmalloc               malloc
00282 #  define xrealloc              realloc
00283 #  define xfree                 free
00284 # endif
00285 # define Gif_New(t)             ((t *)xmalloc(sizeof(t)))
00286 # define Gif_NewArray(t, n)     ((t *)xmalloc(sizeof(t) * (n)))
00287 # define Gif_ReArray(p, t, n)   ((p)=((t*)xrealloc((void*)(p),sizeof(t)*(n))))
00288 #endif
00289 #ifndef Gif_DeleteFunc
00290 # define Gif_DeleteFunc         (&xfree)
00291 # define Gif_DeleteArrayFunc    (&xfree)
00292 #endif
00293 #ifndef Gif_Delete
00294 # define Gif_Delete(p)          (*Gif_DeleteFunc)((void *)(p))
00295 # define Gif_DeleteArray(p)     (*Gif_DeleteArrayFunc)((void *)(p))
00296 #endif
00297 
00298 #ifdef __cplusplus
00299 }
00300 #endif
00301 #endif
 

Powered by Plone

This site conforms to the following standards: