Chan-Vese Segmentation
|
Write animated GIF files. More...
Go to the source code of this file.
Functions | |
int | GifWrite (unsigned char **Image, int ImageWidth, int ImageHeight, int NumFrames, const unsigned char *Palette, int NumColors, int TransparentColor, const int *Delays, const char *OutputFile) |
Write an animated GIF image. More... | |
void | FrameDifference (unsigned char **Image, int ImageWidth, int ImageHeight, int NumFrames, int TransparentColor) |
Optimize animation frames by setting unchanged pixels to transparent. More... | |
Write animated GIF files.
Copyright (c) 2011, Pascal Getreuer All rights reserved.
This program is free software: you can redistribute it and/or modify it under, at your option, the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version, or the terms of the simplified BSD license.
You should have received a copy of these licenses along with this program. If not, see http://www.gnu.org/licenses/ and http://www.opensource.org/licenses/bsd-license.html.
Definition in file gifwrite.h.
void FrameDifference | ( | unsigned char ** | Image, |
int | ImageWidth, | ||
int | ImageHeight, | ||
int | NumFrames, | ||
int | TransparentColor | ||
) |
Optimize animation frames by setting unchanged pixels to transparent.
Image | array holding the image data for each frame |
ImageWidth,ImageHeight | dimensions of the image |
NumFrames | number of frames |
Palette | (global) color palette used by all the frames |
NumColors | number of colors in Palette |
TransparentColor | index of which color is transparent |
Delays | the delay for each frame in centiseconds |
OutputFile | filename of the output GIF file |
Definition at line 401 of file gifwrite.c.
int GifWrite | ( | unsigned char ** | Image, |
int | ImageWidth, | ||
int | ImageHeight, | ||
int | NumFrames, | ||
const unsigned char * | Palette, | ||
int | NumColors, | ||
int | TransparentColor, | ||
const int * | Delays, | ||
const char * | OutputFile | ||
) |
Write an animated GIF image.
Image | array holding the image data for each frame |
ImageWidth,ImageHeight | dimensions of the image |
NumFrames | number of frames |
Palette | (global) color palette used by all the frames |
NumColors | number of colors in Palette |
TransparentColor | index of which color is transparent |
Delays | the delay for each frame in centiseconds |
OutputFile | filename of the output GIF file |
This routine writes a sequence of image frames as an animated GIF file. Image should be an array of pointers where Image[k] points to image data in row-major order for the kth frame,
Image[k][x + ImageWidth*y] = pixel at (x,y) in the kth frame.
The value of Image[k][x + ImageWidth*y] is the palette index of the pixel's color. Palette should be ordered such that
Palette[3*i + 0] = red intensity of the ith color, Palette[3*i + 1] = green intensity of the ith color, Palette[3*i + 2] = blue intensity of the ith color,
where i = 0, 1, ... NumColors - 1. TransparentColor specifies an index to denote transparent pixels.
This routine always uses the overwrite "frame disposal" method, which means that the current frame is drawn on top of the previous ones. This approach allows animated frames to be transparent everywhere except for the pixels that differ from the preceding frame. Call the FrameDifference() function before GifWrite() to perform this optimization.
Delays is an array specifying how long each frame of the animation is shown in units of centiseconds (1/100th of a second). Specifying Delays as NULL sets a delay of 0.1 seconds per frame.
Only a limited portion of the GIF specification is implemented. Particularly,
See [1] for details on the GIF format.
For LZW compression, we follow the hash table algorithm used in GIFCSRC [2] and the UNIX "compress" program [3]. The hash table uses open addressing double hashing (no chaining) on the prefix code / next character combination and a variant of Knuth's algorithm D (vol. 3, sec. 6.4) with G. Knott's relatively-prime secondary probe.
References: [1] http://www.w3.org/Graphics/GIF/spec-gif89a.txt [2] http://www.programmersheaven.com/download/15257/download.aspx [3] http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/compress/
Definition at line 120 of file gifwrite.c.