8
/* gd.h: declarations file for the graphic-draw module.
9
* Permission to use, copy, modify, and distribute this software and its
10
* documentation for any purpose and without fee is hereby granted, provided
11
* that the above copyright notice appear in all copies and that both that
12
* copyright notice and this permission notice appear in supporting
13
* documentation. This software is provided "AS IS." Thomas Boutell and
14
* Boutell.Com, Inc. disclaim all warranties, either express or implied,
15
* including but not limited to implied warranties of merchantability and
16
* fitness for a particular purpose, with respect to this code and accompanying
19
/* stdio is needed for file I/O. */
23
/* This can't be changed in the current palette-only version of gd. */
25
#define gdMaxColors 256
27
/* Image type. See functions below; you will not need to change
28
the elements directly. Use the provided macros to
29
access sx, sy, the color table, and colorsTotal for
30
read-only purposes. */
32
typedef struct gdImageStruct {
33
unsigned char ** pixels;
38
int green[gdMaxColors];
39
int blue[gdMaxColors];
40
int open[gdMaxColors];
44
struct gdImageStruct *brush;
45
struct gdImageStruct *tile;
46
int brushColorMap[gdMaxColors];
47
int tileColorMap[gdMaxColors];
54
typedef gdImage * gdImagePtr;
57
/* # of characters in font */
59
/* First character is numbered... (usually 32 = space) */
61
/* Character width and height */
64
/* Font data; array of characters, one row after another.
65
Easily included in code, also easily loaded from
70
/* Text functions take these. */
71
typedef gdFont *gdFontPtr;
73
/* For backwards compatibility only. Use gdImageSetStyle()
74
for MUCH more flexible line drawing. Also see
81
#define gdBrushed (-3)
82
#define gdStyledBrushed (-4)
85
/* NOT the same as the transparent color index.
86
This is used in line styles only. */
87
#define gdTransparent (-6)
89
/* Functions to manipulate images. */
91
gdImagePtr gdImageCreate(int sx, int sy);
92
gdImagePtr gdImageCreateFromPng(FILE *fd);
93
gdImagePtr gdImageCreateFromPngCtx(gdIOCtxPtr in);
95
/* A custom data source. */
96
/* The source function must return -1 on error, otherwise the number
97
of bytes fetched. 0 is EOF, not an error! */
98
/* context will be passed to your source function. */
101
int (*source) (void *context, char *buffer, int len);
103
} gdSource, *gdSourcePtr;
105
gdImagePtr gdImageCreateFromPngSource(gdSourcePtr in);
107
gdImagePtr gdImageCreateFromGd(FILE *in);
108
gdImagePtr gdImageCreateFromGdCtx(gdIOCtxPtr in);
110
gdImagePtr gdImageCreateFromGd2(FILE *in);
111
gdImagePtr gdImageCreateFromGd2Ctx(gdIOCtxPtr in);
113
gdImagePtr gdImageCreateFromGd2Part(FILE *in, int srcx, int srcy, int w, int h);
114
gdImagePtr gdImageCreateFromGd2PartCtx(gdIOCtxPtr in, int srcx, int srcy, int w, int h);
116
gdImagePtr gdImageCreateFromXbm(FILE *fd);
118
void gdImageDestroy(gdImagePtr im);
119
void gdImageSetPixel(gdImagePtr im, int x, int y, int color);
120
int gdImageGetPixel(gdImagePtr im, int x, int y);
121
void gdImageLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
122
/* For backwards compatibility only. Use gdImageSetStyle()
123
for much more flexible line drawing. */
124
void gdImageDashedLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
125
/* Corners specified (not width and height). Upper left first, lower right
127
void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
128
/* Solid bar. Upper left corner first, lower right corner second. */
129
void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
130
int gdImageBoundsSafe(gdImagePtr im, int x, int y);
131
void gdImageChar(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
132
void gdImageCharUp(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
133
void gdImageString(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);
134
void gdImageStringUp(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);
135
void gdImageString16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
136
void gdImageStringUp16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
138
char *gdImageStringTTF(gdImage *im, int *brect, int fg, char *fontname,
139
double ptsize, double angle, int x, int y, char *string);
141
/* Point type for use in polygon drawing. */
145
} gdPoint, *gdPointPtr;
147
void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c);
148
void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c);
150
int gdImageColorAllocate(gdImagePtr im, int r, int g, int b);
151
int gdImageColorClosest(gdImagePtr im, int r, int g, int b);
152
int gdImageColorExact(gdImagePtr im, int r, int g, int b);
153
int gdImageColorResolve(gdImagePtr im, int r, int g, int b);
154
void gdImageColorDeallocate(gdImagePtr im, int color);
155
void gdImageColorTransparent(gdImagePtr im, int color);
156
void gdImagePaletteCopy(gdImagePtr dst, gdImagePtr src);
157
void gdImagePng(gdImagePtr im, FILE *out);
158
void gdImagePngCtx(gdImagePtr im, gdIOCtx *out);
160
void gdImageWBMP(gdImagePtr image, int fg, FILE *out);
161
void gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out);
162
void *gdImageWBMPPtr(gdImagePtr im, int *size, int fg);
163
gdImagePtr gdImageCreateFromWBMP(FILE *inFile);
164
gdImagePtr gdImageCreateFromWBMPCtx(gdIOCtx *infile);
167
void gdImageJpeg(gdImagePtr im, FILE *out, int quality);
168
void gdImageJpegCtx(gdImagePtr im, gdIOCtx *out, int quality);
169
void *gdImageJpegPtr(gdImagePtr im, int *size, int quality);
170
gdImagePtr gdImageCreateFromJpeg(FILE *infile);
171
gdImagePtr gdImageCreateFromJpegCtx(gdIOCtx *infile);
173
/* A custom data sink. For backwards compatibility. Use
175
/* The sink function must return -1 on error, otherwise the number
176
of bytes written, which must be equal to len. */
177
/* context will be passed to your sink function. */
179
int (*sink) (void *context, const char *buffer, int len);
181
} gdSink, *gdSinkPtr;
183
void gdImagePngToSink(gdImagePtr im, gdSinkPtr out);
185
void gdImageGd(gdImagePtr im, FILE *out);
186
void gdImageGd2(gdImagePtr im, FILE *out, int cs, int fmt);
187
void* gdImagePngPtr(gdImagePtr im, int *size);
188
void* gdImageGdPtr(gdImagePtr im, int *size);
189
void* gdImageGd2Ptr(gdImagePtr im, int cs, int fmt, int *size);
190
void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color);
191
void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color);
192
void gdImageFill(gdImagePtr im, int x, int y, int color);
193
void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h);
194
void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
195
int srcX, int srcY, int w, int h, int pct);
196
void gdImageCopyMergeGray(gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
197
int srcX, int srcY, int w, int h, int pct);
199
/* Stretches or shrinks to fit, as needed */
200
void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);
201
void gdImageSetBrush(gdImagePtr im, gdImagePtr brush);
202
void gdImageSetTile(gdImagePtr im, gdImagePtr tile);
203
void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels);
204
/* On or off (1 or 0) */
205
void gdImageInterlace(gdImagePtr im, int interlaceArg);
207
/* Macros to access information about images. READ ONLY. Changing
208
these values will NOT have the desired result. */
209
#define gdImageSX(im) ((im)->sx)
210
#define gdImageSY(im) ((im)->sy)
211
#define gdImageColorsTotal(im) ((im)->colorsTotal)
212
#define gdImageRed(im, c) ((im)->red[(c)])
213
#define gdImageGreen(im, c) ((im)->green[(c)])
214
#define gdImageBlue(im, c) ((im)->blue[(c)])
215
#define gdImageGetTransparent(im) ((im)->transparent)
216
#define gdImageGetInterlaced(im) ((im)->interlace)
218
/* I/O Support routines. */
220
gdIOCtx* gdNewFileCtx(FILE*);
221
gdIOCtx* gdNewDynamicCtx(int, void*);
222
gdIOCtx* gdNewSSCtx(gdSourcePtr in, gdSinkPtr out);
223
void* gdDPExtractData(struct gdIOCtx* ctx, int *size);
226
#define GD2_CHUNKSIZE 128
227
#define GD2_CHUNKSIZE_MIN 64
228
#define GD2_CHUNKSIZE_MAX 4096
232
#define GD2_FMT_RAW 1
233
#define GD2_FMT_COMPRESSED 2
235
/* Image comparison definitions */
236
int gdImageCompare(gdImagePtr im1, gdImagePtr im2);
238
#define GD_CMP_IMAGE 1 /* Actual image IS different */
239
#define GD_CMP_NUM_COLORS 2 /* Number of Colours in pallette differ */
240
#define GD_CMP_COLOR 4 /* Image colours differ */
241
#define GD_CMP_SIZE_X 8 /* Image width differs */
242
#define GD_CMP_SIZE_Y 16 /* Image heights differ */
243
#define GD_CMP_TRANSPARENT 32 /* Transparent colour */
244
#define GD_CMP_BACKGROUND 64 /* Background colour */
245
#define GD_CMP_INTERLACE 128 /* Interlaced setting */