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 File Reference

#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.


Data Structures

struct  Gif_Color
struct  Gif_Colormap
struct  Gif_Comment
struct  Gif_Extension
struct  Gif_Image
struct  Gif_Record
struct  Gif_Stream

Defines

#define GIF_MAJOR_VERSION   1
#define GIF_MINOR_VERSION   2
#define GIF_VERSION   "1.2"
#define Gif_ScreenWidth(gfs)   ((gfs)->screen_width)
#define Gif_ScreenHeight(gfs)   ((gfs)->screen_height)
#define Gif_ImageCount(gfs)   ((gfs)->nimages)
#define GIF_DISPOSAL_NONE   0
#define GIF_DISPOSAL_ASIS   1
#define GIF_DISPOSAL_BACKGROUND   2
#define GIF_DISPOSAL_PREVIOUS   3
#define Gif_ImageWidth(gfi)   ((gfi)->width)
#define Gif_ImageHeight(gfi)   ((gfi)->height)
#define Gif_ImageDelay(gfi)   ((gfi)->delay)
#define Gif_ImageUserData(gfi)   ((gfi)->userdata)
#define Gif_SetImageUserData(gfi, v)   ((gfi)->userdata = v)
#define Gif_UncompressImage(gfi)   Gif_FullUncompressImage((gfi),0,0)
#define GIF_COLOREQ(c1, c2)   ((c1)->red==(c2)->red && (c1)->green==(c2)->green && (c1)->blue==(c2)->blue)
#define GIF_READ_COMPRESSED   1
#define GIF_READ_UNCOMPRESSED   2
#define GIF_READ_CONST_RECORD   4
#define GIF_WRITE_CAREFUL_MIN_CODE_SIZE   1
#define Gif_ReadFile(f)   Gif_FullReadFile((f),GIF_READ_UNCOMPRESSED,0,0)
#define Gif_ReadRecord(r)   Gif_FullReadRecord((r),GIF_READ_UNCOMPRESSED,0,0)
#define Gif_CompressImage(s, i)   Gif_FullCompressImage((s),(i),0)
#define Gif_WriteFile(s, f)   Gif_FullWriteFile((s),0,(f))
#define GIF_T_STREAM   (0)
#define GIF_T_IMAGE   (1)
#define GIF_T_COLORMAP   (2)
#define GIF_DEBUG(x)
#define GIF_MAX_CODE_BITS   12
#define GIF_MAX_CODE   0x1000
#define GIF_MAX_BLOCK   255
#define xmalloc   malloc
#define xrealloc   realloc
#define xfree   free
#define Gif_New(t)   ((t *)xmalloc(sizeof(t)))
#define Gif_NewArray(t, n)   ((t *)xmalloc(sizeof(t) * (n)))
#define Gif_ReArray(p, t, n)   ((p)=((t*)xrealloc((void*)(p),sizeof(t)*(n))))
#define Gif_DeleteFunc   (&xfree)
#define Gif_DeleteArrayFunc   (&xfree)
#define Gif_Delete(p)   (*Gif_DeleteFunc)((void *)(p))
#define Gif_DeleteArray(p)   (*Gif_DeleteArrayFunc)((void *)(p))

Typedefs

typedef unsigned char byte
typedef Gif_Stream Gif_Stream
typedef Gif_Image Gif_Image
typedef Gif_Colormap Gif_Colormap
typedef Gif_Comment Gif_Comment
typedef Gif_Extension Gif_Extension
typedef Gif_Record Gif_Record
typedef void(* Gif_ReadErrorHandler )(const char *, int, void *)
typedef void(* Gif_DeletionHookFunc )(int, void *, void *)
typedef u_int16_t Gif_Code

Functions

Gif_StreamGif_NewStream (void)
void Gif_DeleteStream (Gif_Stream *)
Gif_StreamGif_CopyStreamSkeleton (Gif_Stream *)
Gif_StreamGif_CopyStreamImages (Gif_Stream *)
void Gif_CalculateScreenSize (Gif_Stream *, int force)
int Gif_Unoptimize (Gif_Stream *)
Gif_ImageGif_NewImage (void)
void Gif_DeleteImage (Gif_Image *)
int Gif_AddImage (Gif_Stream *, Gif_Image *)
void Gif_RemoveImage (Gif_Stream *, int)
Gif_ImageGif_CopyImage (Gif_Image *)
Gif_ImageGif_GetImage (Gif_Stream *, int)
Gif_ImageGif_GetNamedImage (Gif_Stream *, const char *)
int Gif_ImageNumber (Gif_Stream *, Gif_Image *)
int Gif_FullUncompressImage (Gif_Image *, Gif_ReadErrorHandler, void *)
int Gif_CompressImage (Gif_Stream *, Gif_Image *)
int Gif_FullCompressImage (Gif_Stream *, Gif_Image *, int)
void Gif_ReleaseUncompressedImage (Gif_Image *)
void Gif_ReleaseCompressedImage (Gif_Image *)
int Gif_SetUncompressedImage (Gif_Image *, byte *data, void(*free_data)(void *), int data_interlaced)
int Gif_CreateUncompressedImage (Gif_Image *)
int Gif_ClipImage (Gif_Image *, int l, int t, int w, int h)
Gif_ColormapGif_NewColormap (void)
Gif_ColormapGif_NewFullColormap (int count, int capacity)
void Gif_DeleteColormap (Gif_Colormap *)
Gif_ColormapGif_CopyColormap (Gif_Colormap *)
int Gif_ColorEq (Gif_Color *, Gif_Color *)
int Gif_FindColor (Gif_Colormap *, Gif_Color *)
int Gif_AddColor (Gif_Colormap *, Gif_Color *, int look_from)
Gif_CommentGif_NewComment (void)
void Gif_DeleteComment (Gif_Comment *)
int Gif_AddCommentTake (Gif_Comment *, char *, int)
int Gif_AddComment (Gif_Comment *, char *, int)
Gif_ExtensionGif_NewExtension (int, char *)
void Gif_DeleteExtension (Gif_Extension *)
int Gif_AddExtension (Gif_Stream *, Gif_Extension *, int)
Gif_ExtensionGif_GetExtension (Gif_Stream *, int, Gif_Extension *)
Gif_StreamGif_ReadFile (FILE *)
Gif_StreamGif_FullReadFile (FILE *, int flags, Gif_ReadErrorHandler, void *)
Gif_StreamGif_ReadRecord (const Gif_Record *)
Gif_StreamGif_FullReadRecord (const Gif_Record *, int flags, Gif_ReadErrorHandler, void *)
int Gif_WriteFile (Gif_Stream *, FILE *)
int Gif_FullWriteFile (Gif_Stream *, int flags, FILE *)
int Gif_InterlaceLine (int y, int height)
char * Gif_CopyString (char *)
int Gif_AddDeletionHook (int, Gif_DeletionHookFunc, void *)
void Gif_RemoveDeletionHook (int, Gif_DeletionHookFunc, void *)

Define Documentation

#define GIF_COLOREQ c1,
c2       ((c1)->red==(c2)->red && (c1)->green==(c2)->green && (c1)->blue==(c2)->blue)
 

Definition at line 183 of file gif.h.

Referenced by color_change_transformer(), colormap_combine(), ensure_slot_255(), find_background(), find_color_index(), Gif_AddColor(), Gif_ColorEq(), Gif_FindColor(), merge_colormap_if_possible(), and try_assign_transparency().

#define Gif_CompressImage s,
i       Gif_FullCompressImage((s),(i),0)
 

Definition at line 251 of file gif.h.

#define GIF_DEBUG  
 

Definition at line 271 of file gif.h.

Referenced by read_color_table(), read_gif(), read_image(), read_image_block(), read_image_data(), real_write_image_data(), and write_compressed_data().

#define Gif_Delete p       (*Gif_DeleteFunc)((void *)(p))
 

Definition at line 294 of file gif.h.

Referenced by blank_frameset(), create_x_colormap_extension(), delete_color_transforms(), delete_opt_data(), delete_viewer(), delete_xcolormap(), explode_filename(), Gif_DeleteColormap(), Gif_DeleteComment(), Gif_DeleteExtension(), Gif_DeleteImage(), Gif_DeleteStream(), Gif_DeleteXContext(), Gif_NewFullColormap(), and Gif_RemoveDeletionHook().

#define Gif_DeleteArray p       (*Gif_DeleteArrayFunc)((void *)(p))
 

Definition at line 295 of file gif.h.

Referenced by blank_frameset(), colormap_diversity(), colormap_image_floyd_steinberg(), colormap_median_cut(), colormap_stream(), compare(), create_new_image_data(), create_out_global_map(), create_subimages(), create_x_colormap_extension(), crop_image(), delete_histogram(), delete_opt_data(), delete_viewer(), delete_xcolormap(), do_colormap_change(), finalize_optimizer(), flip_image(), free_all_color_hash_items(), Gif_AddComment(), Gif_DeleteColormap(), Gif_DeleteComment(), Gif_DeleteExtension(), Gif_DeleteImage(), Gif_DeleteStream(), Gif_DeleteXContext(), Gif_FullCompressImage(), Gif_FullUncompressImage(), Gif_ReleaseUncompressedImage(), Gif_Unoptimize(), Gif_XSubMask(), load_closest(), merge_frame_interval(), pipe_color_transformer(), prepare_colormap_map(), put_sub_image_colormap(), read_gif(), read_unknown_extension(), set_viewer_name(), unoptimize_image(), write_gif(), and write_image_data().

#define Gif_DeleteArrayFunc   (&xfree)
 

Definition at line 291 of file gif.h.

Referenced by colormap_stream(), copy_extension(), create_new_image_data(), Gif_CopyImage(), Gif_CreateUncompressedImage(), Gif_FullCompressImage(), Gif_NewImage(), read_compressed_image(), rotate_image(), scale_image(), and unoptimize_image().

#define Gif_DeleteFunc   (&xfree)
 

Definition at line 290 of file gif.h.

#define GIF_DISPOSAL_ASIS   1
 

Definition at line 116 of file gif.h.

Referenced by apply_frame_disposal(), create_new_image_data(), create_subimages(), finalize_optimizer(), find_difference_bounds(), and main().

#define GIF_DISPOSAL_BACKGROUND   2
 

Definition at line 117 of file gif.h.

Referenced by apply_frame_disposal(), apply_image_disposal(), create_new_image_data(), create_subimages(), find_background(), Gif_XNextImage(), histogram(), main(), and unoptimize_image().

#define GIF_DISPOSAL_NONE   0
 

Definition at line 115 of file gif.h.

Referenced by apply_frame_disposal(), create_new_image_data(), finalize_optimizer(), find_difference_bounds(), Gif_NewImage(), and main().

#define GIF_DISPOSAL_PREVIOUS   3
 

Definition at line 118 of file gif.h.

Referenced by apply_image(), apply_image_disposal(), create_new_image_data(), create_subimages(), Gif_XNextImage(), unoptimize_image(), and unoptimized_frame().

#define Gif_ImageCount gfs       ((gfs)->nimages)
 

Definition at line 76 of file gif.h.

Referenced by get_input_stream(), input_stream(), input_stream_done(), new_viewer(), parse_frame_spec(), and view_frame().

#define Gif_ImageDelay gfi       ((gfi)->delay)
 

Definition at line 133 of file gif.h.

#define Gif_ImageHeight gfi       ((gfi)->height)
 

Definition at line 132 of file gif.h.

Referenced by view_frame().

#define Gif_ImageUserData gfi       ((gfi)->userdata)
 

Definition at line 134 of file gif.h.

#define Gif_ImageWidth gfi       ((gfi)->width)
 

Definition at line 131 of file gif.h.

Referenced by view_frame().

#define GIF_MAJOR_VERSION   1
 

Definition at line 25 of file gif.h.

#define GIF_MAX_BLOCK   255
 

Definition at line 277 of file gif.h.

Referenced by read_application_extension(), read_graphic_control_extension(), read_image(), read_image_data(), and read_unknown_extension().

#define GIF_MAX_CODE   0x1000
 

Definition at line 276 of file gif.h.

Referenced by Gif_FullCompressImage(), Gif_FullUncompressImage(), read_gif(), and write_gif().

#define GIF_MAX_CODE_BITS   12
 

Definition at line 275 of file gif.h.

Referenced by read_image_data(), real_write_image_data(), and write_compressed_data().

#define GIF_MINOR_VERSION   2
 

Definition at line 26 of file gif.h.

#define Gif_New      ((t *)xmalloc(sizeof(t)))
 

Definition at line 285 of file gif.h.

Referenced by append_color_change(), append_color_transform(), create_x_colormap_extension(), Gif_AddDeletionHook(), Gif_NewColormap(), Gif_NewComment(), Gif_NewExtension(), Gif_NewFullColormap(), Gif_NewImage(), Gif_NewStream(), Gif_NewXContextFromVisual(), main(), new_frameset(), new_opt_data(), and new_viewer().

#define Gif_NewArray t,
n       ((t *)xmalloc(sizeof(t) * (n)))
 

Definition at line 286 of file gif.h.

Referenced by colormap_diversity(), colormap_image_floyd_steinberg(), colormap_median_cut(), colormap_stream(), compare(), copy_extension(), create_new_image_data(), create_out_global_map(), create_subimages(), create_x_colormap_extension(), crop_image(), explode_filename(), flip_image(), get_used_colors(), Gif_AddComment(), Gif_CopyImage(), Gif_CopyString(), Gif_CreateUncompressedImage(), Gif_FullCompressImage(), Gif_FullUncompressImage(), Gif_NewFullColormap(), Gif_SetUncompressedImage(), Gif_Unoptimize(), Gif_XClaimStreamColors(), Gif_XSubMask(), histogram(), init_histogram(), initialize_optimizer(), load_closest(), merger_add(), new_color_hash(), new_color_hash_item(), new_frameset(), new_viewer(), pipe_color_transformer(), prepare_colormap_map(), put_sub_image_colormap(), read_compressed_image(), read_gif(), read_unknown_extension(), rotate_image(), scale_image(), set_viewer_name(), unoptimize_image(), write_gif(), and write_image_data().

#define GIF_READ_COMPRESSED   1
 

Definition at line 235 of file gif.h.

Referenced by get_input_stream(), Gif_FullReadRecord(), input_stream(), main(), and read_image().

#define GIF_READ_CONST_RECORD   4
 

Definition at line 237 of file gif.h.

Referenced by Gif_FullReadRecord(), and read_compressed_image().

#define GIF_READ_UNCOMPRESSED   2
 

Definition at line 236 of file gif.h.

Referenced by Gif_ReadFile(), Gif_ReadRecord(), and read_image().

#define Gif_ReadFile      Gif_FullReadFile((f),GIF_READ_UNCOMPRESSED,0,0)
 

Definition at line 249 of file gif.h.

Referenced by read_colormap_file().

#define Gif_ReadRecord r       Gif_FullReadRecord((r),GIF_READ_UNCOMPRESSED,0,0)
 

Definition at line 250 of file gif.h.

#define Gif_ReArray p,
t,
n       ((p)=((t*)xrealloc((void*)(p),sizeof(t)*(n))))
 

Definition at line 287 of file gif.h.

Referenced by add_frame(), colormap_combine(), create_image_data(), Gif_AddColor(), Gif_AddCommentTake(), Gif_AddImage(), memory_block_putter(), memory_byte_putter(), merger_add(), read_compressed_image(), read_unknown_extension(), and suck_data().

#define Gif_ScreenHeight gfs       ((gfs)->screen_height)
 

Definition at line 75 of file gif.h.

#define Gif_ScreenWidth gfs       ((gfs)->screen_width)
 

Definition at line 74 of file gif.h.

#define Gif_SetImageUserData gfi,
v       ((gfi)->userdata = v)
 

Definition at line 135 of file gif.h.

#define GIF_T_COLORMAP   (2)
 

Definition at line 262 of file gif.h.

Referenced by Gif_DeleteColormap(), Gif_DeleteXContext(), and Gif_NewXContextFromVisual().

#define GIF_T_IMAGE   (1)
 

Definition at line 261 of file gif.h.

Referenced by Gif_DeleteImage().

#define GIF_T_STREAM   (0)
 

Definition at line 260 of file gif.h.

Referenced by Gif_DeleteStream().

#define Gif_UncompressImage gfi       Gif_FullUncompressImage((gfi),0,0)
 

Definition at line 139 of file gif.h.

Referenced by apply_image(), calculate_min_code_bits(), create_subimages(), Gif_XSubMask(), merge_frame_interval(), put_sub_image_colormap(), and unoptimize_image().

#define GIF_VERSION   "1.2"
 

Definition at line 27 of file gif.h.

#define GIF_WRITE_CAREFUL_MIN_CODE_SIZE   1
 

Definition at line 238 of file gif.h.

Referenced by calculate_min_code_bits(), get_color_table_size(), and main().

#define Gif_WriteFile s,
     Gif_FullWriteFile((s),0,(f))
 

Definition at line 252 of file gif.h.

#define xfree   free
 

Definition at line 283 of file gif.h.

#define xmalloc   malloc
 

Definition at line 281 of file gif.h.

#define xrealloc   realloc
 

Definition at line 282 of file gif.h.


Typedef Documentation

typedef unsigned char byte
 

Definition at line 31 of file gif.h.

typedef u_int16_t Gif_Code
 

Definition at line 274 of file gif.h.

Referenced by change_node_to_table(), Gif_FullCompressImage(), Gif_FullUncompressImage(), one_code(), read_gif(), read_image_data(), real_write_image_data(), write_compressed_data(), and write_gif().

typedef struct Gif_Colormap Gif_Colormap
 

Definition at line 36 of file gif.h.

typedef struct Gif_Comment Gif_Comment
 

Definition at line 37 of file gif.h.

typedef void(* Gif_DeletionHookFunc)(int, void *, void *)
 

Definition at line 263 of file gif.h.

typedef struct Gif_Extension Gif_Extension
 

Definition at line 38 of file gif.h.

typedef struct Gif_Image Gif_Image
 

Definition at line 35 of file gif.h.

typedef void(* Gif_ReadErrorHandler)(const char *, int, void *)
 

Definition at line 137 of file gif.h.

Referenced by Gif_FullReadFile(), Gif_FullReadRecord(), Gif_FullUncompressImage(), and read_gif().

typedef struct Gif_Record Gif_Record
 

Definition at line 39 of file gif.h.

typedef struct Gif_Stream Gif_Stream
 

Definition at line 34 of file gif.h.


Function Documentation

int Gif_AddColor Gif_Colormap  ,
Gif_Color  ,
int    look_from
 

Definition at line 562 of file giffunc.c.

References c, Gif_Colormap::capacity, Gif_Colormap::col, GIF_COLOREQ, Gif_ReArray, i, and Gif_Colormap::ncol.

Referenced by combine_colormaps().

00563 {
00564   int i;
00565   if (look_from >= 0)
00566     for (i = look_from; i < gfcm->ncol; i++)
00567       if (GIF_COLOREQ(&gfcm->col[i], c))
00568         return i;
00569   if (gfcm->ncol >= gfcm->capacity) {
00570     gfcm->capacity *= 2;
00571     Gif_ReArray(gfcm->col, Gif_Color, gfcm->capacity);
00572     if (gfcm->col == 0) return -1;
00573   }
00574   i = gfcm->ncol;
00575   gfcm->ncol++;
00576   gfcm->col[i] = *c;
00577   return i;
00578 }

int Gif_AddComment Gif_Comment  ,
char *   ,
int   
 

Definition at line 198 of file giffunc.c.

References Gif_AddCommentTake(), Gif_DeleteArray, and Gif_NewArray.

Referenced by Gif_CopyImage(), main(), and merge_comments().

00199 {
00200   char *new_x;
00201   if (xlen < 0) xlen = strlen(x);
00202   new_x = Gif_NewArray(char, xlen);
00203   if (!new_x) return 0;
00204   memcpy(new_x, x, xlen);
00205   if (Gif_AddCommentTake(gfcom, new_x, xlen) == 0) {
00206     Gif_DeleteArray(new_x);
00207     return 0;
00208   } else
00209     return 1;
00210 }

int Gif_AddCommentTake Gif_Comment  ,
char *   ,
int   
 

Definition at line 180 of file giffunc.c.

References Gif_Comment::cap, Gif_Comment::count, Gif_ReArray, Gif_Comment::len, and Gif_Comment::str.

Referenced by Gif_AddComment(), and read_comment_extension().

00181 {
00182   if (gfcom->count >= gfcom->cap) {
00183     if (gfcom->cap) gfcom->cap *= 2;
00184     else gfcom->cap = 2;
00185     Gif_ReArray(gfcom->str, char *, gfcom->cap);
00186     Gif_ReArray(gfcom->len, int, gfcom->cap);
00187     if (!gfcom->str || !gfcom->len) return 0;
00188   }
00189   if (xlen < 0) xlen = strlen(x);
00190   gfcom->str[ gfcom->count ] = x;
00191   gfcom->len[ gfcom->count ] = xlen;
00192   gfcom->count++;
00193   return 1;
00194 }

int Gif_AddDeletionHook int   ,
Gif_DeletionHookFunc   ,
void *   
 

int Gif_AddExtension Gif_Stream  ,
Gif_Extension  ,
int   
 

Definition at line 214 of file giffunc.c.

References Gif_Stream::extensions, Gif_Extension::next, Gif_Extension::position, and Gif_Extension::stream.

Referenced by merge_frame_interval(), and read_unknown_extension().

00215 {
00216   Gif_Extension *prev, *trav;
00217   if (gfex->stream) return 0;
00218   for (prev = 0, trav = gfs->extensions;
00219        trav && trav->position <= pos;
00220        prev = trav, trav = trav->next)
00221     ;
00222   if (prev) prev->next = gfex;
00223   else gfs->extensions = gfex;
00224   gfex->next = trav;
00225   return 1;
00226 }

int Gif_AddImage Gif_Stream  ,
Gif_Image  
 

Definition at line 151 of file giffunc.c.

References Gif_ReArray, Gif_Stream::images, Gif_Stream::imagescap, Gif_Stream::nimages, and Gif_Image::refcount.

Referenced by Gif_CopyStreamImages(), merge_image(), and read_gif().

00152 {
00153   if (gfs->nimages >= gfs->imagescap) {
00154     if (gfs->imagescap) gfs->imagescap *= 2;
00155     else gfs->imagescap = 2;
00156     Gif_ReArray(gfs->images, Gif_Image *, gfs->imagescap);
00157     if (!gfs->images) return 0;
00158   }
00159   gfs->images[gfs->nimages] = gfi;
00160   gfs->nimages++;
00161   gfi->refcount++;
00162   return 1;
00163 }

void Gif_CalculateScreenSize Gif_Stream  ,
int    force
 

Definition at line 241 of file giffunc.c.

References Gif_Image::height, i, Gif_Stream::images, Gif_Image::left, Gif_Stream::nimages, Gif_Stream::screen_height, Gif_Stream::screen_width, Gif_Image::top, and Gif_Image::width.

Referenced by compare(), Gif_Unoptimize(), initialize_optimizer(), merge_frame_interval(), resize_stream(), and write_logical_screen_descriptor().

00242 {
00243   int i;
00244   int screen_width = 0;
00245   int screen_height = 0;
00246   
00247   for (i = 0; i < gfs->nimages; i++) {
00248     Gif_Image *gfi = gfs->images[i];
00249     /* 17.Dec.1999 - I find this old behavior annoying. */
00250     /* if (gfi->left != 0 || gfi->top != 0) continue; */
00251     if (screen_width < gfi->left + gfi->width)
00252       screen_width = gfi->left + gfi->width;
00253     if (screen_height < gfi->top + gfi->height)
00254       screen_height = gfi->top + gfi->height;
00255   }
00256   
00257   /* Only use the default 640x480 screen size if we are being forced to create
00258      a new screen size or there's no screen size currently. */
00259   if (screen_width == 0 && (force || gfs->screen_width == 0))
00260     screen_width = 640;
00261   if (screen_height == 0 && (force || gfs->screen_height == 0))
00262     screen_height = 480;
00263   
00264   if (gfs->screen_width < screen_width || force)
00265     gfs->screen_width = screen_width;
00266   if (gfs->screen_height < screen_height || force)
00267     gfs->screen_height = screen_height;
00268 }

int Gif_ClipImage Gif_Image  ,
int    l,
int    t,
int    w,
int    h
 

Definition at line 644 of file giffunc.c.

References Gif_Image::height, Gif_Image::img, left, Gif_Image::left, top, Gif_Image::top, and Gif_Image::width.

Referenced by apply_image(), and initialize_optimizer().

00645 {
00646   int new_width = gfi->width, new_height = gfi->height;
00647   int y;
00648 
00649   if (!gfi->img) return 0;
00650   
00651   if (gfi->left < left) {
00652     int shift = left - gfi->left;
00653     for (y = 0; y < gfi->height; y++)
00654       gfi->img[y] += shift;
00655     gfi->left += shift;
00656     new_width -= shift;
00657   }
00658   
00659   if (gfi->top < top) {
00660     int shift = top - gfi->top;
00661     for (y = gfi->height - 1; y >= shift; y++)
00662       gfi->img[y - shift] = gfi->img[y];
00663     gfi->top += shift;
00664     new_height -= shift;
00665   }
00666   
00667   if (gfi->left + new_width >= width)
00668     new_width = width - gfi->left;
00669   
00670   if (gfi->top + new_height >= height)
00671     new_height = height - gfi->top;
00672   
00673   if (new_width < 0) new_width = 0;
00674   if (new_height < 0) new_height = 0;
00675   gfi->width = new_width;
00676   gfi->height = new_height;
00677   return 1;
00678 }

int Gif_ColorEq Gif_Color  ,
Gif_Color  
 

Definition at line 544 of file giffunc.c.

References GIF_COLOREQ.

00545 {
00546   return GIF_COLOREQ(c1, c2);
00547 }

int Gif_CompressImage Gif_Stream  ,
Gif_Image  
 

Definition at line 771 of file gifwrite.c.

References Gif_FullCompressImage().

00772 {
00773   return Gif_FullCompressImage(gfs, gfi, 0);
00774 }

Gif_Colormap* Gif_CopyColormap Gif_Colormap  
 

Definition at line 306 of file giffunc.c.

References Gif_Colormap::capacity, Gif_Colormap::col, Gif_NewFullColormap(), i, and Gif_Colormap::ncol.

Referenced by colormap_stream(), Gif_CopyImage(), Gif_CopyStreamSkeleton(), and read_colormap_file().

00307 {
00308   int i;
00309   Gif_Colormap *dest;
00310   if (!src) return 0;
00311   
00312   dest = Gif_NewFullColormap(src->ncol, src->capacity);
00313   if (!dest) return 0;
00314   
00315   for (i = 0; i < src->ncol; i++) {
00316     dest->col[i] = src->col[i];
00317     dest->col[i].haspixel = 0;
00318   }
00319   
00320   return dest;
00321 }

Gif_Image* Gif_CopyImage Gif_Image  
 

Definition at line 325 of file giffunc.c.

References Gif_Image::comment, Gif_Image::compressed, Gif_Image::compressed_len, Gif_Comment::count, Gif_Image::delay, Gif_Image::disposal, Gif_Image::free_compressed, Gif_Image::free_image_data, Gif_AddComment(), Gif_CopyColormap(), Gif_CopyString(), Gif_DeleteArrayFunc, Gif_DeleteImage(), Gif_NewArray, Gif_NewComment(), Gif_NewImage(), Gif_Image::height, i, Gif_Image::identifier, Gif_Image::image_data, Gif_Image::img, Gif_Image::interlace, Gif_Image::left, Gif_Comment::len, Gif_Image::local, Gif_Comment::str, Gif_Image::top, Gif_Image::transparent, and Gif_Image::width.

Referenced by Gif_CopyStreamImages(), and merge_frame_interval().

00326 {
00327   Gif_Image *dest;
00328   byte *data;
00329   int i;
00330   if (!src) return 0;
00331   
00332   dest = Gif_NewImage();
00333   if (!dest) return 0;
00334   
00335   dest->identifier = Gif_CopyString(src->identifier);
00336   if (!dest->identifier && src->identifier) goto failure;
00337   if (src->comment) {
00338     dest->comment = Gif_NewComment();
00339     if (!dest->comment) goto failure;
00340     for (i = 0; i < src->comment->count; i++)
00341       if (!Gif_AddComment(dest->comment, src->comment->str[i],
00342                           src->comment->len[i]))
00343         goto failure;
00344   }
00345   
00346   dest->local = Gif_CopyColormap(src->local);
00347   if (!dest->local && src->local) goto failure;
00348   dest->transparent = src->transparent;
00349   
00350   dest->delay = src->delay;
00351   dest->disposal = src->disposal;
00352   dest->left = src->left;
00353   dest->top = src->top;
00354   
00355   dest->width = src->width;
00356   dest->height = src->height;
00357   
00358   dest->interlace = src->interlace;
00359   if (src->img) {
00360     dest->img = Gif_NewArray(byte *, dest->height + 1);
00361     dest->image_data = Gif_NewArray(byte, dest->width * dest->height);
00362     dest->free_image_data = Gif_DeleteArrayFunc;
00363     if (!dest->img || !dest->image_data) goto failure;
00364     for (i = 0, data = dest->image_data; i < dest->height; i++) {
00365       memcpy(data, src->img[i], dest->width);
00366       dest->img[i] = data;
00367       data += dest->width;
00368     }
00369     dest->img[dest->height] = 0;
00370   }
00371   if (src->compressed) {
00372     if (src->free_compressed == 0)
00373       dest->compressed = src->compressed;
00374     else {
00375       dest->compressed = Gif_NewArray(byte, src->compressed_len);
00376       dest->free_compressed = Gif_DeleteArrayFunc;
00377       memcpy(dest->compressed, src->compressed, src->compressed_len);
00378     }
00379     dest->compressed_len = src->compressed_len;
00380   }
00381   
00382   return dest;
00383   
00384  failure:
00385   Gif_DeleteImage(dest);
00386   return 0;
00387 }

Gif_Stream* Gif_CopyStreamImages Gif_Stream  
 

Definition at line 289 of file giffunc.c.

References Gif_AddImage(), Gif_CopyImage(), Gif_CopyStreamSkeleton(), Gif_DeleteStream(), i, Gif_Stream::images, and Gif_Stream::nimages.

00290 {
00291   Gif_Stream *ngfs = Gif_CopyStreamSkeleton(gfs);
00292   int i;
00293   if (!ngfs) return 0;
00294   for (i = 0; i < gfs->nimages; i++) {
00295     Gif_Image *gfi = Gif_CopyImage(gfs->images[i]);
00296     if (!gfi || !Gif_AddImage(ngfs, gfi)) {
00297       Gif_DeleteStream(ngfs);
00298       return 0;
00299     }
00300   }
00301   return ngfs;
00302 }

Gif_Stream* Gif_CopyStreamSkeleton Gif_Stream  
 

Definition at line 272 of file giffunc.c.

References Gif_Stream::background, Gif_CopyColormap(), Gif_DeleteStream(), Gif_NewStream(), Gif_Stream::global, Gif_Stream::loopcount, Gif_Stream::screen_height, and Gif_Stream::screen_width.

Referenced by Gif_CopyStreamImages().

00273 {
00274   Gif_Stream *ngfs = Gif_NewStream();
00275   ngfs->global = Gif_CopyColormap(gfs->global);
00276   ngfs->background = gfs->background;
00277   ngfs->screen_width = gfs->screen_width;
00278   ngfs->screen_height = gfs->screen_height;
00279   ngfs->loopcount = gfs->loopcount;
00280   if (gfs->global && !ngfs->global) {
00281     Gif_DeleteStream(ngfs);
00282     return 0;
00283   } else
00284     return ngfs;
00285 }

char* Gif_CopyString char *   
 

Definition at line 137 of file giffunc.c.

References Gif_NewArray, and l.

Referenced by Gif_CopyImage(), Gif_NewExtension(), merge_frame_interval(), merge_image(), and merger_flatten().

00138 {
00139   int l;
00140   char *copy;
00141   if (!s) return 0;
00142   l = strlen(s);
00143   copy = Gif_NewArray(char, l + 1);
00144   if (!copy) return 0;
00145   memcpy(copy, s, l + 1);
00146   return copy;
00147 }

int Gif_CreateUncompressedImage Gif_Image  
 

Definition at line 726 of file giffunc.c.

References Gif_DeleteArrayFunc, Gif_NewArray, Gif_SetUncompressedImage(), Gif_Image::height, Gif_Image::interlace, and Gif_Image::width.

Referenced by merge_image(), and uncompress_image().

00727 {
00728   byte *data = Gif_NewArray(byte, gfi->width * gfi->height);
00729   return Gif_SetUncompressedImage(gfi, data, Gif_DeleteArrayFunc,
00730                                   gfi->interlace);
00731 }

void Gif_DeleteColormap Gif_Colormap  
 

Definition at line 458 of file giffunc.c.

References Gif_DeletionHook::callback_data, Gif_Colormap::col, Gif_DeletionHook::func, Gif_Delete, Gif_DeleteArray, GIF_T_COLORMAP, Gif_DeletionHook::kind, Gif_DeletionHook::next, and Gif_Colormap::refcount.

Referenced by colormap_stream(), combine_output_options(), compare(), do_colormap_change(), finalize_optimizer(), Gif_DeleteImage(), Gif_DeleteStream(), main(), pipe_color_transformer(), prepare_colormap(), and read_text_colormap().

00459 {
00460   Gif_DeletionHook *hook;
00461   if (!gfcm) return;
00462   if (--gfcm->refcount > 0) return;
00463 
00464   for (hook = all_hooks; hook; hook = hook->next)
00465     if (hook->kind == GIF_T_COLORMAP)
00466       (*hook->func)(GIF_T_COLORMAP, gfcm, hook->callback_data);
00467   
00468   Gif_DeleteArray(gfcm->col);
00469   Gif_Delete(gfcm);
00470 }

void Gif_DeleteComment Gif_Comment  
 

Definition at line 474 of file giffunc.c.

References Gif_Comment::count, Gif_Delete, Gif_DeleteArray, i, Gif_Comment::len, and Gif_Comment::str.

Referenced by blank_frameset(), fix_total_crop(), Gif_DeleteImage(), Gif_DeleteStream(), main(), and merge_frame_interval().

00475 {
00476   int i;
00477   if (!gfcom) return;
00478   for (i = 0; i < gfcom->count; i++)
00479     Gif_DeleteArray(gfcom->str[i]);
00480   Gif_DeleteArray(gfcom->str);
00481   Gif_DeleteArray(gfcom->len);
00482   Gif_Delete(gfcom);
00483 }

void Gif_DeleteExtension Gif_Extension  
 

Definition at line 487 of file giffunc.c.

References Gif_Extension::application, Gif_Extension::data, Gif_Stream::extensions, Gif_Extension::free_data, Gif_Delete, Gif_DeleteArray, Gif_Extension::next, and Gif_Extension::stream.

Referenced by copy_extension(), Gif_DeleteStream(), and Gif_NewExtension().

00488 {
00489   if (!gfex) return;
00490   if (gfex->data && gfex->free_data)
00491     (*gfex->free_data)(gfex->data);
00492   Gif_DeleteArray(gfex->application);
00493   if (gfex->stream) {
00494     Gif_Stream *gfs = gfex->stream;
00495     Gif_Extension *prev, *trav;
00496     for (prev = 0, trav = gfs->extensions;
00497          trav && trav != gfex;
00498          prev = trav, trav = trav->next)
00499       ;
00500     if (trav) {
00501       if (prev) prev->next = trav->next;
00502       else gfs->extensions = trav->next;
00503     }
00504   }
00505   Gif_Delete(gfex);
00506 }

void Gif_DeleteImage Gif_Image  
 

Definition at line 433 of file giffunc.c.

References Gif_DeletionHook::callback_data, Gif_Image::comment, Gif_Image::compressed, Gif_Image::free_compressed, Gif_Image::free_image_data, Gif_Image::free_user_data, Gif_DeletionHook::func, Gif_Delete, Gif_DeleteArray, Gif_DeleteColormap(), Gif_DeleteComment(), GIF_T_IMAGE, Gif_Image::identifier, Gif_Image::image_data, Gif_Image::img, Gif_DeletionHook::kind, Gif_Image::local, Gif_DeletionHook::next, Gif_Image::refcount, and Gif_Image::user_data.

Referenced by Gif_CopyImage(), Gif_DeleteStream(), Gif_RemoveImage(), merge_frame_interval(), and read_gif().

00434 {
00435   Gif_DeletionHook *hook;
00436   if (!gfi) return;
00437   if (--gfi->refcount > 0) return;
00438   
00439   for (hook = all_hooks; hook; hook = hook->next)
00440     if (hook->kind == GIF_T_IMAGE)
00441       (*hook->func)(GIF_T_IMAGE, gfi, hook->callback_data);
00442   
00443   Gif_DeleteArray(gfi->identifier);
00444   Gif_DeleteComment(gfi->comment);
00445   Gif_DeleteColormap(gfi->local);
00446   if (gfi->image_data && gfi->free_image_data)
00447     (*gfi->free_image_data)((void *)gfi->image_data);
00448   Gif_DeleteArray(gfi->img);
00449   if (gfi->compressed && gfi->free_compressed)
00450     (*gfi->free_compressed)((void *)gfi->compressed);
00451   if (gfi->user_data && gfi->free_user_data)
00452     (*gfi->free_user_data)(gfi->user_data);
00453   Gif_Delete(gfi);
00454 }

void Gif_DeleteStream Gif_Stream  
 

Definition at line 402 of file giffunc.c.

References Gif_DeletionHook::callback_data, Gif_Stream::comment, Gif_Stream::extensions, Gif_DeletionHook::func, Gif_Delete, Gif_DeleteArray, Gif_DeleteColormap(), Gif_DeleteComment(), Gif_DeleteExtension(), Gif_DeleteImage(), GIF_T_STREAM, Gif_Stream::global, i, Gif_Stream::images, Gif_DeletionHook::kind, Gif_Extension::next, Gif_DeletionHook::next, Gif_Stream::nimages, Gif_Stream::refcount, and Gif_Extension::stream.

Referenced by blank_frameset(), delete_viewer(), get_input_stream(), Gif_CopyStreamImages(), Gif_CopyStreamSkeleton(), input_done(), input_stream(), main(), merge_and_write_frames(), merge_frame_interval(), and read_colormap_file().

00403 {
00404   Gif_Extension *gfex;
00405   Gif_DeletionHook *hook;
00406   int i;
00407   if (!gfs) return;
00408   if (--gfs->refcount > 0) return;
00409   
00410   Gif_DeleteColormap(gfs->global);
00411   Gif_DeleteComment(gfs->comment);
00412   
00413   for (i = 0; i < gfs->nimages; i++)
00414     Gif_DeleteImage(gfs->images[i]);
00415   Gif_DeleteArray(gfs->images);
00416   
00417   gfex = gfs->extensions;
00418   while (gfex) {
00419     Gif_Extension *next = gfex->next;
00420     gfex->stream = 0;
00421     Gif_DeleteExtension(gfex);
00422     gfex = next;
00423   }
00424   
00425   for (hook = all_hooks; hook; hook = hook->next)
00426     if (hook->kind == GIF_T_STREAM)
00427       (*hook->func)(GIF_T_STREAM, gfs, hook->callback_data);
00428   Gif_Delete(gfs);
00429 }

int Gif_FindColor Gif_Colormap  ,
Gif_Color  
 

Definition at line 551 of file giffunc.c.

References c, Gif_Colormap::col, GIF_COLOREQ, i, and Gif_Colormap::ncol.

Referenced by find_color_or_error().

00552 {
00553   int i;
00554   for (i = 0; i < gfcm->ncol; i++)
00555     if (GIF_COLOREQ(&gfcm->col[i], c))
00556       return i;
00557   return -1;
00558 }

int Gif_FullCompressImage Gif_Stream  ,
Gif_Image  ,
int   
 

Definition at line 417 of file gifwrite.c.

References Gif_Writer::block_putter, Gif_Writer::byte_putter, calculate_min_code_bits(), Gif_Writer::cap, Gif_Image::compressed, Gif_Image::compressed_len, flags, Gif_Writer::flags, Gif_Image::free_compressed, Gif_Code, Gif_DeleteArray, Gif_DeleteArrayFunc, GIF_MAX_CODE, Gif_NewArray, memory_block_putter(), memory_byte_putter(), Gif_Writer::pos, Gif_Context::rle_next, Gif_Writer::v, and write_image_data().

Referenced by calculate_min_code_bits(), Gif_CompressImage(), merge_frame_interval(), and transp_frame_data().

00418 {
00419   int ok = 0;
00420   byte min_code_bits;
00421   Gif_Writer grr;
00422   Gif_Context gfc;
00423   
00424   if (gfi->compressed && gfi->free_compressed) {
00425     (*gfi->free_compressed)((void *)gfi->compressed);
00426     gfi->compressed = 0;
00427   }
00428   
00429   gfc.nodes = Gif_NewArray(Gif_Node, NODES_SIZE);
00430   gfc.links = Gif_NewArray(Gif_Node *, LINKS_SIZE);
00431   
00432   grr.v = Gif_NewArray(byte, 1024);
00433   grr.pos = 0;
00434   grr.cap = 1024;
00435   grr.byte_putter = memory_byte_putter;
00436   grr.block_putter = memory_block_putter;
00437   grr.flags = flags;
00438   grr.global_size = get_color_table_size(gfs, 0, &grr);
00439   grr.local_size = get_color_table_size(gfs, gfi, &grr);
00440   
00441   if (!gfc.nodes || !gfc.links || !grr.v)
00442     goto done;
00443 
00444   min_code_bits = calculate_min_code_bits(gfs, gfi, &grr);
00445   ok = write_image_data(gfi, min_code_bits, &gfc, &grr);
00446   
00447  done:
00448   if (!ok) {
00449     Gif_DeleteArray(grr.v);
00450     grr.v = 0;
00451   }
00452   gfi->compressed = grr.v;
00453   gfi->compressed_len = grr.pos;
00454   gfi->free_compressed = Gif_DeleteArrayFunc;
00455   Gif_DeleteArray(gfc.nodes);
00456   Gif_DeleteArray(gfc.links);
00457   return grr.v != 0;
00458 }

Gif_Stream* Gif_FullReadFile FILE *   ,
int    flags,
Gif_ReadErrorHandler   ,
void *   
 

Definition at line 857 of file gifread.c.

References Gif_Reader::block_getter, Gif_Reader::byte_getter, Gif_Reader::eofer, Gif_Reader::f, file_block_getter(), file_byte_getter(), file_eofer(), file_offseter(), Gif_ReadErrorHandler, Gif_Reader::is_record, Gif_Reader::offseter, and read_gif().

Referenced by get_input_stream(), Gif_ReadFile(), input_stream(), and main().

00859 {
00860   Gif_Reader grr;
00861   if (!f) return 0;
00862   grr.f = f;
00863   grr.is_record = 0;
00864   grr.byte_getter = file_byte_getter;
00865   grr.block_getter = file_block_getter;
00866   grr.offseter = file_offseter;
00867   grr.eofer = file_eofer;
00868   return read_gif(&grr, read_flags, h, hthunk);
00869 }

Gif_Stream* Gif_FullReadRecord const Gif_Record  ,
int    flags,
Gif_ReadErrorHandler   ,
void *   
 

Definition at line 872 of file gifread.c.

References Gif_Record::data, GIF_READ_COMPRESSED, GIF_READ_CONST_RECORD, Gif_ReadErrorHandler, Gif_Record::length, make_data_reader(), and read_gif().

Referenced by Gif_ReadRecord().

00874 {
00875   Gif_Reader grr;
00876   if (!gifrec) return 0;
00877   make_data_reader(&grr, gifrec->data, gifrec->length);
00878   if (read_flags & GIF_READ_CONST_RECORD)
00879     read_flags |= GIF_READ_COMPRESSED;
00880   return read_gif(&grr, read_flags, h, hthunk);
00881 }

int Gif_FullUncompressImage Gif_Image  ,
Gif_ReadErrorHandler   ,
void *   
 

Definition at line 502 of file gifread.c.

References Gif_Image::compressed, Gif_Image::compressed_len, Gif_Stream::errors, Gif_Code, Gif_DeleteArray, GIF_MAX_CODE, Gif_NewArray, Gif_ReadErrorHandler, Gif_Context::handler, Gif_Context::handler_thunk, Gif_Image::image_data, Gif_Image::img, Gif_Context::length, make_data_reader(), Gif_Context::prefix, Gif_Context::stream, Gif_Context::suffix, u_int16_t, and uncompress_image().

00503 {
00504   Gif_Context gfc;
00505   Gif_Stream fake_gfs;
00506   Gif_Reader grr;
00507   int ok = 0;
00508   
00509   /* return right away if image is already uncompressed. this might screw over
00510      people who expect re-uncompressing to restore the compressed version. */
00511   if (gfi->img)
00512     return 1;
00513   if (gfi->image_data)
00514     /* we have uncompressed data, but not an `img' array;
00515        this shouldn't happen */
00516     return 0;
00517   
00518   fake_gfs.errors = 0;
00519   gfc.stream = &fake_gfs;
00520   gfc.prefix = Gif_NewArray(Gif_Code, GIF_MAX_CODE);
00521   gfc.suffix = Gif_NewArray(byte, GIF_MAX_CODE);
00522   gfc.length = Gif_NewArray(u_int16_t, GIF_MAX_CODE);
00523   gfc.handler = h;
00524   gfc.handler_thunk = hthunk;
00525   
00526   if (gfi && gfc.prefix && gfc.suffix && gfc.length && gfi->compressed) {
00527     make_data_reader(&grr, gfi->compressed, gfi->compressed_len);
00528     ok = uncompress_image(&gfc, gfi, &grr);
00529   }
00530   
00531   Gif_DeleteArray(gfc.prefix);
00532   Gif_DeleteArray(gfc.suffix);
00533   Gif_DeleteArray(gfc.length);
00534   return ok && !fake_gfs.errors;
00535 }

int Gif_FullWriteFile Gif_Stream  ,
int    flags,
FILE *   
 

Definition at line 756 of file gifwrite.c.

References Gif_Writer::block_putter, Gif_Writer::byte_putter, Gif_Writer::f, file_block_putter(), file_byte_putter(), flags, Gif_Writer::flags, and write_gif().

Referenced by Gif_WriteFile(), and write_stream().

00757 {
00758   Gif_Writer grr;
00759   grr.f = f;
00760   grr.byte_putter = file_byte_putter;
00761   grr.block_putter = file_block_putter;
00762   grr.flags = flags;
00763   return write_gif(gfs, &grr);
00764 }

Gif_Extension* Gif_GetExtension Gif_Stream  ,
int   ,
Gif_Extension  
 

Definition at line 609 of file giffunc.c.

References Gif_Stream::extensions, Gif_Extension::kind, and Gif_Extension::next.

00610 {
00611   if (!search_from) search_from = gfs->extensions;
00612   while (search_from) {
00613     if (search_from->kind == id)
00614       return search_from;
00615     search_from = search_from->next;
00616   }
00617   return 0;
00618 }

Gif_Image* Gif_GetImage Gif_Stream  ,
int   
 

Definition at line 582 of file giffunc.c.

References Gif_Stream::images, and Gif_Stream::nimages.

Referenced by show_frame().

00583 {
00584   if (imagenumber >= 0 && imagenumber < gfs->nimages)
00585     return gfs->images[imagenumber];
00586   else
00587     return 0;
00588 }

Gif_Image* Gif_GetNamedImage Gif_Stream  ,
const char *   
 

Definition at line 592 of file giffunc.c.

References i, Gif_Stream::images, name, and Gif_Stream::nimages.

Referenced by frame_argument(), and parse_frame_spec().

00593 {
00594   int i;
00595   
00596   if (!name)
00597     return gfs->nimages ? gfs->images[0] : 0;
00598   
00599   for (i = 0; i < gfs->nimages; i++)
00600     if (gfs->images[i]->identifier &&
00601         strcmp(gfs->images[i]->identifier, name) == 0)
00602       return gfs->images[i];
00603   
00604   return 0;
00605 }

int Gif_ImageNumber Gif_Stream  ,
Gif_Image  
 

Definition at line 230 of file giffunc.c.

References i, Gif_Stream::images, and Gif_Stream::nimages.

Referenced by frame_argument(), image_info(), output_frames(), and parse_frame_spec().

00231 {
00232   int i;
00233   for (i = 0; i < gfs->nimages; i++)
00234     if (gfs->images[i] == gfi)
00235       return i;
00236   return -1;
00237 }

int Gif_InterlaceLine int    y,
int    height
 

HOOKS AND MISCELLANEOUS *

Definition at line 682 of file giffunc.c.

Referenced by Gif_SetUncompressedImage(), and write_image_data().

00683 {
00684   height--;
00685   if (line > height / 2)
00686     return line * 2 - ( height       | 1);
00687   else if (line > height / 4)
00688     return line * 4 - ((height & ~1) | 2);
00689   else if (line > height / 8)
00690     return line * 8 - ((height & ~3) | 4);
00691   else
00692     return line * 8;
00693 }

Gif_Colormap* Gif_NewColormap void   
 

Definition at line 72 of file giffunc.c.

References Gif_Colormap::capacity, Gif_Colormap::col, Gif_New, Gif_Colormap::ncol, Gif_Colormap::refcount, and Gif_Colormap::userflags.

00073 {
00074   Gif_Colormap *gfcm = Gif_New(Gif_Colormap);
00075   if (!gfcm) return 0;
00076   gfcm->ncol = 0;
00077   gfcm->capacity = 0;
00078   gfcm->col = 0;
00079   gfcm->refcount = 0;
00080   gfcm->userflags = 0;
00081   return gfcm;
00082 }

Gif_Comment* Gif_NewComment void   
 

Definition at line 105 of file giffunc.c.

References Gif_Comment::cap, Gif_Comment::count, Gif_New, Gif_Comment::len, and Gif_Comment::str.

Referenced by fix_total_crop(), Gif_CopyImage(), main(), merge_frame_interval(), merge_image(), merge_stream(), and read_comment_extension().

00106 {
00107   Gif_Comment *gfcom = Gif_New(Gif_Comment);
00108   if (!gfcom) return 0;
00109   gfcom->str = 0;
00110   gfcom->len = 0;
00111   gfcom->count = gfcom->cap = 0;
00112   return gfcom;
00113 }

Gif_Extension* Gif_NewExtension int   ,
char *   
 

Definition at line 117 of file giffunc.c.

References Gif_Extension::application, Gif_Extension::data, Gif_Extension::free_data, Gif_CopyString(), Gif_DeleteExtension(), Gif_New, Gif_Extension::kind, Gif_Extension::next, Gif_Extension::position, and Gif_Extension::stream.

Referenced by copy_extension(), handle_extension(), and read_unknown_extension().

00118 {
00119   Gif_Extension *gfex = Gif_New(Gif_Extension);
00120   if (!gfex) return 0;
00121   gfex->kind = app_name ? 255 : kind;
00122   gfex->application = Gif_CopyString(app_name);
00123   gfex->data = 0;
00124   gfex->position = 0;
00125   gfex->stream = 0;
00126   gfex->next = 0;
00127   gfex->free_data = 0;
00128   if (!gfex->application && app_name) {
00129     Gif_DeleteExtension(gfex);
00130     return 0;
00131   }
00132   return gfex;
00133 }

Gif_Colormap* Gif_NewFullColormap int    count,
int    capacity
 

Definition at line 86 of file giffunc.c.

References Gif_Colormap::capacity, Gif_Colormap::col, Gif_Delete, Gif_New, Gif_NewArray, Gif_Colormap::ncol, Gif_Colormap::refcount, and Gif_Colormap::userflags.

Referenced by colormap_diversity(), colormap_median_cut(), compare(), create_out_global_map(), Gif_CopyColormap(), initialize_optimizer(), merge_frame_interval(), merge_image(), prepare_colormap(), read_color_table(), read_text_colormap(), and set_new_fixed_colormap().

00087 {
00088   Gif_Colormap *gfcm = Gif_New(Gif_Colormap);
00089   if (!gfcm || capacity <= 0 || count < 0) return 0;
00090   if (count > capacity) capacity = count;
00091   gfcm->ncol = count;
00092   gfcm->capacity = capacity;
00093   gfcm->col = Gif_NewArray(Gif_Color, capacity);
00094   gfcm->refcount = 0;
00095   gfcm->userflags = 0;
00096   if (!gfcm->col) {
00097     Gif_Delete(gfcm);
00098     return 0;
00099   } else
00100     return gfcm;
00101 }

Gif_Image* Gif_NewImage void   
 

Definition at line 46 of file giffunc.c.

References Gif_Image::comment, Gif_Image::compressed, Gif_Image::compressed_len, Gif_Image::delay, Gif_Image::disposal, Gif_Image::free_compressed, Gif_Image::free_image_data, Gif_Image::free_user_data, Gif_DeleteArrayFunc, GIF_DISPOSAL_NONE, Gif_New, Gif_Image::height, Gif_Image::identifier, Gif_Image::image_data, Gif_Image::img, Gif_Image::interlace, Gif_Image::left, Gif_Image::local, Gif_Image::refcount, Gif_Image::top, Gif_Image::transparent, Gif_Image::user_data, and Gif_Image::width.

Referenced by Gif_CopyImage(), merge_image(), and read_gif().

00047 {
00048   Gif_Image *gfi = Gif_New(Gif_Image);
00049   if (!gfi) return 0;
00050   gfi->identifier = 0;
00051   gfi->comment = 0;
00052   gfi->local = 0;
00053   gfi->transparent = -1;
00054   gfi->disposal = GIF_DISPOSAL_NONE;
00055   gfi->delay = 0;
00056   gfi->left = gfi->top = gfi->width = gfi->height = 0;
00057   gfi->interlace = 0;
00058   gfi->img = 0;
00059   gfi->image_data = 0;
00060   gfi->free_image_data = Gif_DeleteArrayFunc;
00061   gfi->compressed_len = 0;
00062   gfi->compressed = 0;
00063   gfi->free_compressed = 0;
00064   gfi->user_data = 0;
00065   gfi->free_user_data = 0;
00066   gfi->refcount = 0;
00067   return gfi;
00068 }

Gif_Stream* Gif_NewStream void   
 

Definition at line 26 of file giffunc.c.

References Gif_Stream::background, Gif_Stream::comment, Gif_Stream::errors, Gif_Stream::extensions, Gif_New, Gif_Stream::global, Gif_Stream::images, Gif_Stream::imagescap, Gif_Stream::loopcount, Gif_Stream::nimages, Gif_Stream::refcount, Gif_Stream::screen_height, Gif_Stream::screen_width, and Gif_Stream::userflags.

Referenced by Gif_CopyStreamSkeleton(), merge_frame_interval(), and read_gif().

00027 {
00028   Gif_Stream *gfs = Gif_New(Gif_Stream);
00029   if (!gfs) return 0;
00030   gfs->global = 0;
00031   gfs->background = 0;
00032   gfs->screen_width = gfs->screen_height = 0;
00033   gfs->loopcount = -1;
00034   gfs->comment = 0;
00035   gfs->images = 0;
00036   gfs->nimages = gfs->imagescap = 0;
00037   gfs->extensions = 0;
00038   gfs->errors = 0;
00039   gfs->userflags = 0;
00040   gfs->refcount = 0;
00041   return gfs;
00042 }

Gif_Stream* Gif_ReadFile FILE *   
 

Definition at line 888 of file gifread.c.

References Gif_FullReadFile(), and GIF_READ_UNCOMPRESSED.

00889 {
00890   return Gif_FullReadFile(f, GIF_READ_UNCOMPRESSED, 0, 0);
00891 }

Gif_Stream* Gif_ReadRecord const Gif_Record  
 

Definition at line 894 of file gifread.c.

References Gif_FullReadRecord(), and GIF_READ_UNCOMPRESSED.

00895 {
00896   return Gif_FullReadRecord(gifrec, GIF_READ_UNCOMPRESSED, 0, 0);
00897 }

void Gif_ReleaseCompressedImage Gif_Image  
 

Definition at line 622 of file giffunc.c.

References Gif_Image::compressed, Gif_Image::compressed_len, and Gif_Image::free_compressed.

Referenced by apply_image(), create_subimages(), merge_frame_interval(), scale_image(), transp_frame_data(), and unoptimize_image().

00623 {
00624   if (gfi->compressed && gfi->free_compressed)
00625     (*gfi->free_compressed)(gfi->compressed);
00626   gfi->compressed = 0;
00627   gfi->compressed_len = 0;
00628   gfi->free_compressed = 0;
00629 }

void Gif_ReleaseUncompressedImage Gif_Image  
 

Definition at line 632 of file giffunc.c.

References Gif_Image::free_image_data, Gif_DeleteArray, Gif_Image::image_data, and Gif_Image::img.

Referenced by apply_image(), colormap_stream(), create_new_image_data(), Gif_SetUncompressedImage(), Gif_XSubMask(), merge_frame_interval(), put_sub_image_colormap(), rotate_image(), scale_image(), and transp_frame_data().

00633 {
00634   Gif_DeleteArray(gfi->img);
00635   if (gfi->image_data && gfi->free_image_data)
00636     (*gfi->free_image_data)(gfi->image_data);
00637   gfi->img = 0;
00638   gfi->image_data = 0;
00639   gfi->free_image_data = 0;
00640 }

void Gif_RemoveDeletionHook int   ,
Gif_DeletionHookFunc   ,
void *   
 

void Gif_RemoveImage Gif_Stream  ,
int   
 

Definition at line 167 of file giffunc.c.

References Gif_DeleteImage(), Gif_Stream::images, and Gif_Stream::nimages.

00168 {
00169   int j;
00170   if (inum < 0 || inum >= gfs->nimages)
00171     return;
00172   Gif_DeleteImage(gfs->images[inum]);
00173   for (j = inum; j < gfs->nimages - 1; j++)
00174     gfs->images[j] = gfs->images[j+1];
00175   gfs->nimages--;
00176 }

int Gif_SetUncompressedImage Gif_Image  ,
byte   data,
void(*    free_data)(void *),
int    data_interlaced
 

Definition at line 697 of file giffunc.c.

References Gif_Image::free_image_data, Gif_InterlaceLine(), Gif_NewArray, Gif_ReleaseUncompressedImage(), Gif_Image::height, i, Gif_Image::image_data, Gif_Image::img, and Gif_Image::width.

Referenced by colormap_stream(), create_new_image_data(), Gif_CreateUncompressedImage(), rotate_image(), scale_image(), and unoptimize_image().

00699 {
00700   int i;
00701   int width = gfi->width;
00702   int height = gfi->height;
00703   byte **img;
00704   
00705   Gif_ReleaseUncompressedImage(gfi);
00706   if (!image_data) return 0;
00707   
00708   img = Gif_NewArray(byte *, height + 1);
00709   if (!img) return 0;
00710   
00711   if (data_interlaced)
00712     for (i = 0; i < height; i++)
00713       img[ Gif_InterlaceLine(i, height) ] = image_data + width * i;
00714   else
00715     for (i = 0; i < height; i++)
00716       img[i] = image_data + width * i;
00717   img[height] = 0;
00718   
00719   gfi->img = img;
00720   gfi->image_data = image_data;
00721   gfi->free_image_data = free_data;
00722   return 1;
00723 }

int Gif_Unoptimize Gif_Stream  
 

Definition at line 158 of file gifunopt.c.

References Gif_Stream::background, Gif_CalculateScreenSize(), Gif_DeleteArray, Gif_NewArray, Gif_Stream::global, i, Gif_Stream::images, Gif_Stream::nimages, Gif_Stream::screen_height, Gif_Stream::screen_width, Gif_Image::transparent, TRANSPARENT, u_int16_t, and unoptimize_image().

Referenced by input_stream().

00159 {
00160   int ok = 1;
00161   int i, size;
00162   u_int16_t *screen;
00163   u_int16_t background;
00164   Gif_Image *gfi;
00165   
00166   if (gfs->nimages < 1) return 1;
00167   for (i = 0; i < gfs->nimages; i++)
00168     if (gfs->images[i]->local)
00169       return 0;
00170   if (!gfs->global)
00171     return 0;
00172   
00173   Gif_CalculateScreenSize(gfs, 0);
00174   size = gfs->screen_width * gfs->screen_height;
00175   
00176   screen = Gif_NewArray(u_int16_t, size);
00177   gfi = gfs->images[0];
00178   background = gfi->transparent >= 0 ? TRANSPARENT : gfs->background;
00179   for (i = 0; i < size; i++)
00180     screen[i] = background;
00181   
00182   for (i = 0; i < gfs->nimages; i++)
00183     if (!unoptimize_image(gfs, gfs->images[i], screen))
00184       ok = 0;
00185   
00186   Gif_DeleteArray(screen);
00187   return ok;
00188 }

int Gif_WriteFile Gif_Stream  ,
FILE *   
 

Definition at line 777 of file gifwrite.c.

References Gif_FullWriteFile().

00778 {
00779   return Gif_FullWriteFile(gfs, 0, f);
00780 }
 

Powered by Plone

This site conforms to the following standards: