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  

giffunc.c File Reference

#include "gif.h"
#include <string.h>
#include <stdarg.h>

Go to the source code of this file.


Data Structures

struct  Gif_DeletionHook

Typedefs

typedef Gif_DeletionHook Gif_DeletionHook

Functions

Gif_StreamGif_NewStream (void)
Gif_ImageGif_NewImage (void)
Gif_ColormapGif_NewColormap (void)
Gif_ColormapGif_NewFullColormap (int count, int capacity)
Gif_CommentGif_NewComment (void)
Gif_ExtensionGif_NewExtension (int kind, char *app_name)
char * Gif_CopyString (char *s)
int Gif_AddImage (Gif_Stream *gfs, Gif_Image *gfi)
void Gif_RemoveImage (Gif_Stream *gfs, int inum)
int Gif_AddCommentTake (Gif_Comment *gfcom, char *x, int xlen)
int Gif_AddComment (Gif_Comment *gfcom, char *x, int xlen)
int Gif_AddExtension (Gif_Stream *gfs, Gif_Extension *gfex, int pos)
int Gif_ImageNumber (Gif_Stream *gfs, Gif_Image *gfi)
void Gif_CalculateScreenSize (Gif_Stream *gfs, int force)
Gif_StreamGif_CopyStreamSkeleton (Gif_Stream *gfs)
Gif_StreamGif_CopyStreamImages (Gif_Stream *gfs)
Gif_ColormapGif_CopyColormap (Gif_Colormap *src)
Gif_ImageGif_CopyImage (Gif_Image *src)
void Gif_DeleteStream (Gif_Stream *gfs)
void Gif_DeleteImage (Gif_Image *gfi)
void Gif_DeleteColormap (Gif_Colormap *gfcm)
void Gif_DeleteComment (Gif_Comment *gfcom)
void Gif_DeleteExtension (Gif_Extension *gfex)
int Gif_AddDeletionHook (int kind, void(*func)(int, void *, void *), void *cb)
void Gif_RemoveDeletionHook (int kind, void(*func)(int, void *, void *), void *cb)
int Gif_ColorEq (Gif_Color *c1, Gif_Color *c2)
int Gif_FindColor (Gif_Colormap *gfcm, Gif_Color *c)
int Gif_AddColor (Gif_Colormap *gfcm, Gif_Color *c, int look_from)
Gif_ImageGif_GetImage (Gif_Stream *gfs, int imagenumber)
Gif_ImageGif_GetNamedImage (Gif_Stream *gfs, const char *name)
Gif_ExtensionGif_GetExtension (Gif_Stream *gfs, int id, Gif_Extension *search_from)
void Gif_ReleaseCompressedImage (Gif_Image *gfi)
void Gif_ReleaseUncompressedImage (Gif_Image *gfi)
int Gif_ClipImage (Gif_Image *gfi, int left, int top, int width, int height)
int Gif_InterlaceLine (int line, int height)
int Gif_SetUncompressedImage (Gif_Image *gfi, byte *image_data, void(*free_data)(void *), int data_interlaced)
int Gif_CreateUncompressedImage (Gif_Image *gfi)
void Gif_Debug (char *x,...)

Variables

Gif_DeletionHookall_hooks

Typedef Documentation

typedef struct Gif_DeletionHook Gif_DeletionHook
 

DELETION *


Function Documentation

int Gif_AddColor Gif_Colormap   gfcm,
Gif_Color   c,
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   gfcom,
char *    x,
int    xlen
 

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   gfcom,
char *    x,
int    xlen
 

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    kind,
void(*    func)(int, void *, void *),
void *    cb
 

DELETION HOOKS *

Definition at line 512 of file giffunc.c.

References Gif_DeletionHook::callback_data, Gif_DeletionHook::func, Gif_New, Gif_RemoveDeletionHook(), Gif_DeletionHook::kind, and Gif_DeletionHook::next.

Referenced by Gif_NewXContextFromVisual().

00513 {
00514   Gif_DeletionHook *hook = Gif_New(Gif_DeletionHook);
00515   if (!hook) return 0;
00516   Gif_RemoveDeletionHook(kind, func, cb);
00517   hook->kind = kind;
00518   hook->func = func;
00519   hook->callback_data = cb;
00520   hook->next = all_hooks;
00521   all_hooks = hook;
00522   return 1;
00523 }

int Gif_AddExtension Gif_Stream   gfs,
Gif_Extension   gfex,
int    pos
 

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   gfs,
Gif_Image   gfi
 

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   gfs,
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   gfi,
int    left,
int    top,
int    width,
int    height
 

Definition at line 644 of file giffunc.c.

References Gif_Image::height, Gif_Image::img, Gif_Image::left, left, Gif_Image::top, 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   c1,
Gif_Color   c2
 

Definition at line 544 of file giffunc.c.

References GIF_COLOREQ.

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

Gif_Colormap* Gif_CopyColormap Gif_Colormap   src
 

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   src
 

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   gfs
 

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   gfs
 

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 *    s
 

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   gfi
 

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_Debug char *    x,
...   
 

Definition at line 735 of file giffunc.c.

00736 {
00737   va_list val;
00738   va_start(val, x);
00739   vfprintf(stderr, x, val);
00740   fputc(' ', stderr);
00741   va_end(val);
00742 }

void Gif_DeleteColormap Gif_Colormap   gfcm
 

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   gfcom
 

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   gfex
 

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   gfi
 

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   gfs
 

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_DeletionHook::next, Gif_Extension::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   gfcm,
Gif_Color   c
 

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 }

Gif_Extension* Gif_GetExtension Gif_Stream   gfs,
int    id,
Gif_Extension   search_from
 

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   gfs,
int    imagenumber
 

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   gfs,
const char *    name
 

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   gfs,
Gif_Image   gfi
 

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    kind,
char *    app_name
 

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 }

void Gif_ReleaseCompressedImage Gif_Image   gfi
 

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   gfi
 

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    kind,
void(*    func)(int, void *, void *),
void *    cb
 

Definition at line 526 of file giffunc.c.

References Gif_DeletionHook::callback_data, Gif_DeletionHook::func, Gif_Delete, Gif_DeletionHook::kind, and Gif_DeletionHook::next.

Referenced by Gif_AddDeletionHook(), and Gif_DeleteXContext().

00527 {
00528   Gif_DeletionHook *hook = all_hooks, *prev = 0;
00529   while (hook) {
00530     if (hook->kind == kind && hook->func == func
00531         && hook->callback_data == cb) {
00532       if (prev) prev->next = hook->next;
00533       else all_hooks = hook->next;
00534       Gif_Delete(hook);
00535       return;
00536     }
00537     prev = hook;
00538     hook = hook->next;
00539   }
00540 }

void Gif_RemoveImage Gif_Stream   gfs,
int    inum
 

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   gfi,
byte   image_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 }

Variable Documentation

Gif_DeletionHook* all_hooks [static]
 

Definition at line 399 of file giffunc.c.

 

Powered by Plone

This site conforms to the following standards: