lib/gifwrite.c File Reference

#include "common.h"
#include "memgfx.h"
#include "gifcodes.h"

Include dependency graph for gifwrite.c:

Go to the source code of this file.

Functions

boolean mgSaveToGif (FILE *gif_file, struct memGfx *screen)
void mgSaveGif (struct memGfx *screen, char *name)

Variables

static char const rcsid [] = "$Id: gifwrite.c,v 1.6 2003/05/21 21:02:22 kent Exp $"
static char gifsig [] = "GIF87a"


Function Documentation

void mgSaveGif ( struct memGfx screen,
char *  name 
)

Definition at line 62 of file gifwrite.c.

References errAbort(), errnoAbort(), mgSaveToGif(), and mustOpen().

Referenced by gifLabelVerticalText(), and memGifClose().

00063 {
00064 FILE *gifFile = mustOpen(name, "wb");
00065 if (!mgSaveToGif(gifFile, screen))
00066     {
00067     remove(name);
00068     errAbort("Couldn't save %s", name);
00069     }
00070 if (fclose(gifFile) != 0)
00071     errnoAbort("fclose failed");
00072 }

Here is the call graph for this function:

Here is the caller graph for this function:

boolean mgSaveToGif ( FILE *  gif_file,
struct memGfx screen 
)

Definition at line 12 of file gifwrite.c.

References memGfx::colorMap, COLPIXVGA13, FALSE, gif_image::flags, gif, gif_compress_data(), gif_wcount, gifsig, gim, memGfx::height, gif_image::hhi, gif_image::hlo, memGfx::pixels, TRUE, warn(), gif_image::whi, memGfx::width, gif_image::wlo, gif_image::xhi, gif_image::xlo, gif_image::yhi, gif_image::ylo, and zeroBytes().

Referenced by mgSaveGif().

00014 {
00015 int i;
00016 struct gif_header gif;
00017 struct gif_image gim;
00018 long gif_wcount;
00019 
00020 gif_wcount = (long)screen->width * screen->height;
00021 zeroBytes(&gif, sizeof(gif));
00022 strcpy(gif.giftype, gifsig);
00023 gif.wlo = gim.wlo = ((screen->width)&0xff);
00024 gif.whi = gim.whi = ((screen->width>>8)&0xff);
00025 gif.hlo = gim.hlo = ((screen->height)&0xff);
00026 gif.hhi = gim.hhi = ((screen->height>>8)&0xff);
00027 gim.xlo = gim.xhi = gim.ylo = gim.yhi = gim.flags = 0;
00028 gif.colpix = COLPIXVGA13;
00029 if (fwrite(&gif, sizeof(gif), 1, gif_file ) < 1)
00030     goto TRUNCOUT;
00031 /* write global color map */
00032 if (fwrite(screen->colorMap, 3, 256, gif_file) < 256)
00033     goto TRUNCOUT;
00034 if (fputc(',', gif_file) < 0) /* comma to start image */
00035     goto TRUNCOUT;
00036 if (fwrite(&gim, sizeof(gim), 1, gif_file) < 1)
00037     goto TRUNCOUT;
00038 fputc(8,gif_file);
00039 fflush(gif_file);
00040 i = gif_compress_data(8, screen->pixels, gif_wcount, gif_file);
00041 switch (i)
00042     {
00043     case 0:
00044         break;
00045     case -2:
00046         warn("Out of memory writing GIF");
00047         goto BADOUT;
00048     case -3:
00049         goto TRUNCOUT;
00050     default:
00051         warn("Error code %d writing gif", i);
00052         goto BADOUT;
00053     }
00054 fputc(';', gif_file); /* end of file for gif */
00055 return(TRUE);
00056 TRUNCOUT:
00057 warn("Disk full writing GIF");
00058 BADOUT:
00059 return(FALSE);
00060 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char gifsig[] = "GIF87a" [static]

Definition at line 9 of file gifwrite.c.

Referenced by mgSaveToGif().

char const rcsid[] = "$Id: gifwrite.c,v 1.6 2003/05/21 21:02:22 kent Exp $" [static]

Definition at line 7 of file gifwrite.c.


Generated on Tue Dec 25 19:52:34 2007 for blat by  doxygen 1.5.2