- sync to 1.7.0

master
pierre 2006-04-05 15:38:05 +00:00
parent cc33b004a8
commit 0b986ddde7
24 changed files with 3547 additions and 1054 deletions

View File

@ -1,3 +1,8 @@
990922 Thomas Boutell (TBB)
- autoconf/automake removed in favor of an improved Makefile.
I was getting unbelievable amounts of confused email.
- Documentation updates.
- ANSI C correctness.
990729 Thomas Boutell (TBB)
- It would probably be a good idea to free the
png_write_struct, wouldn't it.

View File

@ -1,58 +1,135 @@
#Depending on your system, you will need to modify this makefile.
#If you do not have gcc, change the setting for CC, but you must
#If you do not have gcc, change the setting for COMPILER, but you must
#use an ANSI standard C compiler (NOT the old SunOS 4.1.3 cc
#compiler; get gcc if you are still using it).
COMPILER=gcc
#If the ar command fails on your system, consult the ar manpage
#for your system.
CC=gcc
AR=ar
#CFLAGS= -ggdb
CFLAGS= -g
LIBS=-L. -lgd -lz -lm -lpng
all: libgd.a gdtest gddemo pngtogd pngtogd2 gdtopng gd2topng gd2copypal gdparttopng gd2time webpng
#If the install command is not in your path, provide
#an explicit path for it here, or install manually.
INSTALL=install
gdtest: gdtest.o libgd.a gd.h
$(CC) gdtest.o -o gdtest $(LIBS)
#If you don't have FreeType and/or Xpm installed, including the
#header files, uncomment this (default).
CFLAGS=-O
#If you do have FreeType and/or Xpm fully installed, uncomment a
#variation of this and comment out the line above. See also LIBS below.
#CFLAGS=-O -DHAVE_XPM -DHAVE_LIBTTF
gddemo: gddemo.o libgd.a gd.h gdfonts.h gdfontl.h
$(CC) gddemo.o -o gddemo $(LIBS)
#If you don't have FreeType and/or Xpm fully installed, uncomment this
#(default).
LIBS=-lgd -lm -lz -lpng
#If you do have FreeType and/or Xpm fully installed, uncomment a
#variation of this and comment out the line above. Note that
#Xpm requires X11. See also CFLAGS above.
#LIBS=-lgd -lm -lttf -lpng -lXpm -lX11
pngtogd: pngtogd.o libgd.a gd.h
$(CC) pngtogd.o -o pngtogd $(LIBS)
#Typical install locations for freetype, zlib, xpm and libpng header files.
#If yours are somewhere else, change this.
INCLUDEDIRS=-I/usr/local/include -I/usr/include/X11 -I/usr/X11R6/include/X11
pngtogd2: pngtogd2.o libgd.a gd.h
$(CC) pngtogd2.o -o pngtogd2 $(LIBS)
#Typical install locations for freetype, zlib, xpm and libpng libraries.
#If yours are somewhere else, other than a standard location
#such as /lib or /usr/lib, then change this. Be sure to keep
#-L. as this allows the gd library itself to be found.
#Put -L. first so that old versions of the gd library elsewhere
#on your system can't cause conflicts while building a new one.
LIBDIRS=-L. -L/usr/local/lib -L/usr/lib/X11 -L/usr/X11R6/lib
gdtopng: gdtopng.o libgd.a gd.h
$(CC) gdtopng.o -o gdtopng $(LIBS)
#Location where libgd.a should be installed by "make install".
INSTALL_LIB=/usr/local/lib
gd2topng: gd2topng.o libgd.a gd.h
$(CC) gd2topng.o -o gd2topng $(LIBS)
#Location where .h files should be installed by "make install".
INSTALL_INCLUDE=/usr/local/include
gd2copypal: gd2copypal.o libgd.a gd.h
$(CC) gd2copypal.o -o gd2copypal $(LIBS)
#Location where useful non-test programs should be installed by "make install".
INSTALL_BIN=/usr/local/bin
gdparttopng: gdparttopng.o libgd.a gd.h
$(CC) gdparttopng.o -o gdparttopng $(LIBS)
#
#
# Changes should not be required below here.
#
#
gd2time: gd2time.o libgd.a gd.h
$(CC) gd2time.o -o gd2time $(LIBS)
VERSION=1.7
libgd.a: gd.o gd_io.o gd_io_file.o gd_io_dp.o gd_io_ss.o gd_png.o gd_ss.o \
gd_gd.o gd_gd2.o gdfontt.o gdfonts.o gdfontmb.o gdfontl.o gdfontg.o \
CC=$(COMPILER) $(INCLUDEDIRS)
LINK=$(CC) $(LIBDIRS) $(LIBS)
PROGRAMS=$(BIN_PROGRAMS) $(TEST_PROGRAMS)
BIN_PROGRAMS=pngtogd pngtogd2 gdtopng gd2topng gd2copypal gdparttopng webpng
TEST_PROGRAMS=gdtest gddemo gd2time gdtestttf
all: libgd.a $(PROGRAMS)
install: libgd.a $(BIN_PROGRAMS)
$(INSTALL) -m 644 libgd.a $(INSTALL_LIB)/libgd.a
$(INSTALL) -m 755 pngtogd $(INSTALL_BIN)/pngtogd
$(INSTALL) -m 755 pngtogd2 $(INSTALL_BIN)/pngtogd2
$(INSTALL) -m 755 gdtopng $(INSTALL_BIN)/gdtopng
$(INSTALL) -m 755 gd2topng $(INSTALL_BIN)/gd2topng
$(INSTALL) -m 755 gd2copypal $(INSTALL_BIN)/gd2copypal
$(INSTALL) -m 755 gdparttopng $(INSTALL_BIN)/gdparttopng
$(INSTALL) -m 755 webpng $(INSTALL_BIN)/webpng
$(INSTALL) -m 755 bdftogd $(INSTALL_BIN)/bdftogd
$(INSTALL) -m 644 gd.h $(INSTALL_INCLUDE)/gd.h
$(INSTALL) -m 644 gdcache.h $(INSTALL_INCLUDE)/gdcache.h
$(INSTALL) -m 644 gd_io.h $(INSTALL_INCLUDE)/gd_io.h
$(INSTALL) -m 644 gdfontg.h $(INSTALL_INCLUDE)/gdfontg.h
$(INSTALL) -m 644 gdfontl.h $(INSTALL_INCLUDE)/gdfontl.h
$(INSTALL) -m 644 gdfontmb.h $(INSTALL_INCLUDE)/gdfontmb.h
$(INSTALL) -m 644 gdfonts.h $(INSTALL_INCLUDE)/gdfonts.h
$(INSTALL) -m 644 gdfontt.h $(INSTALL_INCLUDE)/gdfontt.h
gddemo: gddemo.o libgd.a
$(CC) gddemo.o -o gddemo $(LIBDIRS) $(LIBS)
pngtogd: pngtogd.o libgd.a
$(CC) pngtogd.o -o pngtogd $(LIBDIRS) $(LIBS)
webpng: webpng.o libgd.a
$(CC) webpng.o -o webpng $(LIBDIRS) $(LIBS)
pngtogd2: pngtogd2.o libgd.a
$(CC) pngtogd2.o -o pngtogd2 $(LIBDIRS) $(LIBS)
gdtopng: gdtopng.o libgd.a
$(CC) gdtopng.o -o gdtopng $(LIBDIRS) $(LIBS)
gd2topng: gd2topng.o libgd.a
$(CC) gd2topng.o -o gd2topng $(LIBDIRS) $(LIBS)
gd2copypal: gd2copypal.o libgd.a
$(CC) gd2copypal.o -o gd2copypal $(LIBDIRS) $(LIBS)
gdparttopng: gdparttopng.o libgd.a
$(CC) gdparttopng.o -o gdparttopng $(LIBDIRS) $(LIBS)
gdtest: gdtest.o libgd.a
$(CC) gdtest.o -o gdtest $(LIBDIRS) $(LIBS)
gd2time: gd2time.o libgd.a
$(CC) gd2time.o -o gd2time $(LIBDIRS) $(LIBS)
gdtestttf: gdtestttf.o libgd.a
$(CC) gdtestttf.o -o gdtestttf $(LIBDIRS) $(LIBS)
libgd.a: gd.o gd_gd.o gd_gd2.o gd_io.o gd_io_dp.o gd_io_file.o gd_ss.o \
gd_io_ss.o gd_png.o gdxpm.o gdfontt.o gdfonts.o gdfontmb.o gdfontl.o \
gdtables.o gdfontg.o gdkanji.o \
gd.h gdfontt.h gdfonts.h gdfontmb.h gdfontl.h gdfontg.h
rm -f libgd.a
$(AR) rc libgd.a gd.o gd_io.o gd_io_file.o gd_io_dp.o gd_io_ss.o \
gd_png.o gd_ss.o gd_gd.o gd_gd2.o \
gdfontt.o gdfonts.o gdfontmb.o gdfontl.o gdfontg.o
webpng: webpng.o libgd.a gd.h
$(CC) webpng.o -o webpng $(LIBS)
$(AR) rc libgd.a gd.o gd_gd.o gd_gd2.o gd_io.o gd_io_dp.o gdxpm.o \
gd_io_file.o gd_ss.o gd_io_ss.o gd_png.o gdfontt.o gdfonts.o \
gdfontmb.o gdfontl.o gdfontg.o gd.o gdfontt.o gdfonts.o \
gdfontmb.o gdfontl.o gdfontg.o gdtables.o gdkanji.o
-ranlib libgd.a
clean:
rm -f *.o *.a gddemo gdtest pngtogd pngtogd2 gdtopng gd2topng gdparttopng gd2time gd2copypal webpng
rm -f *.o *.a ${PROGRAMS}

View File

@ -183,12 +183,20 @@ print FILEH <<"EOF";
#ifndef $capdef
#define $capdef 1
#ifdef __cplusplus
extern "C" {
#endif
$info
#include "gd.h"
extern gdFontPtr $gdname;
#ifdef __cplusplus
}
#endif
#endif
EOF

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

739
src/gd.c
View File

@ -5,10 +5,8 @@
#include <zlib.h>
#include "gd.h"
#define costScale 1024
static int cost[];
#define sintScale 1024
static int sint[];
extern int gdCosT[1024];
extern int gdSinT[1024];
static void gdImageBrushApply(gdImagePtr im, int x, int y);
static void gdImageTileApply(gdImagePtr im, int x, int y);
@ -585,7 +583,7 @@ void gdImageString(gdImagePtr im, gdFontPtr f,
{
int i;
int l;
l = strlen(s);
l = strlen((char *) s);
for (i=0; (i<l); i++) {
gdImageChar(im, f, x, y, s[i], color);
x += f->w;
@ -597,7 +595,7 @@ void gdImageStringUp(gdImagePtr im, gdFontPtr f,
{
int i;
int l;
l = strlen(s);
l = strlen((char *) s);
for (i=0; (i<l); i++) {
gdImageCharUp(im, f, x, y, s[i], color);
y -= f->w;
@ -662,8 +660,8 @@ void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int c
}
for (i=s; (i <= e); i++) {
int x, y;
x = ((long)cost[i % 360] * (long)w2 / costScale) + cx;
y = ((long)sint[i % 360] * (long)h2 / sintScale) + cy;
x = ((long)gdCosT[i % 360] * (long)w2 / 1024) + cx;
y = ((long)gdSinT[i % 360] * (long)h2 / 1024) + cy;
if (i != s) {
gdImageLine(im, lx, ly, x, y, color);
}
@ -1477,728 +1475,3 @@ int gdImageCompare(gdImagePtr im1, gdImagePtr im2)
return cmpStatus;
}
int cost[] = {
1024,
1023,
1023,
1022,
1021,
1020,
1018,
1016,
1014,
1011,
1008,
1005,
1001,
997,
993,
989,
984,
979,
973,
968,
962,
955,
949,
942,
935,
928,
920,
912,
904,
895,
886,
877,
868,
858,
848,
838,
828,
817,
806,
795,
784,
772,
760,
748,
736,
724,
711,
698,
685,
671,
658,
644,
630,
616,
601,
587,
572,
557,
542,
527,
512,
496,
480,
464,
448,
432,
416,
400,
383,
366,
350,
333,
316,
299,
282,
265,
247,
230,
212,
195,
177,
160,
142,
124,
107,
89,
71,
53,
35,
17,
0,
-17,
-35,
-53,
-71,
-89,
-107,
-124,
-142,
-160,
-177,
-195,
-212,
-230,
-247,
-265,
-282,
-299,
-316,
-333,
-350,
-366,
-383,
-400,
-416,
-432,
-448,
-464,
-480,
-496,
-512,
-527,
-542,
-557,
-572,
-587,
-601,
-616,
-630,
-644,
-658,
-671,
-685,
-698,
-711,
-724,
-736,
-748,
-760,
-772,
-784,
-795,
-806,
-817,
-828,
-838,
-848,
-858,
-868,
-877,
-886,
-895,
-904,
-912,
-920,
-928,
-935,
-942,
-949,
-955,
-962,
-968,
-973,
-979,
-984,
-989,
-993,
-997,
-1001,
-1005,
-1008,
-1011,
-1014,
-1016,
-1018,
-1020,
-1021,
-1022,
-1023,
-1023,
-1024,
-1023,
-1023,
-1022,
-1021,
-1020,
-1018,
-1016,
-1014,
-1011,
-1008,
-1005,
-1001,
-997,
-993,
-989,
-984,
-979,
-973,
-968,
-962,
-955,
-949,
-942,
-935,
-928,
-920,
-912,
-904,
-895,
-886,
-877,
-868,
-858,
-848,
-838,
-828,
-817,
-806,
-795,
-784,
-772,
-760,
-748,
-736,
-724,
-711,
-698,
-685,
-671,
-658,
-644,
-630,
-616,
-601,
-587,
-572,
-557,
-542,
-527,
-512,
-496,
-480,
-464,
-448,
-432,
-416,
-400,
-383,
-366,
-350,
-333,
-316,
-299,
-282,
-265,
-247,
-230,
-212,
-195,
-177,
-160,
-142,
-124,
-107,
-89,
-71,
-53,
-35,
-17,
0,
17,
35,
53,
71,
89,
107,
124,
142,
160,
177,
195,
212,
230,
247,
265,
282,
299,
316,
333,
350,
366,
383,
400,
416,
432,
448,
464,
480,
496,
512,
527,
542,
557,
572,
587,
601,
616,
630,
644,
658,
671,
685,
698,
711,
724,
736,
748,
760,
772,
784,
795,
806,
817,
828,
838,
848,
858,
868,
877,
886,
895,
904,
912,
920,
928,
935,
942,
949,
955,
962,
968,
973,
979,
984,
989,
993,
997,
1001,
1005,
1008,
1011,
1014,
1016,
1018,
1020,
1021,
1022,
1023,
1023
};
int sint[] = {
0,
17,
35,
53,
71,
89,
107,
124,
142,
160,
177,
195,
212,
230,
247,
265,
282,
299,
316,
333,
350,
366,
383,
400,
416,
432,
448,
464,
480,
496,
512,
527,
542,
557,
572,
587,
601,
616,
630,
644,
658,
671,
685,
698,
711,
724,
736,
748,
760,
772,
784,
795,
806,
817,
828,
838,
848,
858,
868,
877,
886,
895,
904,
912,
920,
928,
935,
942,
949,
955,
962,
968,
973,
979,
984,
989,
993,
997,
1001,
1005,
1008,
1011,
1014,
1016,
1018,
1020,
1021,
1022,
1023,
1023,
1024,
1023,
1023,
1022,
1021,
1020,
1018,
1016,
1014,
1011,
1008,
1005,
1001,
997,
993,
989,
984,
979,
973,
968,
962,
955,
949,
942,
935,
928,
920,
912,
904,
895,
886,
877,
868,
858,
848,
838,
828,
817,
806,
795,
784,
772,
760,
748,
736,
724,
711,
698,
685,
671,
658,
644,
630,
616,
601,
587,
572,
557,
542,
527,
512,
496,
480,
464,
448,
432,
416,
400,
383,
366,
350,
333,
316,
299,
282,
265,
247,
230,
212,
195,
177,
160,
142,
124,
107,
89,
71,
53,
35,
17,
0,
-17,
-35,
-53,
-71,
-89,
-107,
-124,
-142,
-160,
-177,
-195,
-212,
-230,
-247,
-265,
-282,
-299,
-316,
-333,
-350,
-366,
-383,
-400,
-416,
-432,
-448,
-464,
-480,
-496,
-512,
-527,
-542,
-557,
-572,
-587,
-601,
-616,
-630,
-644,
-658,
-671,
-685,
-698,
-711,
-724,
-736,
-748,
-760,
-772,
-784,
-795,
-806,
-817,
-828,
-838,
-848,
-858,
-868,
-877,
-886,
-895,
-904,
-912,
-920,
-928,
-935,
-942,
-949,
-955,
-962,
-968,
-973,
-979,
-984,
-989,
-993,
-997,
-1001,
-1005,
-1008,
-1011,
-1014,
-1016,
-1018,
-1020,
-1021,
-1022,
-1023,
-1023,
-1024,
-1023,
-1023,
-1022,
-1021,
-1020,
-1018,
-1016,
-1014,
-1011,
-1008,
-1005,
-1001,
-997,
-993,
-989,
-984,
-979,
-973,
-968,
-962,
-955,
-949,
-942,
-935,
-928,
-920,
-912,
-904,
-895,
-886,
-877,
-868,
-858,
-848,
-838,
-828,
-817,
-806,
-795,
-784,
-772,
-760,
-748,
-736,
-724,
-711,
-698,
-685,
-671,
-658,
-644,
-630,
-616,
-601,
-587,
-572,
-557,
-542,
-527,
-512,
-496,
-480,
-464,
-448,
-432,
-416,
-400,
-383,
-366,
-350,
-333,
-316,
-299,
-282,
-265,
-247,
-230,
-212,
-195,
-177,
-160,
-142,
-124,
-107,
-89,
-71,
-53,
-35,
-17
};

View File

@ -1,6 +1,10 @@
#ifndef GD_H
#define GD_H 1
#ifdef __cplusplus
extern "C" {
#endif
/* gd.h: declarations file for the graphic-draw module.
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
@ -225,4 +229,9 @@ int gdImageCompare(gdImagePtr im1, gdImagePtr im2);
#define GD_CMP_TRANSPARENT 32 /* Transparent colour */
#define GD_CMP_BACKGROUND 64 /* Background colour */
#define GD_CMP_INTERLACE 128 /* Interlaced setting */
#ifdef __cplusplus
}
#endif
#endif /* GD_H */

View File

@ -201,14 +201,15 @@ int _gd2ReadChunk(int offset, char *compBuf, int compSize, char *chunkBuf, uLong
return FALSE;
};
GD2_DBG(printf("Got %d bytes. Uncompressing into buffer of %d bytes\n", compSize, *chunkLen));
zerr = uncompress(chunkBuf, chunkLen, compBuf, compSize);
zerr = uncompress((unsigned char *) chunkBuf, chunkLen,
(unsigned char *) compBuf, compSize);
if (zerr != Z_OK) {
GD2_DBG(printf("Error %d from uncompress\n",zerr));
return FALSE;
};
GD2_DBG(printf("Got chunk\n"));
return TRUE;
};
}
gdImagePtr gdImageCreateFromGd2(FILE *inFile)
{
@ -668,7 +669,10 @@ static void _gdImageGd2(gdImagePtr im, gdIOCtx *out, int cs, int fmt)
};
if (fmt == GD2_FMT_COMPRESSED) {
compLen = compMax;
if (compress(&compData[0], &compLen, &chunkData[0], chunkLen) != Z_OK) {
if (compress((unsigned char *)
&compData[0], &compLen,
(unsigned char *) &chunkData[0],
chunkLen) != Z_OK) {
printf("Error from compressing\n");
} else {
chunkIdx[chunkNum].offset = gdTell(out);

View File

@ -88,7 +88,7 @@ gdIOCtx* gdNewDynamicCtx (int initialSize, void *data) {
ctx->ctx.free = freeDynamicCtx;
return (gdIOCtx*)ctx;
};
}
void* gdDPExtractData(struct gdIOCtx* ctx, int *size)
{
@ -197,7 +197,7 @@ static dynamicPtr* newDynamic (int initialSize, void *data) {
dp->pos = 0;
return dp;
};
}
static int
dynamicPutbuf( struct gdIOCtx* ctx, const void *buf, int size )

View File

@ -12,6 +12,13 @@
*
*/
/* For platforms with incomplete ANSI defines. Fortunately,
SEEK_SET is defined to be zero by the standard. */
#ifndef SEEK_SET
#define SEEK_SET 0
#endif /* SEEK_SET */
#include <math.h>
#include <string.h>
#include <stdlib.h>
@ -60,7 +67,7 @@ gdIOCtx* gdNewFileCtx (FILE *f) {
ctx->ctx.free = freeFileCtx;
return (gdIOCtx*)ctx;
};
}
static
void freeFileCtx(gdIOCtx *ctx)
@ -109,6 +116,7 @@ static int fileGetchar( gdIOCtx* ctx)
return getc(fctx->f);
}
static int fileSeek(struct gdIOCtx* ctx, const int pos)
{
fileIOCtx *fctx;

View File

@ -67,7 +67,7 @@ gdIOCtx* gdNewSSCtx (gdSourcePtr src, gdSinkPtr snk) {
ctx->ctx.free = freeSsCtx;
return (gdIOCtx*)ctx;
};
}
static
void freeSsCtx(gdIOCtx *ctx)

View File

@ -95,8 +95,10 @@ int main(void)
gdImageLine(im_out, 0, 127, 127, 0, gdStyledBrushed);
}
/* Text */
gdImageString(im_out, gdFontGiant, 16, 16, "hi", red);
gdImageStringUp(im_out, gdFontSmall, 32, 32, "hi", red);
gdImageString(im_out, gdFontGiant, 16, 16,
(unsigned char *) "hi", red);
gdImageStringUp(im_out, gdFontSmall, 32, 32,
(unsigned char *) "hi", red);
/* Make output image interlaced (allows "fade in" in some viewers,
and in the latest web browsers) */
gdImageInterlace(im_out, 1);

View File

@ -2,6 +2,10 @@
#ifndef _GDFONTG_H_
#define _GDFONTG_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
This is a header file for gd font, generated using
bdftogd version 0.51 by Jan Pazdziora, adelton@fi.muni.cz
@ -17,5 +21,9 @@
extern gdFontPtr gdFontGiant;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -2,6 +2,10 @@
#ifndef _GDFONTL_H_
#define _GDFONTL_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
This is a header file for gd font, generated using
bdftogd version 0.5 by Jan Pazdziora, adelton@fi.muni.cz
@ -18,5 +22,9 @@
extern gdFontPtr gdFontLarge;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -2,6 +2,10 @@
#ifndef _GDFONTMB_H_
#define _GDFONTMB_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
This is a header file for gd font, generated using
bdftogd version 0.5 by Jan Pazdziora, adelton@fi.muni.cz
@ -16,5 +20,9 @@
extern gdFontPtr gdFontMediumBold;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -2,6 +2,10 @@
#ifndef _GDFONTS_H_
#define _GDFONTS_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
This is a header file for gd font, generated using
bdftogd version 0.5 by Jan Pazdziora, adelton@fi.muni.cz
@ -16,5 +20,9 @@
extern gdFontPtr gdFontSmall;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -2,6 +2,10 @@
#ifndef _GDFONTT_H_
#define _GDFONTT_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
This is a header file for gd font, generated using
bdftogd version 0.5 by Jan Pazdziora, adelton@fi.muni.cz
@ -17,5 +21,9 @@
extern gdFontPtr gdFontTiny;
#ifdef __cplusplus
}
#endif
#endif

552
src/gdkanji.c Normal file
View File

@ -0,0 +1,552 @@
/* gdkanji.c (Kanji code converter) */
/* written by Masahito Yamaga (yamaga@ipc.chiba-u.ac.jp) */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
#if defined(HAVE_ICONV_H) || defined(HAVE_ICONV)
#include <iconv.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#endif
#if defined(HAVE_ICONV_H) && !defined(HAVE_ICONV)
#define HAVE_ICONV 1
#endif
#define LIBNAME "any2eucjp()"
#if defined(__MSC__) || defined(__BORLANDC__) || defined(__TURBOC__) || defined(_Windows) || defined(MSDOS)
#ifndef SJISPRE
#define SJISPRE 1
#endif
#endif
#ifdef TRUE
#undef TRUE
#endif
#ifdef FALSE
#undef FALSE
#endif
#define TRUE 1
#define FALSE 0
#define NEW 1
#define OLD 2
#define ESCI 3
#define NEC 4
#define EUC 5
#define SJIS 6
#define EUCORSJIS 7
#define ASCII 8
#define NEWJISSTR "JIS7"
#define OLDJISSTR "jis"
#define EUCSTR "eucJP"
#define SJISSTR "SJIS"
#define ESC 27
#define SS2 142
#ifdef __STDC__
static void debug(const char *format, ...)
#else
static debug(format, ...)
char *format;
#endif
{
#ifdef DEBUG
#ifdef HAVE_STDARG_H
va_list args;
va_start(args, format);
fprintf(stdout, "%s: ", LIBNAME);
vfprintf(stdout, format, args);
fprintf(stdout, "\n");
va_end(args);
#endif
#endif
}
#ifdef __STDC__
static void error(const char *format, ...)
#else
static error(format, ...)
char *format;
#endif
{
#ifdef HAVE_STDARG_H
va_list args;
va_start(args, format);
fprintf(stderr, "%s: ", LIBNAME);
vfprintf(stderr, format, args);
fprintf(stderr, "\n");
va_end(args);
#endif
}
/* DetectKanjiCode() derived from DetectCodeType() by Ken Lunde. */
#ifdef __STDC__
static int DetectKanjiCode(unsigned char *str)
#else
static int DetectKanjiCode(str)
unsigned char *str;
#endif
{
static int whatcode;
int c, i;
char *lang = NULL;
c = '\1';
i = 0;
if (whatcode == 0) whatcode = ASCII;
while ((whatcode == EUCORSJIS || whatcode == ASCII) && c != '\0') {
if ((c = str[i++]) != '\0') {
if (c == ESC){
c = str[i++];
if (c == '$') {
c = str[i++];
if (c == 'B') whatcode = NEW;
else
if (c == '@') whatcode = OLD;
} else
if (c == '(') {
c = str[i++];
if (c == 'I') whatcode = ESCI;
} else
if (c == 'K') whatcode = NEC;
} else
if ((c >= 129 && c <= 141) || (c >= 143 && c <= 159))
whatcode = SJIS;
else
if (c == SS2) {
c = str[i++];
if ((c >= 64 && c <= 126) || (c >= 128 && c <= 160) || (c >= 224 && c <= 252))
whatcode = SJIS;
else
if (c >= 161 && c <= 223)
whatcode = EUCORSJIS;
} else
if (c >= 161 && c <= 223) {
c = str[i++];
if (c >= 240 && c <= 254) whatcode = EUC;
else
if (c >= 161 && c <= 223) whatcode = EUCORSJIS;
else
if (c >= 224 && c <= 239) {
whatcode = EUCORSJIS;
while (c >= 64 && c != '\0' && whatcode == EUCORSJIS) {
if (c >= 129) {
if (c <= 141 || (c >= 143 && c <= 159))
whatcode = SJIS;
else
if (c >= 253 && c <= 254)
whatcode = EUC;
}
c = str[i++];
}
} else
if (c <= 159) whatcode = SJIS;
} else
if (c >= 240 && c <= 254) whatcode = EUC;
else
if (c >= 224 && c <= 239) {
c = str[i++];
if ((c >= 64 && c <= 126) || (c >= 128 && c <= 160))
whatcode = SJIS;
else
if (c >= 253 && c >= 254) whatcode = EUC;
else
if (c >= 161 && c <= 252) whatcode = EUCORSJIS;
}
}
}
#ifdef DEBUG
if (whatcode == ASCII)
debug("Kanji code not included.");
else
if (whatcode == EUCORSJIS)
debug("Kanji code not detected.");
else
debug("Kanji code detected at %d byte.", i);
#endif
if (whatcode == EUCORSJIS) {
if (getenv ("LC_ALL")) lang = getenv ("LC_ALL");
else
if (getenv ("LC_CTYPE")) lang = getenv ("LC_CTYPE");
else
if (getenv ("LANG")) lang = getenv ("LANG");
if (lang) {
if (strcmp (lang, "ja_JP.SJIS") == 0 ||
#ifdef hpux
strcmp (lang, "japanese") == 0 ||
#endif
strcmp (lang, "ja_JP.mscode") == 0 ||
strcmp (lang, "ja_JP.PCK") == 0)
whatcode = SJIS;
else
if (strncmp (lang, "ja", 2) == 0)
#ifdef SJISPRE
whatcode = SJIS;
#else
whatcode = EUC;
#endif
}
}
if (whatcode == EUCORSJIS)
#ifdef SJISPRE
whatcode = SJIS;
#else
whatcode = EUC;
#endif
return whatcode;
}
/* SJIStoJIS() is sjis2jis() by Ken Lunde. */
#ifdef __STDC__
static void SJIStoJIS(int *p1, int *p2)
#else
static SJIStoJIS(p1, p2)
int *p1, *p2;
#endif
{
register unsigned char c1 = *p1;
register unsigned char c2 = *p2;
register int adjust = c2 < 159;
register int rowOffset = c1 < 160 ? 112 : 176;
register int cellOffset = adjust ? (31 + (c2 > 127)) : 126;
*p1 = ((c1 - rowOffset) << 1) - adjust;
*p2 -= cellOffset;
}
/* han2zen() was derived from han2zen() written by Ken Lunde. */
#define IS_DAKU(c) ((c >= 182 && c <= 196) || (c >= 202 && c <= 206) || (c == 179))
#define IS_HANDAKU(c) (c >= 202 && c <= 206)
#ifdef __STDC__
static void han2zen(int *p1, int *p2)
#else
static han2zen(p1, p2)
int *p1, *p2;
#endif
{
int c = *p1;
int daku = FALSE;
int handaku = FALSE;
int mtable[][2] = {
{129,66},{129,117},{129,118},{129,65},{129,69},
{131,146},
{131,64},{131,66},{131,68},{131,70},{131,72},
{131,131},{131,133},{131,135},
{131,98},{129,91},
{131,65},{131,67},{131,69},{131,71},{131,73},
{131,74},{131,76},{131,78},{131,80},{131,82},
{131,84},{131,86},{131,88},{131,90},{131,92},
{131,94},{131,96},{131,99},{131,101},{131,103},
{131,105},{131,106},{131,107},{131,108},{131,109},
{131,110},{131,113},{131,116},{131,119},{131,122},
{131,125},{131,126},{131,128},{131,129},{131,130},
{131,132},{131,134},{131,136},
{131,137},{131,138},{131,139},{131,140},{131,141},
{131,143},{131,147},
{129,74},{129,75}
};
if (*p2 == 222 && IS_DAKU(*p1)) daku = TRUE; /* Daku-ten */
else
if (*p2 == 223 && IS_HANDAKU(*p1)) handaku = TRUE; /* Han-daku-ten */
*p1 = mtable[c - 161][0];
*p2 = mtable[c - 161][1];
if (daku) {
if ((*p2 >= 74 && *p2 <= 103) || (*p2 >= 110 && *p2 <= 122))
(*p2)++;
else
if (*p2 == 131 && *p2 == 69) *p2 = 148;
} else
if (handaku && *p2 >= 110 && *p2 <= 122) (*p2) += 2;
}
#ifdef __STDC__
static void do_convert(unsigned char *to, unsigned char *from, const char *code)
#else
static do_convert(to, from, code)
unsigned char *to, *from;
char *code;
#endif
{
#ifdef HAVE_ICONV
iconv_t cd;
size_t from_len, to_len;
if ((cd = iconv_open(EUCSTR, code)) == (iconv_t)-1) {
error("iconv_open() error");
#ifdef HAVE_ERRNO_H
if (errno == EINVAL)
error("invalid code specification: \"%s\" or \"%s\"",
EUCSTR, code);
#endif
strcpy(to, from);
return;
}
from_len = strlen((const char *)from) +1;
to_len = BUFSIZ;
if (iconv(cd, (const char **)&from, &from_len,
(char **)&to, &to_len) == -1) {
#ifdef HAVE_ERRNO_H
if (errno == EINVAL) error("invalid end of input string");
else
if (errno == EILSEQ) error("invalid code in input string");
else
if (errno == E2BIG) error("output buffer overflow at do_convert()");
else
#endif
error("something happen");
strcpy(to, from);
return;
}
if (iconv_close(cd) != 0) {
error("iconv_close() error");
}
#else
int p1, p2, i, j;
int jisx0208 = FALSE;
int hankaku = FALSE;
j = 0;
if (strcmp(code, NEWJISSTR) == 0 || strcmp(code, OLDJISSTR) == 0){
for(i=0; from[i] != '\0' && j < BUFSIZ; i++){
if (from[i] == ESC) {
i++;
if (from[i] == '$') {
jisx0208 = TRUE;
hankaku = FALSE;
i++;
}else
if (from[i] == '(') {
jisx0208 = FALSE;
i++;
if (from[i] == 'I') /* Hankaku Kana */
hankaku = TRUE;
else
hankaku = FALSE;
}
} else {
if (jisx0208)
to[j++] = from[i] + 128;
else
if (hankaku) {
to[j++] = SS2;
to[j++] = from[i] + 128;
}
else
to[j++] = from[i];
}
}
} else
if (strcmp(code, SJISSTR) == 0) {
for(i=0; from[i] != '\0' && j < BUFSIZ; i++){
p1 = from[i];
if (p1 < 127) to[j++] = p1;
else
if ((p1 >= 161) && (p1 <= 223)) { /* Hankaku Kana */
to[j++] = SS2;
to[j++] = p1;
} else {
p2 = from[++i];
SJIStoJIS(&p1, &p2);
to[j++] = p1 + 128;
to[j++] = p2 + 128;
}
}
} else {
error("invalid code specification: \"%s\"", code);
return;
}
if (j >= BUFSIZ) {
error("output buffer overflow at do_convert()");
strcpy(to, from);
} else
to[j] = '\0';
#endif /* HAVE_ICONV */
}
#ifdef __STDC__
static int do_check_and_conv(unsigned char *to, unsigned char *from)
#else
static int do_check_and_conv(to, from)
unsigned char *to, *from;
#endif
{
static unsigned char tmp[BUFSIZ];
int p1, p2, i, j;
int kanji = TRUE;
switch (DetectKanjiCode(from)){
case NEW:
debug("Kanji code is New JIS.");
do_convert(tmp, from, NEWJISSTR);
break;
case OLD:
debug("Kanji code is Old JIS.");
do_convert(tmp, from, OLDJISSTR);
break;
case ESCI:
debug("This string includes Hankaku-Kana (jisx0201) escape sequence [ESC] + ( + I.");
do_convert(tmp, from, NEWJISSTR);
break;
case NEC:
debug("Kanji code is NEC Kanji.");
error("cannot convert NEC Kanji.");
strcpy(tmp, from);
kanji = FALSE;
break;
case EUC:
debug("Kanji code is EUC.");
strcpy(tmp, from);
break;
case SJIS:
debug("Kanji code is SJIS.");
do_convert(tmp, from, SJISSTR);
break;
case EUCORSJIS:
debug("Kanji code is EUC or SJIS.");
strcpy(tmp, from);
kanji = FALSE;
break;
case ASCII:
debug("This is ASCII string.");
strcpy(tmp, from);
kanji = FALSE;
break;
default:
debug("This string includes unknown code.");
strcpy(tmp, from);
kanji = FALSE;
break;
}
/* Hankaku Kana ---> Zenkaku Kana */
if (kanji) {
j = 0;
for(i = 0; tmp[i] != '\0'&& j < BUFSIZ; i++) {
if (tmp[i] == SS2) {
p1 = tmp[++i];
if (tmp[i+1] == SS2) {
p2 = tmp[i+2];
if (p2 == 222 || p2 == 223) i += 2;
else p2 = 0;
} else p2 = 0;
han2zen(&p1, &p2);
SJIStoJIS(&p1, &p2);
to[j++] = p1 + 128;
to[j++] = p2 + 128;
} else
to[j++] = tmp[i];
}
if (j >= BUFSIZ) {
error("output buffer overflow at Hankaku --> Zenkaku");
strcpy(to, tmp);
} else
to[j] = '\0';
} else
strcpy(to, tmp);
return kanji;
}
#ifdef __STDC__
int any2eucjp(unsigned char *dest, unsigned char *src, unsigned int dest_max)
#else
int any2eucjp(dest, src, dest_max)
unsigned char *dest, *src;
unsigned int dest_max;
#endif
{
static unsigned char tmp_dest[BUFSIZ];
int ret;
if (strlen((const char *)src) >= BUFSIZ) {
error("input string too large");
return -1;
}
if (dest_max > BUFSIZ) {
error("invalid maximum size of destination\nit should be less than %d.", BUFSIZ);
return -1;
}
ret = do_check_and_conv(tmp_dest, src);
if (strlen((const char *)tmp_dest) >= dest_max) {
error("output buffer overflow");
strcpy(dest, src);
return -1;
}
strcpy(dest, tmp_dest);
return ret;
}
#if 0
#ifdef __STDC__
unsigned int strwidth(unsigned char *s)
#else
unsigned int strwidth(s)
unsigned char *s;
#endif
{
unsigned char *t;
unsigned int i;
t = (unsigned char *)malloc(BUFSIZ);
any2eucjp(t, s, BUFSIZ);
i = strlen(t);
free(t);
return i;
}
#endif
#ifdef DEBUG
int main()
{
unsigned char input[BUFSIZ];
unsigned char *output;
unsigned char *str;
int c, i = 0;
while ( (c = fgetc(stdin)) != '\n' && i < BUFSIZ ) input[i++] = c;
input[i] = '\0';
printf("input : %d bytes\n", strlen(input));
printf("output: %d bytes\n", strwidth(input));
output = (unsigned char *)malloc(BUFSIZ);
any2eucjp(output, input, BUFSIZ);
str = output;
while(*str != '\0') putchar(*(str++));
putchar('\n');
free(output);
return 0;
}
#endif

725
src/gdtables.c Normal file
View File

@ -0,0 +1,725 @@
int gdCosT[] = {
1024,
1023,
1023,
1022,
1021,
1020,
1018,
1016,
1014,
1011,
1008,
1005,
1001,
997,
993,
989,
984,
979,
973,
968,
962,
955,
949,
942,
935,
928,
920,
912,
904,
895,
886,
877,
868,
858,
848,
838,
828,
817,
806,
795,
784,
772,
760,
748,
736,
724,
711,
698,
685,
671,
658,
644,
630,
616,
601,
587,
572,
557,
542,
527,
512,
496,
480,
464,
448,
432,
416,
400,
383,
366,
350,
333,
316,
299,
282,
265,
247,
230,
212,
195,
177,
160,
142,
124,
107,
89,
71,
53,
35,
17,
0,
-17,
-35,
-53,
-71,
-89,
-107,
-124,
-142,
-160,
-177,
-195,
-212,
-230,
-247,
-265,
-282,
-299,
-316,
-333,
-350,
-366,
-383,
-400,
-416,
-432,
-448,
-464,
-480,
-496,
-512,
-527,
-542,
-557,
-572,
-587,
-601,
-616,
-630,
-644,
-658,
-671,
-685,
-698,
-711,
-724,
-736,
-748,
-760,
-772,
-784,
-795,
-806,
-817,
-828,
-838,
-848,
-858,
-868,
-877,
-886,
-895,
-904,
-912,
-920,
-928,
-935,
-942,
-949,
-955,
-962,
-968,
-973,
-979,
-984,
-989,
-993,
-997,
-1001,
-1005,
-1008,
-1011,
-1014,
-1016,
-1018,
-1020,
-1021,
-1022,
-1023,
-1023,
-1024,
-1023,
-1023,
-1022,
-1021,
-1020,
-1018,
-1016,
-1014,
-1011,
-1008,
-1005,
-1001,
-997,
-993,
-989,
-984,
-979,
-973,
-968,
-962,
-955,
-949,
-942,
-935,
-928,
-920,
-912,
-904,
-895,
-886,
-877,
-868,
-858,
-848,
-838,
-828,
-817,
-806,
-795,
-784,
-772,
-760,
-748,
-736,
-724,
-711,
-698,
-685,
-671,
-658,
-644,
-630,
-616,
-601,
-587,
-572,
-557,
-542,
-527,
-512,
-496,
-480,
-464,
-448,
-432,
-416,
-400,
-383,
-366,
-350,
-333,
-316,
-299,
-282,
-265,
-247,
-230,
-212,
-195,
-177,
-160,
-142,
-124,
-107,
-89,
-71,
-53,
-35,
-17,
0,
17,
35,
53,
71,
89,
107,
124,
142,
160,
177,
195,
212,
230,
247,
265,
282,
299,
316,
333,
350,
366,
383,
400,
416,
432,
448,
464,
480,
496,
512,
527,
542,
557,
572,
587,
601,
616,
630,
644,
658,
671,
685,
698,
711,
724,
736,
748,
760,
772,
784,
795,
806,
817,
828,
838,
848,
858,
868,
877,
886,
895,
904,
912,
920,
928,
935,
942,
949,
955,
962,
968,
973,
979,
984,
989,
993,
997,
1001,
1005,
1008,
1011,
1014,
1016,
1018,
1020,
1021,
1022,
1023,
1023
};
int gdSinT[] = {
0,
17,
35,
53,
71,
89,
107,
124,
142,
160,
177,
195,
212,
230,
247,
265,
282,
299,
316,
333,
350,
366,
383,
400,
416,
432,
448,
464,
480,
496,
512,
527,
542,
557,
572,
587,
601,
616,
630,
644,
658,
671,
685,
698,
711,
724,
736,
748,
760,
772,
784,
795,
806,
817,
828,
838,
848,
858,
868,
877,
886,
895,
904,
912,
920,
928,
935,
942,
949,
955,
962,
968,
973,
979,
984,
989,
993,
997,
1001,
1005,
1008,
1011,
1014,
1016,
1018,
1020,
1021,
1022,
1023,
1023,
1024,
1023,
1023,
1022,
1021,
1020,
1018,
1016,
1014,
1011,
1008,
1005,
1001,
997,
993,
989,
984,
979,
973,
968,
962,
955,
949,
942,
935,
928,
920,
912,
904,
895,
886,
877,
868,
858,
848,
838,
828,
817,
806,
795,
784,
772,
760,
748,
736,
724,
711,
698,
685,
671,
658,
644,
630,
616,
601,
587,
572,
557,
542,
527,
512,
496,
480,
464,
448,
432,
416,
400,
383,
366,
350,
333,
316,
299,
282,
265,
247,
230,
212,
195,
177,
160,
142,
124,
107,
89,
71,
53,
35,
17,
0,
-17,
-35,
-53,
-71,
-89,
-107,
-124,
-142,
-160,
-177,
-195,
-212,
-230,
-247,
-265,
-282,
-299,
-316,
-333,
-350,
-366,
-383,
-400,
-416,
-432,
-448,
-464,
-480,
-496,
-512,
-527,
-542,
-557,
-572,
-587,
-601,
-616,
-630,
-644,
-658,
-671,
-685,
-698,
-711,
-724,
-736,
-748,
-760,
-772,
-784,
-795,
-806,
-817,
-828,
-838,
-848,
-858,
-868,
-877,
-886,
-895,
-904,
-912,
-920,
-928,
-935,
-942,
-949,
-955,
-962,
-968,
-973,
-979,
-984,
-989,
-993,
-997,
-1001,
-1005,
-1008,
-1011,
-1014,
-1016,
-1018,
-1020,
-1021,
-1022,
-1023,
-1023,
-1024,
-1023,
-1023,
-1022,
-1021,
-1020,
-1018,
-1016,
-1014,
-1011,
-1008,
-1005,
-1001,
-997,
-993,
-989,
-984,
-979,
-973,
-968,
-962,
-955,
-949,
-942,
-935,
-928,
-920,
-912,
-904,
-895,
-886,
-877,
-868,
-858,
-848,
-838,
-828,
-817,
-806,
-795,
-784,
-772,
-760,
-748,
-736,
-724,
-711,
-698,
-685,
-671,
-658,
-644,
-630,
-616,
-601,
-587,
-572,
-557,
-542,
-527,
-512,
-496,
-480,
-464,
-448,
-432,
-416,
-400,
-383,
-366,
-350,
-333,
-316,
-299,
-282,
-265,
-247,
-230,
-212,
-195,
-177,
-160,
-142,
-124,
-107,
-89,
-71,
-53,
-35,
-17
};

View File

@ -1,8 +1,31 @@
#include "gd.h"
#include <string.h>
#define PI 3.141592
#define DEG2RAD(x) ((x)*PI/180.)
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX4(x,y,z,w) \
((MAX((x),(y))) > (MAX((z),(w))) ? (MAX((x),(y))) : (MAX((z),(w))))
#define MIN4(x,y,z,w) \
((MIN((x),(y))) < (MIN((z),(w))) ? (MIN((x),(y))) : (MIN((z),(w))))
#define MAXX(x) MAX4(x[0],x[2],x[4],x[6])
#define MINX(x) MIN4(x[0],x[2],x[4],x[6])
#define MAXY(x) MAX4(x[1],x[3],x[5],x[7])
#define MINY(x) MIN4(x[1],x[3],x[5],x[7])
int main(int argc, char *argv[])
{
#ifndef HAVE_TTF
fprintf(stderr, "gd was not compiled with HAVE_TTF defined.\n");
fprintf(stderr, "Install the FreeType library, including the\n");
fprintf(stderr, "header files. Then edit the gd Makefile, type\n");
fprintf(stderr, "make clean, and type make again.\n");
return 1;
#else
gdImagePtr im;
int black;
int white;
@ -10,17 +33,27 @@ int main(int argc, char *argv[])
int x, y;
char *err;
#ifdef JISX0208
char *s = "Hello. ‚±‚ñ‚É‚¿‚Í Qyjpqg,"; /* String to draw. */
#else
char *s = "Hello. Qyjpqg,"; /* String to draw. */
#endif
double sz = 40.;
char *f = "/usr/local/share/ttf/times.ttf"; /* TrueType font */
double angle = DEG2RAD(-90);
#ifdef JISX0208
char *f = "/usr/openwin/lib/locale/ja/X11/fonts/TT/HG-MinchoL.ttf"; /* UNICODE */
/* char *f = "/usr/local/lib/fonts/truetype/DynaFont/dfpop1.ttf"; */ /* SJIS */
#else
char *f = "/usr/local/lib/fonts/truetype/misc/times.ttf"; /* TrueType font */
#endif
/* obtain brect so that we can size the image */
err = gdImageStringTTF((gdImagePtr)NULL,&brect[0],0,f,sz,0.,0,0,s);
err = gdImageStringTTF((gdImagePtr)NULL,&brect[0],0,f,sz,angle,0,0,s);
if (err) {fprintf(stderr,err); return 1;}
/* create an image just big enough for the string */
x = brect[2]-brect[6] + 6;
y = brect[3]-brect[7] + 6;
x = MAXX(brect) - MINX(brect) + 6;
y = MAXY(brect) - MINY(brect) + 6;
im = gdImageCreate(x,y);
/* Background color (first allocated) */
@ -28,9 +61,9 @@ int main(int argc, char *argv[])
black = gdImageColorResolve(im, 0, 0, 0);
/* render the string, offset origin to center string*/
x = 0-brect[6] + 3;
y = 0-brect[7] + 3;
err = gdImageStringTTF(im,&brect[0],black,f,sz,0.0,x,y,s);
x = 0 - MINX(brect) + 3;
y = 0 - MINY(brect) + 3;
err = gdImageStringTTF(im,&brect[0],black,f,sz,angle,x,y,s);
if (err) {fprintf(stderr,err); return 1;}
/* Write img to stdout */
@ -40,4 +73,5 @@ int main(int argc, char *argv[])
gdImageDestroy(im);
return 0;
#endif /* HAVE_TTF */
}

View File

@ -65,8 +65,8 @@ typedef struct {
TT_Face face;
TT_Face_Properties properties;
TT_Instance instance;
TT_CharMap char_map_Unicode, char_map_Big5, char_map_Roman;
int have_char_map_Unicode, have_char_map_Big5, have_char_map_Roman;
TT_CharMap char_map_Unicode, char_map_Big5, char_map_Sjis, char_map_Roman;
int have_char_map_Unicode, have_char_map_Big5, have_char_map_Sjis, have_char_map_Roman;
TT_Matrix matrix;
TT_Instance_Metrics imetrics;
gdCache_head_t *glyphCache;
@ -176,6 +176,10 @@ static void bitmapRelease( void *element );
*
*---------------------------------------------------------------------------
*/
#ifdef JISX0208
#include "jisx0208.h"
#endif
#define Tcl_UniChar int
#define TCL_UTF_MAX 3
@ -213,6 +217,22 @@ gdTcl_UtfToUniChar(char *str, Tcl_UniChar *chPtr)
*/
byte = *((unsigned char *) str);
#ifdef JISX0208
if (0xA1 <= byte && byte <= 0xFE) {
int jiscode, ku, ten;
jiscode = 0x100 * (byte & 0x7F) + (str[1] & 0x7F);
ku = (jiscode >> 8) - 0x20;
ten = (jiscode % 256) - 0x20;
if ( (ku < 1 || ku > 92) || (ten < 1 || ten > 94) ) {
*chPtr = (Tcl_UniChar) byte;
return 1;
}
*chPtr = (Tcl_UniChar) UnicodeTbl[ku - 1][ten - 1];
return 2;
} else
#endif /* JISX0208 */
if (byte < 0xC0) {
/*
* Handles properly formed UTF-8 characters between 0x01 and 0x7F.
@ -353,10 +373,14 @@ fontFetch ( char **error, void *key )
map_found = 0;
a->have_char_map_Unicode = 0;
a->have_char_map_Big5 = 0;
a->have_char_map_Sjis = 0;
a->have_char_map_Roman = 0;
for (i = 0; i < n; i++) {
TT_Get_CharMap_ID(a->face, i, &platform, &encoding);
if ((platform == 3 && encoding == 1) /* Windows Unicode */
|| (platform == 3 && encoding == 0) /* Windows
Symbol */
|| (platform == 2 && encoding == 1) /* ISO Unicode */
|| (platform == 0)) { /* Apple Unicode */
TT_Get_CharMap(a->face, i, &a->char_map_Unicode);
@ -366,6 +390,10 @@ fontFetch ( char **error, void *key )
TT_Get_CharMap(a->face, i, &a->char_map_Big5);
a->have_char_map_Big5 = 1;
map_found++;
} else if (platform == 3 && encoding == 2) { /* Windows Sjis */
TT_Get_CharMap(a->face, i, &a->char_map_Sjis);
a->have_char_map_Sjis = 1;
map_found++;
} else if ((platform == 1 && encoding == 0) /* Apple Roman */
|| (platform == 2 && encoding == 0)) { /* ISO ASCII */
TT_Get_CharMap(a->face, i, &a->char_map_Roman);
@ -447,6 +475,8 @@ glyphFetch ( char **error, void *key )
glyph_code = TT_Char_Index(b->font->char_map_Roman, a->character);
} else if ( b->font->have_char_map_Big5) {
glyph_code = TT_Char_Index(b->font->char_map_Big5, a->character);
} else if ( b->font->have_char_map_Sjis) {
glyph_code = TT_Char_Index(b->font->char_map_Sjis, a->character);
}
if ((err=TT_Load_Glyph(b->font->instance, a->glyph, glyph_code, flags))) {
*error = "TT_Load_Glyph problem";
@ -642,6 +672,30 @@ gdttfchar(gdImage *im, int fg, font_t *font,
if (font->have_char_map_Unicode) { /* use UTF-8 mapping from ASCII */
len = gdTcl_UtfToUniChar(*next, &ch);
*next += len;
} else
if (font->have_char_map_Sjis) {
unsigned char c;
int jiscode;
c = (unsigned char)(**next);
if ( 0xA1 <= c && c <= 0xFE ) {
(*next)++;
jiscode = 0x100 * ((c)&0x7F) + ((**next)&0x7F);
ch = (jiscode >> 8) & 0xFF;
jiscode &= 0xFF;
if (ch & 1) jiscode += 0x40 - 0x21;
else jiscode += 0x9E - 0x21;
if (jiscode >= 0x7F) jiscode++;
ch = (ch - 0x21) / 2 + 0x81;
if (ch >= 0xA0) ch += 0x40;
ch = (ch << 8) + jiscode;
} else
ch = (**next) & 255; /* don't extend sign */
(*next)++;
} else {
/*
* Big 5 mapping:
@ -713,6 +767,8 @@ gdttfchar(gdImage *im, int fg, font_t *font,
return (char *)NULL;
}
extern int any2eucjp(unsigned char *, unsigned char *, unsigned int);
/********************************************************************/
/* gdImageStringTTF - render a utf8 string onto a gd image */
@ -727,6 +783,7 @@ char * gdImageStringTTF(gdImage *im, int *brect, int fg, char *fontname,
font_t *font;
fontkey_t fontkey;
char *error, *next;
char *tmpstr;
/****** initialize font engine on first call ************/
static gdCache_head_t *fontCache;
@ -755,7 +812,18 @@ char * gdImageStringTTF(gdImage *im, int *brect, int fg, char *fontname,
advance_x = advance_y = 0;
#ifndef JISX0208
if (font->have_char_map_Sjis) {
#endif
if (tmpstr = (unsigned char *)malloc(BUFSIZ)) {
any2eucjp(tmpstr, string, BUFSIZ);
next=tmpstr;
} else
next=string;
#ifndef JISX0208
} else
next=string;
#endif
while (*next) {
ch = *next;
@ -813,6 +881,7 @@ char * gdImageStringTTF(gdImage *im, int *brect, int fg, char *fontname,
i++;
}
if ( tmpstr ) free(tmpstr);
return (char *)NULL;
}

144
src/gdxpm.c Normal file
View File

@ -0,0 +1,144 @@
/*
add ability to load xpm files to gd, requires the xpm
library.
Caolan.McNamara@ul.ie
http://www.csn.ul.ie/~caolan
*/
#include <stdio.h>
#include <stdlib.h>
#include "gd.h"
#ifndef HAVE_XPM
gdImagePtr gdImageCreateFromXpm(char *filename)
{
fprintf(stderr,"libgd was not built with xpm support\n");
return(NULL);
}
#else
#include "xpm.h"
gdImagePtr gdImageCreateFromXpm(char *filename)
{
XpmInfo info;
XpmImage image;
int i,j,k,number;
char buf[5];
gdImagePtr im = 0;
char *apixel;
int *pointer;
int red=0,green=0,blue=0,color=0;
int *colors;
int ret;
ret = XpmReadFileToXpmImage(filename,&image,&info);
if (ret != XpmSuccess)
return 0;
if (!(im = gdImageCreate(image.width, image.height)))
return 0;
number = image.ncolors;
colors = (int*)malloc(sizeof(int) * number);
if (colors == NULL)
return(0);
for (i = 0; i < number; i++)
{
switch(strlen(image.colorTable[i].c_color))
{
case 4:
buf[1] = '\0';
buf[0] = image.colorTable[i].c_color[1];
red = strtol(buf,NULL,16);
buf[0] = image.colorTable[i].c_color[3];
green = strtol(buf,NULL,16);
buf[0] = image.colorTable[i].c_color[5];
blue = strtol(buf,NULL,16);
break;
case 7:
buf[2] = '\0';
buf[0] = image.colorTable[i].c_color[1];
buf[1] = image.colorTable[i].c_color[2];
red = strtol(buf,NULL,16);
buf[0] = image.colorTable[i].c_color[3];
buf[1] = image.colorTable[i].c_color[4];
green = strtol(buf,NULL,16);
buf[0] = image.colorTable[i].c_color[5];
buf[1] = image.colorTable[i].c_color[6];
blue = strtol(buf,NULL,16);
break;
case 10:
buf[3] = '\0';
buf[0] = image.colorTable[i].c_color[1];
buf[1] = image.colorTable[i].c_color[2];
buf[2] = image.colorTable[i].c_color[3];
red = strtol(buf,NULL,16);
red /= 64;
buf[0] = image.colorTable[i].c_color[4];
buf[1] = image.colorTable[i].c_color[5];
buf[2] = image.colorTable[i].c_color[6];
green = strtol(buf,NULL,16);
green /= 64;
buf[0] = image.colorTable[i].c_color[7];
buf[1] = image.colorTable[i].c_color[8];
buf[2] = image.colorTable[i].c_color[9];
blue = strtol(buf,NULL,16);
blue /= 64;
break;
case 13:
buf[4] = '\0';
buf[0] = image.colorTable[i].c_color[1];
buf[1] = image.colorTable[i].c_color[2];
buf[2] = image.colorTable[i].c_color[3];
buf[3] = image.colorTable[i].c_color[4];
red = strtol(buf,NULL,16);
red /= 256;
buf[0] = image.colorTable[i].c_color[5];
buf[1] = image.colorTable[i].c_color[6];
buf[2] = image.colorTable[i].c_color[7];
buf[3] = image.colorTable[i].c_color[8];
green = strtol(buf,NULL,16);
green /= 256;
buf[0] = image.colorTable[i].c_color[9];
buf[1] = image.colorTable[i].c_color[10];
buf[2] = image.colorTable[i].c_color[11];
buf[3] = image.colorTable[i].c_color[12];
blue = strtol(buf,NULL,16);
blue /= 256;
break;
}
colors[i] = gdImageColorResolve(im,red,green,blue);
if (colors[i] == -1)
fprintf(stderr,"ARRRGH\n");
}
apixel = (char *)malloc(image.cpp+1);
if (apixel == NULL)
return(0);
apixel[image.cpp] = '\0';
pointer = image.data;
for(i=0;i<image.height;i++)
{
for(j=0;j<image.width;j++)
{
k = *pointer++;
gdImageSetPixel(im,j,i,colors[k]);
}
}
free(apixel);
free(colors);
return(im);
}
#endif

View File

@ -1,16 +1,16 @@
<HTML>
<HEAD>
<TITLE>gd 1.6.3</TITLE>
<TITLE>gd 1.7.0</TITLE>
</HEAD>
<BODY>
<H1>gd 1.6.3</H1>
<H1>gd 1.7.0</H1>
<H2>A graphics library for fast image creation</H2>
<H2>Follow this link to the
<A HREF="http://www.boutell.com/gd/">latest version
of this document</A>.</H2>
<blockquote>
<strong>HEY! READ THIS!</strong>
gd 1.6.3 creates PNG images, not GIF images. This is a good thing.
gd 1.7.0 creates PNG images, not GIF images. This is a good thing.
PNG is a more compact format, and full compression is available.
Existing code will need modification to call gdImagePng instead
of gdImageGif. <strong>Please do not ask us to send you the old GIF
@ -19,13 +19,24 @@ algorithm, which is used in fully compressed GIF images. We are
still investigating the legal issues surrounding various
alternative means of producing a valid GIF file.
<p>
gd 1.6.3 <strong>requires</strong> that the following libraries
gd 1.7.0 <strong>requires</strong> that the following libraries
also be installed:
<p>
libpng
<p>
zlib
<p>
If you want to use the TrueType font support, you must also
install the <strong>Freetype library</strong>, including
the <strong><code>freetype.h</code> header file</strong>.
See the <a href="http://www.freetype.org/">Freetype Home Page</a>.
No, I cannot explain why that site is down on a particular day,
and no, I can't send you a copy.
<p>
If you want to use the Xpm color bitmap loading support, you must also
have the X Window System and the Xpm library installed (Xpm is often
included in modern X distributions).
<p>
Please read the documentation and install the required libraries.
Do not send email asking why <code>png.h</code> is not found.
See the <a href="#required">requirements section</a> for more
@ -34,6 +45,7 @@ information. Thank you!
<H3>Table of Contents</H3>
<UL>
<LI><A HREF="#notice">Credits and license terms</A>
<LI><A HREF="#whatsnew1.7">What's new in version 1.7?</A>
<LI><A HREF="#whatsnew1.6.3">What's new in version 1.6.3?</A>
<LI><A HREF="#whatsnew1.6.2">What's new in version 1.6.2?</A>
<LI><A HREF="#whatsnew1.6.1">What's new in version 1.6.1?</A>
@ -95,7 +107,7 @@ including but not limited to implied warranties of merchantability and
fitness for a particular purpose, with respect to this code and accompanying
documentation.
<p>
Although their code does not appear in gd 1.6.3, the authors wish to
Although their code does not appear in gd 1.7.0, the authors wish to
thank David Koblas, David Rowley, and Hutchison Avenue Software
Corporation for their prior contributions.
</blockquote>
@ -118,9 +130,9 @@ in the wrong place.
<P>
gd does not provide for every possible desirable graphics
operation. It is not necessary or desirable for gd to become
a kitchen-sink graphics package, but version 1.6.3 incorporates
a kitchen-sink graphics package, but version 1.7.0 incorporates
most of the commonly requested features for an 8-bit 2D package.
Support for scalable fonts, and truecolor images, JPEG and
Support for truecolor images, JPEG and
truecolor PNG is planned for version 2.0.
<P>
<A NAME="gdother"><H3>What if I want to use another programming
@ -130,23 +142,54 @@ gd can also be used from Perl, courtesy of
Lincoln Stein's
<a href="http://www-genome.wi.mit.edu/ftp/pub/software/WWW/GD.html">
GD.pm</a> library, which uses gd as the basis for a set of
Perl 5.x classes. Not yet updated for gd 1.6.3.
Perl 5.x classes. Updated to gd 1.6 and up.
<h4>Tcl</h4>
gd can be used from Tcl with John Ellson's
<a href=http://www.tcltk.com/ftp/ellson/>Gdtclft</a>
dynamically loaded extension package.
(Gdtclft2.0 or later is needed for gd-1.6.3 with PNG output.)
(Gdtclft2.0 or later is needed for gd-1.6 and up with PNG output.)
<h4>Any Language</h4>
There are, at the moment, at least three simple interpreters that
perform gd operations. You can output the desired commands to a simple
text file from whatever scripting language you prefer to use, then
invoke the interpreter.
<p>
These packages have not been updated to gd 1.6.3 as of this writing.
These packages have not been updated to gd 1.6 and up as of this writing.
<ul>
<li><a href="http://s27w007.pswfs.gov/tgd/">tgd</a>, by Bradley K. Sherman
<li><a href="http://www.unimelb.edu.au/fly/fly.html">fly</a>, by Martin Gleeson
</ul>
<P><A NAME="whatsnew1.7"><H3>What's new in version 1.7?</H3></A>
Version 1.7 contains the following changes:
<ul>
<li>Japanese language support for the TrueType functions.
Thanks to Masahito Yamaga.
<li><code>autoconf</code> and <code>configure</code> have been removed, in favor of a
carefully designed Makefile which produces and properly installs
the library and the binaries. System-dependent variables are
at the top of the Makefile for easy modification. I'm sorry,
folks, but autoconf generated <strong>many, many confused email
messages</strong> from people who didn't have things where autoconf
expected to find them. I am not an autoconf/automake wizard, and
gd is a simple, very compact library which does not need to
be a shared library. I <strong>did</strong> make many improvements
over the old gd 1.3 Makefile, which were directly inspired by the
autoconf version found in the 1.6 series (thanks to John Ellson).
<li>Completely ANSI C compliant, according to the <code>-pedantic-errors</code>
flag of gcc. Several pieces of not-quite-ANSI-C code were causing problems
for those with non-gcc compilers.
<li><code>gdttf.c</code> patched to allow the use of Windows symbol
fonts, when present (thanks to Joseph Peppin).
<li><code>extern "C"</code> wrappers added to <code>gd.h</code> and the
font header files for the convenience of C++ programmers.
<code>bdftogd</code> was also modified to automatically insert these
wrappers into future font header files. Thanks to John Lindal.
<li>Compiles correctly on platforms that don't define <code>SEEK_SET</code>.
Thanks to Robert Bonomi.
<li>Loads Xpm images via the
<a href="#gdImageCreateFromXpm"><code>gdImageCreateFromXpm</code></a>
function, if the Xpm library is available. Thanks to Caolan McNamara.
</ul>
<P><A NAME="whatsnew1.6.3"><H3>What's new in version 1.6.3?</H3></A>
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
@ -339,13 +382,13 @@ newsgroups relevant to your particular system.
<A NAME="getgd"><H3>How do I get gd?</H3></A>
<h4>By HTTP</h4>
<ul>
<li><a href="http://www.boutell.com/gd/http/gd-1.6.3.tar.gz">Gzipped Tar File (Unix)</a>
<li><a href="http://www.boutell.com/gd/http/gd163.zip">.ZIP File (Windows)</a>
<li><a href="http://www.boutell.com/gd/http/gd-1.7.0.tar.gz">Gzipped Tar File (Unix)</a>
<li><a href="http://www.boutell.com/gd/http/gd-1.7.0.zip">.ZIP File (Windows)</a>
</ul>
<h4>By FTP</h4>
<ul>
<li><a href="ftp://ftp.boutell.com/pub/boutell/gd/gd-1.6.3.tar.gz">Gzipped Tar File (Unix)</a>
<li><a href="ftp://ftp.boutell.com/pub/boutell/gd/gd163.zip">.ZIP File (Windows)</a>
<li><a href="ftp://ftp.boutell.com/pub/boutell/gd/gd-1.7.0.tar.gz">Gzipped Tar File (Unix)</a>
<li><a href="ftp://ftp.boutell.com/pub/boutell/gd/gd-1.7.0.zip">.ZIP File (Windows)</a>
</ul>
<P>
<A NAME="buildgd"><H3>How do I build gd?</H3></A>
@ -356,13 +399,18 @@ downloaded. If you are not familiar with <code>tar</code> and
consult with an experienced user of your system. Sorry, we cannot
answer questions about basic Internet skills.
<p>
Unpacking the archive will produce a directory called "gd-1.6.3".
Unpacking the archive will produce a directory called "gd-1.7.0".
<p>
<h4>For Unix</h4>
<code>cd</code> to the gd-1.6.3 directory and type "./configure",
followed by "make". If you are the system administrator, and you
<code>cd</code> to the 1.7.0 directory. Edit the Makefile with
your preferred text editor and make any necessary changes to the
settings at the top, especially if you want Xpm or TrueType support.
Next, type "make". If you are the system administrator, and you
wish to make the gd library available to other programs, you may
also wish to type "make install".
<p>
If you get errors, edit the Makefile again, paying special attention
to the INCLUDEDIRS and LIBDIRS settings.
<h4>For Windows, Mac, Et Cetera</h4>
Create a project using your favorite programming environment.
Copy all of the gd files to the project directory. Add <code>gd.c</code>
@ -782,6 +830,31 @@ fclose(in);
/* ... Use the image ... */
<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
</PRE>
<DT><A NAME="gdImageCreateFromXpm">gdImageCreateFromXpm(FILE *in)</A>
<strong>(FUNCTION)</strong>
<DD>
gdImageCreateFromXbm is called to load images from XPM X Window System
color bitmap format files. This function is available only if HAVE_XPM
is selected in the Makefile and the Xpm library is linked with the
application. Invoke gdImageCreateFromXpm with an already opened pointer
to a file containing the desired image.
gdImageCreateFromXpm
returns a <A HREF="#gdImagePtr">gdImagePtr</A> to the new image, or NULL
if unable to load the image (most often because the file is corrupt or
does not contain an XPM bitmap format image). gdImageCreateFromXpm does
<em>not</em> close the file. You can inspect the sx and sy members of the
image to determine its size. The image must eventually be destroyed
using <A HREF="#gdImageDestroy">gdImageDestroy()</A>.
<PRE>
... inside a function ...
<A HREF="#gdImagePtr">gdImagePtr</A> im;
FILE *in;
in = fopen("myxpm.xpm", "rb");
im = gdImageCreateFromXpm(in);
fclose(in);
/* ... Use the image ... */
<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
</PRE>
<DT><A NAME="gdImageDestroy">gdImageDestroy(gdImagePtr im)</A> <STRONG>(FUNCTION)</STRONG>
<DD>gdImageDestroy is used to free the memory associated with
an image. It is important to invoke gdImageDestroy before
@ -2569,6 +2642,7 @@ Be sure to read this manual carefully first.
<A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A> |
<A HREF="#gdImageCreateFromPngSource">gdImageCreateFromPngSource</A> |
<A HREF="#gdImageCreateFromXbm">gdImageCreateFromXbm</A> |
<A HREF="#gdImageCreateFromXpm">gdImageCreateFromXpm</A> |
<A HREF="#gdImageDashedLine">gdImageDashedLine</A> |
<A HREF="#gdImageDestroy">gdImageDestroy</A> |
<A HREF="#gdImageFill">gdImageFill</A> |

1205
src/jisx0208.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,44 @@
A MUCH BETTER MANUAL IS IN THE HYPERTEXT DOCUMENT index.html!
A MUCH BETTER MANUAL IS IN THE HYPERTEXT DOCUMENT index.html!
A MUCH BETTER MANUAL IS IN THE HYPERTEXT DOCUMENT index.html!
A MUCH BETTER MANUAL IS IN THE HYPERTEXT DOCUMENT index.html!
gd 1.6.1
gd 1.7.0
A graphics library for fast image creation
Follow this link to the latest version of this document.
_HEY! READ THIS!_ gd 1.7.0 creates PNG images, not GIF images. This
is a good thing. PNG is a more compact format, and full compression
is available. Existing code will need modification to call
gdImagePng instead of gdImageGif. _Please do not ask us 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. We are still investigating the legal issues surrounding
various alternative means of producing a valid GIF file.
gd 1.7.0 _requires_ that the following libraries also be installed:
libpng
zlib
If you want to use the TrueType font support, you must also install
the _Freetype library_, including the _freetype.h header file_. See
the Freetype Home Page. No, I cannot explain why that site is down
on a particular day, and no, I can't send you a copy.
If you want to use the Xpm color bitmap loading support, you must
also have the X Window System and the Xpm library installed (Xpm is
often included in modern X distributions).
Please read the documentation and install the required libraries.
Do not send email asking why png.h is not found. See the
requirements section for more information. Thank you!
Table of Contents
* Credits and license terms
* What's new in version 1.7?
* What's new in version 1.6.3?
* What's new in version 1.6.2?
* What's new in version 1.6.1?
* What's new in version 1.6?
* What is gd?
@ -20,7 +47,7 @@ Follow this link to the latest version of this document.
* How do I get gd?
* How do I build gd?
* gd basics: using gd in your program
* webgif: a useful example
* webpng: a useful example
* Function and type reference by category
* About the additional .gd image file format
* Please tell us you're using gd!
@ -49,9 +76,13 @@ COPYRIGHT STATEMENT FOLLOWS THIS LINE
Portions relating to PNG copyright 1999, Greg Roelofs.
Portions relating to libttf copyright 1999, John Ellson
(ellson@lucent.com).
_Permission has been granted to copy and distribute gd in any
context, including a commercial application, provided that this
notice is present in user-accessible supporting documentation._
context without fee, including a commercial application, provided
that this notice is present in user-accessible supporting
documentation._
This does not affect your ownership of the derived work itself, and
the intent is to assure proper credit for the authors of gd, not to
@ -59,27 +90,16 @@ COPYRIGHT STATEMENT FOLLOWS THIS LINE
ask. "Derived works" includes all programs that utilize the
library. Credit must be given in user-accessible documentation.
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that copyright notice and this permission
notice appear in supporting documentation. This software is
provided "as is" without express or implied warranty.
_This software is provided "AS IS."_ The copyright holders disclaim
all warranties, either express or implied, including but not
limited to implied warranties of merchantability and fitness for a
particular purpose, with respect to this code and accompanying
documentation.
Although their code does not appear in gd 1.6.1, the authors wish
Although their code does not appear in gd 1.7.0, the authors wish
to thank David Koblas, David Rowley, and Hutchison Avenue Software
Corporation for their prior contributions.
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that copyright notice and this permission
notice appear in supporting documentation. _This software is
provided "AS IS."_ The copyright holders disclaim all warranties,
either express or implied, including but not limited to implied
warranties of merchantability and fitness for a particular purpose,
with respect to this code and accompanying documentation.
END OF COPYRIGHT STATEMENT
What is gd?
@ -97,18 +117,23 @@ END OF COPYRIGHT STATEMENT
gd does not provide for every possible desirable graphics operation.
It is not necessary or desirable for gd to become a kitchen-sink
graphics package, but version 1.6.1 incorporates most of the commonly
requested features for an 8-bit 2D package. Support for scalable
fonts, and truecolor images, JPEG and truecolor PNG is planned for
version 2.0.
graphics package, but version 1.7.0 incorporates most of the commonly
requested features for an 8-bit 2D package. Support for truecolor
images, JPEG and truecolor PNG is planned for version 2.0.
What if I want to use another programming language?
Perl
gd can also be used from Perl, courtesy of Lincoln Stein's GD.pm
library, which uses gd as the basis for a set of Perl 5.x classes. Not
yet updated for gd 1.6.1.
library, which uses gd as the basis for a set of Perl 5.x classes.
Updated to gd 1.6 and up.
Tcl
gd can be used from Tcl with John Ellson's Gdtclft dynamically loaded
extension package. (Gdtclft2.0 or later is needed for gd-1.6 and up
with PNG output.)
Any Language
@ -117,10 +142,66 @@ END OF COPYRIGHT STATEMENT
text file from whatever scripting language you prefer to use, then
invoke the interpreter.
These packages have not been updated to gd 1.6.1 as of this writing.
These packages have not been updated to gd 1.6 and up as of this
writing.
* tgd, by Bradley K. Sherman
* fly, by Martin Gleeson
What's new in version 1.7?
Version 1.7 contains the following changes:
* Japanese language support for the TrueType functions. Thanks to
Masahito Yamaga.
* autoconf and configure have been removed, in favor of a carefully
designed Makefile which produces and properly installs the library
and the binaries. System-dependent variables are at the top of the
Makefile for easy modification. I'm sorry, folks, but autoconf
generated _many, many confused email messages_ from people who
didn't have things where autoconf expected to find them. I am not
an autoconf/automake wizard, and gd is a simple, very compact
library which does not need to be a shared library. I _did_ make
many improvements over the old gd 1.3 Makefile, which were
directly inspired by the autoconf version found in the 1.6 series
(thanks to John Ellson).
* Completely ANSI C compliant, according to the -pedantic-errors
flag of gcc. Several pieces of not-quite-ANSI-C code were causing
problems for those with non-gcc compilers.
* gdttf.c patched to allow the use of Windows symbol fonts, when
present (thanks to Joseph Peppin).
* extern "C" wrappers added to gd.h and the font header files for
the convenience of C++ programmers. bdftogd was also modified to
automatically insert these wrappers into future font header files.
Thanks to John Lindal.
* Compiles correctly on platforms that don't define SEEK_SET. Thanks
to Robert Bonomi.
* Loads Xpm images via the 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
writing a PNG image.
What's new in version 1.6.2?
Version 1.6.2 from John Ellson adds two new functions:
* gdImageStringTTF - scalable, rotatable, anti-aliased, TrueType
strings using the FreeType library, but only if libttf is found by
configure. _We do not provide TrueType fonts. Obtaining them is
entirely up to you._
* gdImageColorResolve - an efficient alternative for the common code
fragment:
if ((color=gdImageColorExact(im,R,G,B)) < 0)
if ((color=gdImageColorAllocate(im,R,G,B)) < 0)
color=gdImageColorClosest(im,R,G,B);
Also in this release the build process has been converted to GNU
autoconf/automake/libtool conventions so that both (or either) static
and shared libraries can be built.
What's new in version 1.6.1?
Version 1.6.1 incorporates superior PNG reading and writing code from
@ -248,8 +329,8 @@ END OF COPYRIGHT STATEMENT
containing more than 256 characters should work if the
gdImageString16 and gdImageStringUp16 routines are used.
Improvements to the "webgif" example/utility
The "webgif" utility is now a slightly more useful application.
Improvements to the "webpng" example/utility
The "webpng" utility is now a slightly more useful application.
Thanks to Brian Dowling for this code.
Corrections to the color resolution field of GIF output
@ -281,9 +362,11 @@ END OF COPYRIGHT STATEMENT
industry standard. Ask your ISP why it is missing._
As of version 1.6, you also need the zlib compression library, and the
libpng library. zlib is available for a variety of platforms from the
zlib web site. libpng is available for a variety of platforms from the
PNG web site.
libpng library. As of version 1.6.2, you can draw text using
antialiased TrueType fonts if you also have the libttf library
installed, but this is not mandatory. zlib is available for a variety
of platforms from the zlib web site. libpng is available for a variety
of platforms from the PNG web site.
You will also want a PNG viewer, if you do not already have one for
your system, since you will need a good way to check the results of
@ -312,13 +395,18 @@ END OF COPYRIGHT STATEMENT
(Windows), please consult with an experienced user of your system.
Sorry, we cannot answer questions about basic Internet skills.
Unpacking the archive will produce a directory called "gd1.6.1".
Unpacking the archive will produce a directory called "gd-1.7.0".
For Unix
cd to the gd1.6.1 directory and examine the Makefile, which you will
probably need to change slightly depending on your operating system
and your needs.
cd to the 1.7.0 directory. Edit the Makefile with your preferred text
editor and make any necessary changes to the settings at the top,
especially if you want Xpm or TrueType support. Next, type "make". If
you are the system administrator, and you wish to make the gd library
available to other programs, you may also wish to type "make install".
If you get errors, edit the Makefile again, paying special attention
to the INCLUDEDIRS and LIBDIRS settings.
For Windows, Mac, Et Cetera
@ -327,16 +415,9 @@ END OF COPYRIGHT STATEMENT
Add other source files as appropriate. Learning the basic skills of
creating projects with your chosen C environment is up to you.
Now, to build the demonstration program, just type "make gddemo" if
you are working in a command-line environment, or build a project that
includes gddemo.c if you are using a graphical environment. If all
goes well, the program "gddemo" will be compiled and linked without
incident. Depending on your system you may need to edit the Makefile.
Understanding the basic techniques of compiling and linking programs
on your system is up to you.
You have now built a demonstration program which shows off the
capabilities of gd. To see it in action, type "gddemo".
You have now built both the gd library and a demonstration program
which shows off the capabilities of gd. To see it in action, type
"gddemo".
gddemo should execute without incident, creating the file demoout.png.
(Note there is also a file named demoin.png, which is provided in the
@ -360,10 +441,12 @@ END OF COPYRIGHT STATEMENT
gd.c to your own project.
If you want to use the provided fonts, include gdfontt.h, gdfonts.h,
gdfontmb.h, gdfontl.h and/or gdfontg.h. If you are not using the
provided Makefile and/or a library-based approach, be sure to include
the source modules as well in your project. (They may be too large for
16-bit memory models, that is, 16-bit DOS and Windows.)
gdfontmb.h, gdfontl.h and/or gdfontg.h. For more impressive results,
install libttf and use the new gdImageStringTTF function. If you are
not using the provided Makefile and/or a library-based approach, be
sure to include the source modules as well in your project. (They may
be too large for 16-bit memory models, that is, 16-bit DOS and
Windows.)
Here is a short example program. _(For a more advanced example, see
gddemo.c, included in the distribution. gddemo.c is NOT the same
@ -711,6 +794,30 @@ in = fopen("myxbm.xbm", "rb");
im = gdImageCreateFromXbm(in);
fclose(in);
/* ... Use the image ... */
gdImageDestroy(im);
gdImageCreateFromXpm(FILE *in) _(FUNCTION)_
gdImageCreateFromXbm is called to load images from XPM X Window
System color bitmap format files. This function is available
only if HAVE_XPM is selected in the Makefile and the Xpm
library is linked with the application. Invoke
gdImageCreateFromXpm with an already opened pointer to a file
containing the desired image. gdImageCreateFromXpm returns a
gdImagePtr to the new image, or NULL if unable to load the
image (most often because the file is corrupt or does not
contain an XPM bitmap format image). gdImageCreateFromXpm does
_not_ close the file. You can inspect the sx and sy members of
the image to determine its size. The image must eventually be
destroyed using gdImageDestroy().
... inside a function ...
gdImagePtr im;
FILE *in;
in = fopen("myxpm.xpm", "rb");
im = gdImageCreateFromXpm(in);
fclose(in);
/* ... Use the image ... */
gdImageDestroy(im);
gdImageDestroy(gdImagePtr im) _(FUNCTION)_
@ -1429,18 +1536,19 @@ gdImageDestroy(im);
c, int color) _(FUNCTION)_
gdImageChar is used to draw single characters on the
image. (To draw multiple characters, use gdImageString or
gdImageString16.) The second argument is a pointer to a
font definition structure; five fonts are provided with
gd, gdFontTiny, gdFontSmall, gdFontMediumBold,
gdFontLarge, and gdFontGiant. You must include the files
"gdfontt.h", "gdfonts.h", "gdfontmb.h", "gdfontl.h" and
"gdfontg.h" respectively and (if you are not using a
library-based approach) link with the corresponding .c
files to use the provided fonts. The character specified
by the fifth argument is drawn from left to right in the
specified color. (See gdImageCharUp for a way of drawing
vertical text.) Pixels not set by a particular character
retain their previous color.
gdImageString16. See also gdImageStringTTF, new with
gd-1.6.2.) The second argument is a pointer to a font
definition structure; five fonts are provided with gd,
gdFontTiny, gdFontSmall, gdFontMediumBold, gdFontLarge,
and gdFontGiant. You must include the files "gdfontt.h",
"gdfonts.h", "gdfontmb.h", "gdfontl.h" and "gdfontg.h"
respectively and (if you are not using a library-based
approach) link with the corresponding .c files to use the
provided fonts. The character specified by the fifth
argument is drawn from left to right in the specified
color. (See gdImageCharUp for a way of drawing vertical
text.) Pixels not set by a particular character retain
their previous color.
#include "gd.h"
@ -1511,8 +1619,9 @@ gdImageDestroy(im);
provided fonts. The null-terminated C string specified by
the fifth argument is drawn from left to right in the
specified color. (See gdImageStringUp for a way of
drawing vertical text.) Pixels not set by a particular
character retain their previous color.
drawing vertical text. See also gdImageStringTTF, new
with gd-1.6.2.) Pixels not set by a particular character
retain their previous color.
#include "gd.h"
@ -1627,6 +1736,92 @@ gdImageDestroy(im);
who have them. A more frequently used routine is
gdImageStringUp.
char *gdImageStringTTF(gdImagePtr im, int *brect, int fg, char
*fontname, double ptsize, double angle, int x, int y,
char *string) _(FUNCTION)_
gdImageStringTTF is draws a string of anti-aliased
characters on the image using the FreeType library to
print from user-supplied TrueType fonts. _We do not
provide TrueType fonts. Obtaining them is entirely up to
you._ The string is anti-aliased, meaning that there
should be less "jaggies." The fontname is the full
pathname to a TrueType font file. The string may be
arbitrarily scaled (ptsize) and rotated (angle in
radians).
The user-supplied int brect[8] array is filled on return
from gdImageStringTTF with the 8 elements representing
the 4 corner coordinates of the bounding rectangle.
0 lower left corner, X position
lower left corner, Y position
lower right corner, X position
3 lower right corner, Y position
4 upper right corner, X position
5 upper right corner, Y position
6 upper left corner, X position
7 upper left corner, Y position
The points are relative to the text regardless of the
angle, so "upper left" means in the top left-hand corner
seeing the text horizontally.
Use a NULL gdImagePtr to get the bounding rectangle
without rendering. This is a relatively cheap operation
if followed by a rendering of the same string, because of
the caching of the partial rendering during bounding
rectangle calculation.
The string is rendered in the color indicated by the gf
color index. Use the negative of the desired color index
to disable anti-aliasing.
The string may contain UTF-8 sequences like: "&#192;"
gdImageStringTTF will return a null char* on success, or
an error string on failure.
#include "gd.h"
#include <string.h>
... inside a function ...
gdImagePtr im;
int black;
int white;
int brect[8];
int x, y;
char *err;
char *s = "Hello."; /* String to draw. */
double sz = 40.;
char *f = "/usr/local/share/ttf/Times.ttf"; /* User supplied font */
/* obtain brect so that we can size the image */
err = gdImageStringTTF(NULL,&brect[0],0,f,sz,0.,0,0,s);
if (err) {fprintf(stderr,err); return 1;}
/* create an image big enough for the string plus a little whitespace */
x = brect[2]-brect[6] + 6;
y = brect[3]-brect[7] + 6;
im = gdImageCreate(x,y);
/* Background color (first allocated) */
white = gdImageColorResolve(im, 255, 255, 255);
black = gdImageColorResolve(im, 0, 0, 0);
/* render the string, offset origin to center string*/
/* note that we use top-left coordinate for adjustment
* since gd origin is in top-left with y increasing downwards. */
x = 3 - brect[6];
y = 3 - brect[7];
err = gdImageStringTTF(im,&brect[0],black,f,sz,0.0,x,y,s);
if (err) {fprintf(stderr,err); return 1;}
/* Write img to stdout */
gdImagePng(im, stdout);
/* Destroy it */
gdImageDestroy(im);
Color-handling functions
int gdImageColorAllocate(gdImagePtr im, int r, int g, int b)
@ -1647,7 +1842,8 @@ gdImageDestroy(im);
for existing colors that match your request; see
gdImageColorExact and gdImageColorClosest for ways to
locate existing colors that approximate the color desired
in situations where a new color is not available.
in situations where a new color is not available. Also
see gdImageColorResolve, new in gd-1.6.2.
... inside a function ...
@ -1740,6 +1936,35 @@ if (red == (-1)) {
gdImageDashedLine(im, 0, 0, 99, 99, red);
/* ... Do something with the image, such as saving it to a file... */
/* Destroy it */
gdImageDestroy(im);
int gdImageColorResolve(gdImagePtr im, int r, int g, int b)
_(FUNCTION)_
gdImageColorResolve searches the colors which have been
defined thus far in the image specified and returns the
index of the first color with RGB values which exactly
match those of the request. If no allocated color matches
the request precisely, then gdImageColorResolve tries to
allocate the exact color. If there is no space left in
the color table then gdImageColorResolve returns the
closest color (as in gdImageColorClosest). This function
always returns an index of a color.
... inside a function ...
gdImagePtr im;
int red;
in = fopen("photo.png", "rb");
im = gdImageCreateFromPng(in);
fclose(in);
/* The image may already contain red; if it does, we'll save a slot
in the color table by using that color. */
/* Get index of red, or color closest to red */
red = gdImageColorResolve(im, 255, 0, 0);
/* Draw a dashed line from the upper left corner to the lower right corner */
gdImageDashedLine(im, 0, 0, 99, 99, red);
/* ... Do something with the image, such as saving it to a file... */
/* Destroy it */
gdImageDestroy(im);
int gdImageColorsTotal(gdImagePtr im) _(MACRO)_
@ -2023,6 +2248,22 @@ gdImageCopyMergeGray(im_out, im_in, 100, 200, 0, 0, 30, 50, 50);
Miscellaneous Functions
int gdImageCompare(gdImagePtr im1, gdImagePtr im2)
_(FUNCTION)_
gdImageCompare returns a bitmap indicating if the
two images are different. The members of the bitmap
are defined in gd.h, but the most important is
GD_CMP_IMAGE, which indicated that the images will
actually appear different when displayed. Other,
less important, differences relate to pallette
entries. Any difference in the transparent colour
is assumed to make images display differently, even
if the transparent colour is not used.
... Inside a function ...
cmpMask = gdImageCompare(im1, im2);
gdImageInterlace(gdImagePtr im, int interlace) _(FUNCTION)_
gdImageInterlace is used to determine whether an
@ -2063,127 +2304,139 @@ gdImageDestroy(im);
Constants
gdBrushed _(CONSTANT)_
Used in place of a color when invoking a
line-drawing function such as gdImageLine or
gdImageRectangle. When gdBrushed is used as the
color, the brush image set with gdImageSetBrush is
drawn in place of each pixel of the line (the brush
is usually larger than one pixel, creating the
effect of a wide paintbrush). See also
gdStyledBrushed for a way to draw broken lines with
a series of distinct copies of an image.
gdMaxColors_(CONSTANT)_
The constant 256. This is the maximum number of
colors in a PNG file according to the PNG standard,
and is also the maximum number of colors in a gd
image.
gdStyled _(CONSTANT)_
Used in place of a color when invoking a
line-drawing function such as gdImageLine or
gdImageRectangle. When gdStyled is used as the
color, the colors of the pixels are drawn
successively from the style that has been set with
gdImageSetStyle. If the color of a pixel is equal
to gdTransparent, that pixel is not altered. (This
mechanism is completely unrelated to the
"transparent color" of the image itself; see
gdImageColorTransparent gdImageColorTransparent for
that mechanism.) See also gdStyledBrushed.
gdStyledBrushed _(CONSTANT)_
Used in place of a color when invoking a
line-drawing function such as gdImageLine or
gdImageRectangle. When gdStyledBrushed is used as
the color, the brush image set with gdImageSetBrush
is drawn at each pixel of the line, providing that
the style set with gdImageSetStyle contains a
nonzero value (OR gdTransparent, which does not
equal zero but is supported for consistency) for
the current pixel. (Pixels are drawn successively
from the style as the line is drawn, returning to
the beginning when the available pixels in the
style are exhausted.) Note that this differs from
the behavior of gdStyled, in which the values in
the style are used as actual pixel colors, except
for gdTransparent.
gdDashSize _(CONSTANT)_
The length of a dash in a dashed line. Defined to
be 4 for backwards compatibility with programs that
use gdImageDashedLine. New programs should use
gdImageSetStyle and call the standard gdImageLine
function with the special "color" gdStyled or
gdStyledBrushed.
gdTiled _(CONSTANT)_
Used in place of a normal color in
gdImageFilledRectangle, gdImageFilledPolygon,
gdImageFill, and gdImageFillToBorder. gdTiled
selects a pixel from the tile image set with
gdImageSetTile in such a way as to ensure that the
filled area will be tiled with copies of the tile
image. See the discussions of gdImageFill and
gdImageFillToBorder for special restrictions
regarding those functions.
gdTransparent _(CONSTANT)_
Used in place of a normal color in a style to be
set with gdImageSetStyle. gdTransparent is _not_
the transparent color index of the image; for that
functionality please see gdImageColorTransparent.
gdBrushed _(CONSTANT)_
Used in place of a color when invoking a
line-drawing function such as gdImageLine or
gdImageRectangle. When gdBrushed is used as
the color, the brush image set with
gdImageSetBrush is drawn in place of each
pixel of the line (the brush is usually
larger than one pixel, creating the effect of
a wide paintbrush). See also gdStyledBrushed
for a way to draw broken lines with a series
of distinct copies of an image.
gdMaxColors_(CONSTANT)_
The constant 256. This is the maximum number
of colors in a PNG file according to the PNG
standard, and is also the maximum number of
colors in a gd image.
gdStyled _(CONSTANT)_
Used in place of a color when invoking a
line-drawing function such as gdImageLine or
gdImageRectangle. When gdStyled is used as
the color, the colors of the pixels are drawn
successively from the style that has been set
with gdImageSetStyle. If the color of a pixel
is equal to gdTransparent, that pixel is not
altered. (This mechanism is completely
unrelated to the "transparent color" of the
image itself; see gdImageColorTransparent
gdImageColorTransparent for that mechanism.)
See also gdStyledBrushed.
gdStyledBrushed _(CONSTANT)_
Used in place of a color when invoking a
line-drawing function such as gdImageLine or
gdImageRectangle. When gdStyledBrushed is
used as the color, the brush image set with
gdImageSetBrush is drawn at each pixel of the
line, providing that the style set with
gdImageSetStyle contains a nonzero value (OR
gdTransparent, which does not equal zero but
is supported for consistency) for the current
pixel. (Pixels are drawn successively from
the style as the line is drawn, returning to
the beginning when the available pixels in
the style are exhausted.) Note that this
differs from the behavior of gdStyled, in
which the values in the style are used as
actual pixel colors, except for
gdTransparent.
gdDashSize _(CONSTANT)_
The length of a dash in a dashed line.
Defined to be 4 for backwards compatibility
with programs that use gdImageDashedLine. New
programs should use gdImageSetStyle and call
the standard gdImageLine function with the
special "color" gdStyled or gdStyledBrushed.
gdTiled _(CONSTANT)_
Used in place of a normal color in
gdImageFilledRectangle, gdImageFilledPolygon,
gdImageFill, and gdImageFillToBorder. gdTiled
selects a pixel from the tile image set with
gdImageSetTile in such a way as to ensure
that the filled area will be tiled with
copies of the tile image. See the discussions
of gdImageFill and gdImageFillToBorder for
special restrictions regarding those
functions.
gdTransparent _(CONSTANT)_
Used in place of a normal color in a style to
be set with gdImageSetStyle. gdTransparent is
_not_ the transparent color index of the
image; for that functionality please see
gdImageColorTransparent.
About the additional .gd image file format
In addition to reading and writing the PNG format
and reading the X Bitmap format, gd has the
capability to read and write its own ".gd" format.
This format is _not_ intended for general purpose
use and should never be used to distribute images.
It is not a compressed format. Its purpose is
solely to allow very fast loading of images your
program needs often in order to build other images
for output. If you are experiencing performance
problems when loading large, fixed PNG images your
program needs to produce its output images, you may
wish to examine the functions gdImageCreateFromGd
and gdImageGd, which read and write .gd format
images.
The program "pngtogd.c" is provided as a simple way
of converting .png files to .gd format. I emphasize
again that you will not need to use this format
unless you have a need for high-speed loading of a
few frequently-used images in your program.
In addition to reading and writing the PNG
format and reading the X Bitmap format, gd
has the capability to read and write its own
".gd" format. This format is _not_ intended
for general purpose use and should never be
used to distribute images. It is not a
compressed format. Its purpose is solely to
allow very fast loading of images your
program needs often in order to build other
images for output. If you are experiencing
performance problems when loading large,
fixed PNG images your program needs to
produce its output images, you may wish to
examine the functions gdImageCreateFromGd and
gdImageGd, which read and write .gd format
images.
The program "pngtogd.c" is provided as a
simple way of converting .png files to .gd
format. I emphasize again that you will not
need to use this format unless you have a
need for high-speed loading of a few
frequently-used images in your program.
About the .gd2 image file format
In addition to reading and writing the PNG format
and reading the X Bitmap format, gd has the
capability to read and write its own ".gd2" format.
This format is _not_ intended for general purpose
use and should never be used to distribute images.
It is a compressed format allowing pseudo-random
access to large image files. Its purpose is solely
to allow very fast loading of _parts_ of images If
you are experiencing performance problems when
loading large, fixed PNG images your program needs
to produce its output images, you may wish to
examine the functions gdImageCreateFromGd2,
gdImageCreateFromGd2Part and gdImageGd2, which read
and write .gd2 format images.
The program "pngtogd2.c" is provided as a simple
way of converting .png files to .gd2 format.
In addition to reading and writing the PNG
format and reading the X Bitmap format, gd
has the capability to read and write its own
".gd2" format. This format is _not_ intended
for general purpose use and should never be
used to distribute images. It is a compressed
format allowing pseudo-random access to large
image files. Its purpose is solely to allow
very fast loading of _parts_ of images If you
are experiencing performance problems when
loading large, fixed PNG images your program
needs to produce its output images, you may
wish to examine the functions
gdImageCreateFromGd2,
gdImageCreateFromGd2Part and gdImageGd2,
which read and write .gd2 format images.
The program "pngtogd2.c" is provided as a
simple way of converting .png files to .gd2
format.
About the gdIOCtx structure
Version 1.5 of GD added a new style of I/O based on
an IOCtx structure (the most up-to-date version can
be found in gd_io.h):
Version 1.5 of GD added a new style of I/O
based on an IOCtx structure (the most
up-to-date version can be found in gd_io.h):
typedef struct gdIOCtx {
int (*getC)(struct gdIOCtx*);
@ -2199,76 +2452,87 @@ typedef struct gdIOCtx {
} gdIOCtx;
Most functions that accepted files in previous versions now
also have a counterpart that accepts an I/O
context. These functions have a 'Ctx' suffix.
The Ctx routines use the function pointers in the
I/O context pointed to by gdIOCtx to perform all
I/O. Examples of how to implement an I/O context
can be found in io_file.c (which provides a wrapper
for file routines), and io_dp.c (which implements
in-memory storage).
It is not necessary to implement all functions in
an I/O context if you know that it will only be
used in limited cirsumstances. At the time of
writing (Version 1.6.1, July 1999), the known
requirements are:
All Must have 'free',
Anything that reads from the context Must have
'getC' and 'getBuf',
Anything that writes to the context Must have
'putC' and 'putBuf'.
If gdCreateFromGd2Part is called Must also have
'seek' and 'tell'.
If gdImageGd2 is called Must also have 'seek' and
'tell'.
Most functions that accepted files in previous
versions now also have a counterpart that
accepts an I/O context. These functions have
a 'Ctx' suffix.
The Ctx routines use the function pointers in
the I/O context pointed to by gdIOCtx to
perform all I/O. Examples of how to implement
an I/O context can be found in io_file.c
(which provides a wrapper for file routines),
and io_dp.c (which implements in-memory
storage).
It is not necessary to implement all
functions in an I/O context if you know that
it will only be used in limited
cirsumstances. At the time of writing
(Version 1.6.1, July 1999), the known
requirements are:
All Must have 'free',
Anything that reads from the context Must
have 'getC' and 'getBuf',
Anything that writes to the context Must have
'putC' and 'putBuf'.
If gdCreateFromGd2Part is called Must also
have 'seek' and 'tell'.
If gdImageGd2 is called Must also have 'seek'
and 'tell'.
Please tell us you're using gd!
When you contact us and let us know you are using
gd, you help us justify the time spent in
maintaining and improving it. So please let us
know. If the results are publicly visible on the
web, a URL is a wonderful thing to receive, but if
it's not a publicly visible project, a simple note
is just as welcome.
When you contact us and let us know you are
using gd, you help us justify the time spent
in maintaining and improving it. So please
let us know. If the results are publicly
visible on the web, a URL is a wonderful
thing to receive, but if it's not a publicly
visible project, a simple note is just as
welcome.
If you have problems
If you have any difficulties with gd, feel free to
contact the author, Thomas Boutell. Problems
relating to the gd2 format should be addressed to
Philip Warner.
_Be sure to read this manual carefully first. _
If you have any difficulties with gd, feel
free to contact the author, Thomas Boutell.
Problems relating to the gd2 format should be
addressed to Philip Warner.
_Be sure to read this manual carefully first.
_
Alphabetical quick index
gdBrushed | gdDashSize | gdFont | gdFontPtr |
gdImage | gdImageArc | gdImageBlue |
gdImageBoundsSafe | gdImageChar | gdImageCharUp |
gdImageColorAllocate | gdImageColorClosest |
gdImageColorDeallocate | gdImageColorExact |
gdImageColorTransparent | gdImageCopy |
gdImageCopyResized | gdImageCreate |
gdImageCreateFromGd | gdImageCreateFromGd2 |
gdImageCreateFromGd2Part | gdImageCreateFromPng |
gdImageCreateFromPngSource | gdImageCreateFromXbm |
gdImageDashedLine | gdImageDestroy | gdImageFill |
gdImageFillToBorder | gdImageFilledRectangle |
gdImageGd | gdImageGd2 | gdImageGetInterlaced |
gdImageGetPixel | gdImageGetTransparent |
gdImageGreen | gdImageInterlace | gdImageLine |
gdImageFilledPolygon | gdImagePaletteCopy |
gdImagePng | gdImagePngToSink | gdImagePolygon |
gdImagePtr | gdImageRectangle | gdImageRed |
gdImageSetBrush | gdImageSetPixel | gdImageSetStyle
| gdImageSetTile | gdImageString | gdImageString16
| gdImageStringUp | gdImageStringUp16 | gdMaxColors
| gdPoint | gdStyled | gdStyledBrushed | gdTiled |
gdTransparent
_Boutell.Com, Inc._
gdBrushed | gdDashSize | gdFont | gdFontPtr |
gdImage | gdImageArc | gdImageBlue |
gdImageBoundsSafe | gdImageChar |
gdImageCharUp | gdImageColorAllocate |
gdImageColorClosest | gdImageColorDeallocate
| gdImageColorExact | gdImageColorResolve |
gdImageColorTransparent | gdImageCopy |
gdImageCopyResized | gdImageCreate |
gdImageCreateFromGd | gdImageCreateFromGd2 |
gdImageCreateFromGd2Part |
gdImageCreateFromPng |
gdImageCreateFromPngSource |
gdImageCreateFromXbm | gdImageCreateFromXpm |
gdImageDashedLine | gdImageDestroy |
gdImageFill | gdImageFillToBorder |
gdImageFilledRectangle | gdImageGd |
gdImageGd2 | gdImageGetInterlaced |
gdImageGetPixel | gdImageGetTransparent |
gdImageGreen | gdImageInterlace | gdImageLine
| gdImageFilledPolygon | gdImagePaletteCopy |
gdImagePng | gdImagePngToSink |
gdImagePolygon | gdImagePtr |
gdImageRectangle | gdImageRed |
gdImageSetBrush | gdImageSetPixel |
gdImageSetStyle | gdImageSetTile |
gdImageString | gdImageString16 |
gdImageStringTTF | gdImageStringUp |
gdImageStringUp16 | gdMaxColors | gdPoint |
gdStyled | gdStyledBrushed | gdTiled |
gdTransparent
_Boutell.Com, Inc._