+Note: The version at this site also supports GIF format, for those people +who have not yet managed to move away from GIFs. +
+Please do not ask the original author to send you the old GIF version of GD. Unisys holds a patent on the LZW compression algorithm, which is used in fully compressed GIF images. The best solution is to move to legally unencumbered, well-compressed, @@ -103,6 +108,18 @@
Portions relating to libttf copyright 1999, 2000 John Ellson (ellson@lucent.com).
+GIF decompression code copyright 1990, 1991, 1993, by David Koblas +(koblas@netcom.com). +
+Non-LZW-based GIF compression code copyright 1998, by Hutchison Avenue +Software Corporation (http://www.hasc.com/, +info@hasc.com). +
+LZW-based GIF compression code David Rowley. +Obtaining a license for the Unisys LZW compression patent is +entirely between the user and Unisys. The authors of gd can provide +NO assistance in this matter. +
Portions relating to JPEG and to color quantization copyright 2000, Doug Becker and copyright (C) 1994-1998, Thomas G. Lane. This software is based in part on the work of the Independent JPEG Group. See the file @@ -193,6 +210,26 @@
What's new in the patched version?
+
+This version reinstates GIF support. Specifically, the following functions are added:
+
+Note: While every effort has been made to ensure that the _WinNT_ build works, it has not +been tested. +
gdImageCreateFromXpm
function, if the Xpm library is available. Thanks to Caolan McNamara.
What's new in version 1.6.3?
Version 1.6.3 corrects a memory leak in gd_png.c. This leak caused
a significant amount of memory to be allocated and not freed when
@@ -911,7 +951,8 @@
typedef struct { @@ -921,7 +962,8 @@
+
+gdImagePtr im; +... inside a function ... +FILE *in; +in = fopen("mygif.gif", "rb"); +im = gdImageCreateFromGif(in); +fclose(in); +/* ... Use the image ... */ +gdImageDestroy(im); ++
+The programmer must write an input function which accepts
+a context pointer, a buffer, and a number of bytes to be
+read as arguments. This function must read the number of
+bytes requested, unless the end of the file has been reached,
+in which case the function should return zero, or an error
+has occurred, in which case the function should return
+-1
. The programmer then creates a
+gdSource structure and sets
+the source
pointer to the input function and
+the context pointer to any value which is useful to the
+programmer.
+
+The example below +implements gdImageCreateFromGif +by creating a custom data source and invoking gdImageCreateFromGifSource. +
+static int freadWrapper(void *context, char *buf, int len); + +gdImagePtr gdImageCreateFromGif(FILE *in) +{ + gdSource s; + s.source = freadWrapper; + s.context = in; + return gdImageCreateFromGifSource(&s); +} + +static int freadWrapper(void *context, char *buf, int len) +{ + int got = fread(buf, 1, len, (FILE *) context); + return got; +} ++ +
+... inside a function ... +gdImagePtr im; +int black, white; +FILE *out; +/* Create the image */ +im = gdImageCreate(100, 100); +/* Allocate background */ +white = gdImageColorAllocate(im, 255, 255, 255); +/* Allocate drawing color */ +black = gdImageColorAllocate(im, 0, 0, 0); +/* Draw rectangle */ +gdImageRectangle(im, 0, 0, 99, 99, black); +/* Open output file in binary mode */ +out = fopen("rect.gif", "wb"); +/* Write GIF */ +gdImageGif(im, out); +/* Close file */ +fclose(out); +/* Destroy image */ +gdImageDestroy(im); ++ +
+
+ +
+The programmer must write an output function which accepts
+a context pointer, a buffer, and a number of bytes to be
+written as arguments. This function must write the number of
+bytes requested and return that number, unless an error
+has occurred, in which case the function should return
+-1
. The programmer then creates a
+gdSink structure and sets
+the sink
pointer to the output function and
+the context pointer to any value which is useful to the
+programmer.
+
+The example below +implements gdImageGif +by creating a custom data source and invoking gdImageGifFromSink. +
+static int stdioSink(void *context, char *buffer, int len) +{ + return fwrite(buffer, 1, len, (FILE *) context); +} + +void gdImageGif(gdImagePtr im, FILE *out) +{ + gdSink mySink; + mySink.context = (void *) out; + mySink.sink = stdioSink; + gdImageGifToSink(im, &mySink); +} ++
+