8
/* Do the DLL dance: dllexport when building the DLL,
9
dllimport when importing from it, nothing when
10
not on Silly Silly Windows (tm Aardman Productions). */
12
/* 2.0.20: for headers */
14
/* 2.0.24: __stdcall also needed for Visual BASIC
15
and other languages. This breaks ABI compatibility
16
with previous DLL revs, but it's necessary. */
18
/* 2.0.29: WIN32 programmers can declare the NONDLL macro if they
19
wish to build gd as a static library or by directly including
20
the gd sources in a project. */
27
#define BGD_DECLARE(rt) extern rt
30
#define BGD_DECLARE(rt) __declspec(dllexport) rt __stdcall
32
#define BGD_DECLARE(rt) __declspec(dllimport) rt _stdcall
36
/* 2.0.20: for actual storage of exported data, functions don't need this,
37
currently needed only for font pointers */
39
/* 2.0.25: bring back extern */
40
#define BGD_EXPORT_DATA_PROT extern
41
#define BGD_EXPORT_DATA_IMPL
44
#define BGD_EXPORT_DATA_PROT __declspec(dllexport) extern
45
#define BGD_EXPORT_DATA_IMPL __declspec(dllexport)
47
#define BGD_EXPORT_DATA_PROT __declspec(dllimport) extern
48
#define BGD_EXPORT_DATA_IMPL __declspec(dllimport)
57
/* some might want to set DEFAULT_FONTPATH from configure in config.h */
59
/* 2.0.23: more Type 1 fonts */
60
#ifndef DEFAULT_FONTPATH
61
/* default fontpath for unix systems - whatever happened to standards ! */
62
#define DEFAULT_FONTPATH "/usr/X11R6/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/truetype:/usr/X11R6/lib/X11/fonts/TTF:/usr/share/fonts/TrueType:/usr/share/fonts/truetype:/usr/openwin/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/Type1:/usr/lib/X11/fonts/Type1:/usr/openwin/lib/X11/fonts/Type1"
65
#define PATHSEPARATOR ":"
68
/* gd.h: declarations file for the graphic-draw module.
69
* Permission to use, copy, modify, and distribute this software and its
70
* documentation for any purpose and without fee is hereby granted, provided
71
* that the above copyright notice appear in all copies and that both that
72
* copyright notice and this permission notice appear in supporting
73
* documentation. This software is provided "AS IS." Thomas Boutell and
74
* Boutell.Com, Inc. disclaim all warranties, either express or implied,
75
* including but not limited to implied warranties of merchantability and
76
* fitness for a particular purpose, with respect to this code and accompanying
79
/* stdio is needed for file I/O. */
83
/* The maximum number of palette entries in palette-based images.
84
In the wonderful new world of gd 2.0, you can of course have
85
many more colors when using truecolor mode. */
87
#define gdMaxColors 256
89
/* Image type. See functions below; you will not need to change
90
the elements directly. Use the provided macros to
91
access sx, sy, the color table, and colorsTotal for
92
read-only purposes. */
94
/* If 'truecolor' is set true, the image is truecolor;
95
pixels are represented by integers, which
96
must be 32 bits wide or more.
98
True colors are repsented as follows:
102
Where 'A' (alpha channel) occupies only the
103
LOWER 7 BITS of the MSB. This very small
104
loss of alpha channel resolution allows gd 2.x
105
to keep backwards compatibility by allowing
106
signed integers to be used to represent colors,
107
and negative numbers to represent special cases,
108
just as in gd 1.x. */
110
#define gdAlphaMax 127
111
#define gdAlphaOpaque 0
112
#define gdAlphaTransparent 127
114
#define gdGreenMax 255
115
#define gdBlueMax 255
116
#define gdTrueColorGetAlpha(c) (((c) & 0x7F000000) >> 24)
117
#define gdTrueColorGetRed(c) (((c) & 0xFF0000) >> 16)
118
#define gdTrueColorGetGreen(c) (((c) & 0x00FF00) >> 8)
119
#define gdTrueColorGetBlue(c) ((c) & 0x0000FF)
121
/* This function accepts truecolor pixel values only. The
122
source color is composited with the destination color
123
based on the alpha channel value of the source color.
124
The resulting color is opaque. */
126
BGD_DECLARE(int) gdAlphaBlend (int dest, int src);
128
typedef struct gdImageStruct
130
/* Palette-based image pixels */
131
unsigned char **pixels;
134
/* These are valid in palette images only. See also
135
'alpha', which appears later in the structure to
136
preserve binary backwards compatibility */
138
int red[gdMaxColors];
139
int green[gdMaxColors];
140
int blue[gdMaxColors];
141
int open[gdMaxColors];
142
/* For backwards compatibility, this is set to the
143
first palette entry with 100% transparency,
144
and is also set and reset by the
145
gdImageColorTransparent function. Newer
146
applications can allocate palette entries
147
with any desired level of transparency; however,
148
bear in mind that many viewers, notably
149
many web browsers, fail to implement
150
full alpha channel for PNG and provide
151
support for full opacity or transparency only. */
155
struct gdImageStruct *brush;
156
struct gdImageStruct *tile;
157
int brushColorMap[gdMaxColors];
158
int tileColorMap[gdMaxColors];
163
/* New in 2.0: thickness of line. Initialized to 1. */
165
/* New in 2.0: alpha channel for palettes. Note that only
166
Macintosh Internet Explorer and (possibly) Netscape 6
167
really support multiple levels of transparency in
168
palettes, to my knowledge, as of 2/15/01. Most
169
common browsers will display 100% opaque and
170
100% transparent correctly, and do something
171
unpredictable and/or undesirable for levels
173
int alpha[gdMaxColors];
174
/* Truecolor flag and pixels. New 2.0 fields appear here at the
175
end to minimize breakage of existing object code. */
178
/* Should alpha channel be copied, or applied, each time a
179
pixel is drawn? This applies to truecolor images only.
180
No attempt is made to alpha-blend in palette images,
181
even if semitransparent palette entries exist.
182
To do that, build your image as a truecolor image,
183
then quantize down to 8 bits. */
184
int alphaBlendingFlag;
185
/* Should the alpha channel of the image be saved? This affects
186
PNG at the moment; other future formats may also
187
have that capability. JPEG doesn't. */
190
/* There should NEVER BE ACCESSOR MACROS FOR ITEMS BELOW HERE, so this
191
part of the structure can be safely changed in new releases. */
193
/* 2.0.12: anti-aliased globals. 2.0.26: just a few vestiges after
194
switching to the fast, memory-cheap implementation from PHP-gd. */
199
/* 2.0.12: simple clipping rectangle. These values
200
must be checked for safety when set; please use
209
typedef gdImage *gdImagePtr;
213
/* # of characters in font */
215
/* First character is numbered... (usually 32 = space) */
217
/* Character width and height */
220
/* Font data; array of characters, one row after another.
221
Easily included in code, also easily loaded from
227
/* Text functions take these. */
228
typedef gdFont *gdFontPtr;
230
/* For backwards compatibility only. Use gdImageSetStyle()
231
for MUCH more flexible line drawing. Also see
232
gdImageSetBrush(). */
235
/* Special colors. */
237
#define gdStyled (-2)
238
#define gdBrushed (-3)
239
#define gdStyledBrushed (-4)
242
/* NOT the same as the transparent color index.
243
This is used in line styles only. */
244
#define gdTransparent (-6)
246
#define gdAntiAliased (-7)
248
/* Functions to manipulate images. */
250
/* Creates a palette-based image (up to 256 colors). */
251
BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy);
253
/* An alternate name for the above (2.0). */
254
#define gdImageCreatePalette gdImageCreate
256
/* Creates a truecolor image (millions of colors). */
257
BGD_DECLARE(gdImagePtr) gdImageCreateTrueColor (int sx, int sy);
259
/* Creates an image from various file types. These functions
260
return a palette or truecolor image based on the
261
nature of the file being loaded. Truecolor PNG
262
stays truecolor; palette PNG stays palette-based;
263
JPEG is always truecolor. */
264
BGD_DECLARE(gdImagePtr) gdImageCreateFromPng (FILE * fd);
265
BGD_DECLARE(gdImagePtr) gdImageCreateFromPngCtx (gdIOCtxPtr in);
266
BGD_DECLARE(gdImagePtr) gdImageCreateFromPngPtr (int size, void *data);
268
/* These read the first frame only */
269
BGD_DECLARE(gdImagePtr) gdImageCreateFromGif (FILE * fd);
270
BGD_DECLARE(gdImagePtr) gdImageCreateFromGifCtx (gdIOCtxPtr in);
271
BGD_DECLARE(gdImagePtr) gdImageCreateFromGifPtr (int size, void *data);
272
BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMP (FILE * inFile);
273
BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPCtx (gdIOCtx * infile);
274
BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPPtr (int size, void *data);
275
BGD_DECLARE(gdImagePtr) gdImageCreateFromJpeg (FILE * infile);
276
BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegCtx (gdIOCtx * infile);
277
BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtr (int size, void *data);
279
/* A custom data source. */
280
/* The source function must return -1 on error, otherwise the number
281
of bytes fetched. 0 is EOF, not an error! */
282
/* context will be passed to your source function. */
286
int (*source) (void *context, char *buffer, int len);
289
gdSource, *gdSourcePtr;
291
/* Deprecated in favor of gdImageCreateFromPngCtx */
292
BGD_DECLARE(gdImagePtr) gdImageCreateFromPngSource (gdSourcePtr in);
294
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd (FILE * in);
295
BGD_DECLARE(gdImagePtr) gdImageCreateFromGdCtx (gdIOCtxPtr in);
296
BGD_DECLARE(gdImagePtr) gdImageCreateFromGdPtr (int size, void *data);
298
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2 (FILE * in);
299
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in);
300
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ptr (int size, void *data);
302
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Part (FILE * in, int srcx, int srcy, int w,
304
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartCtx (gdIOCtxPtr in, int srcx, int srcy,
306
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartPtr (int size, void *data, int srcx, int srcy,
308
/* 2.0.10: prototype was missing */
309
BGD_DECLARE(gdImagePtr) gdImageCreateFromXbm (FILE * in);
311
/* NOTE: filename, not FILE */
312
BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm (char *filename);
314
BGD_DECLARE(void) gdImageDestroy (gdImagePtr im);
316
/* Replaces or blends with the background depending on the
317
most recent call to gdImageAlphaBlending and the
318
alpha channel value of 'color'; default is to overwrite.
319
Tiling and line styling are also implemented
320
here. All other gd drawing functions pass through this call,
321
allowing for many useful effects. */
323
BGD_DECLARE(void) gdImageSetPixel (gdImagePtr im, int x, int y, int color);
324
/* FreeType 2 text output with hook to extra flags */
326
BGD_DECLARE(int) gdImageGetPixel (gdImagePtr im, int x, int y);
327
BGD_DECLARE(int) gdImageGetTrueColorPixel (gdImagePtr im, int x, int y);
329
BGD_DECLARE(void) gdImageAABlend (gdImagePtr im);
331
BGD_DECLARE(void) gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color);
333
/* For backwards compatibility only. Use gdImageSetStyle()
334
for much more flexible line drawing. */
335
BGD_DECLARE(void) gdImageDashedLine (gdImagePtr im, int x1, int y1, int x2, int y2,
337
/* Corners specified (not width and height). Upper left first, lower right
339
BGD_DECLARE(void) gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2,
341
/* Solid bar. Upper left corner first, lower right corner second. */
342
BGD_DECLARE(void) gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2,
344
BGD_DECLARE(void) gdImageSetClip(gdImagePtr im, int x1, int y1, int x2, int y2);
345
BGD_DECLARE(void) gdImageGetClip(gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P);
346
BGD_DECLARE(int) gdImageBoundsSafe (gdImagePtr im, int x, int y);
347
BGD_DECLARE(void) gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c,
349
BGD_DECLARE(void) gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c,
351
BGD_DECLARE(void) gdImageString (gdImagePtr im, gdFontPtr f, int x, int y,
352
unsigned char *s, int color);
353
BGD_DECLARE(void) gdImageStringUp (gdImagePtr im, gdFontPtr f, int x, int y,
354
unsigned char *s, int color);
355
BGD_DECLARE(void) gdImageString16 (gdImagePtr im, gdFontPtr f, int x, int y,
356
unsigned short *s, int color);
357
BGD_DECLARE(void) gdImageStringUp16 (gdImagePtr im, gdFontPtr f, int x, int y,
358
unsigned short *s, int color);
360
/* 2.0.16: for thread-safe use of gdImageStringFT and friends,
361
call this before allowing any thread to call gdImageStringFT.
362
Otherwise it is invoked by the first thread to invoke
363
gdImageStringFT, with a very small but real risk of a race condition.
364
Return 0 on success, nonzero on failure to initialize freetype. */
365
BGD_DECLARE(int) gdFontCacheSetup (void);
367
/* Optional: clean up after application is done using fonts in
368
BGD_DECLARE( ) gdImageStringFT(). */
369
BGD_DECLARE(void) gdFontCacheShutdown (void);
370
/* 2.0.20: for backwards compatibility. A few applications did start calling
371
this function when it first appeared although it was never documented.
372
Simply invokes gdFontCacheShutdown. */
373
BGD_DECLARE(void) gdFreeFontCache (void);
375
/* Calls gdImageStringFT. Provided for backwards compatibility only. */
376
BGD_DECLARE(char *) gdImageStringTTF (gdImage * im, int *brect, int fg, char *fontlist,
377
double ptsize, double angle, int x, int y,
380
/* FreeType 2 text output */
381
BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
382
double ptsize, double angle, int x, int y,
385
/* 2.0.5: provides an extensible way to pass additional parameters.
386
Thanks to Wez Furlong, sorry for the delay. */
390
int flags; /* Logical OR of gdFTEX_ values */
391
double linespacing; /* fine tune line spacing for '\n' */
392
int charmap; /* TBB: 2.0.12: may be gdFTEX_Unicode,
393
gdFTEX_Shift_JIS, or gdFTEX_Big5;
394
when not specified, maps are searched
395
for in the above order. */
396
int hdpi; /* if (flags & gdFTEX_RESOLUTION) */
397
int vdpi; /* if (flags & gdFTEX_RESOLUTION) */
398
char *xshow; /* if (flags & gdFTEX_XSHOW)
399
then, on return, xshow is a malloc'ed
400
string contining xshow position data for
403
NB. The caller is responsible for gdFree'ing
406
char *fontpath; /* if (flags & gdFTEX_RETURNFONTPATHNAME)
407
then, on return, fontpath is a malloc'ed
408
string containing the actual font file path name
409
used, which can be interesting when fontconfig
412
The caller is responsible for gdFree'ing the
417
gdFTStringExtra, *gdFTStringExtraPtr;
419
#define gdFTEX_LINESPACE 1
420
#define gdFTEX_CHARMAP 2
421
#define gdFTEX_RESOLUTION 4
422
#define gdFTEX_DISABLE_KERNING 8
423
#define gdFTEX_XSHOW 16
424
/* The default unless gdFTUseFontConfig(1); has been called:
425
fontlist is a full or partial font file pathname or list thereof
426
(i.e. just like before 2.0.29) */
427
#define gdFTEX_FONTPATHNAME 32
428
/* Necessary to use fontconfig patterns instead of font pathnames
429
as the fontlist argument, unless gdFTUseFontConfig(1); has
430
been called. New in 2.0.29 */
431
#define gdFTEX_FONTCONFIG 64
432
/* Sometimes interesting when fontconfig is used: the fontpath
433
element of the structure above will contain a gdMalloc'd string
434
copy of the actual font file pathname used, if this flag is set
435
when the call is made */
436
#define gdFTEX_RETURNFONTPATHNAME 128
438
/* If flag is nonzero, the fontlist parameter to gdImageStringFT
439
and gdImageStringFTEx shall be assumed to be a fontconfig font pattern
440
if fontconfig was compiled into gd. This function returns zero
441
if fontconfig is not available, nonzero otherwise. */
442
BGD_DECLARE(int) gdFTUseFontConfig(int flag);
444
/* These are NOT flags; set one in 'charmap' if you set the
445
gdFTEX_CHARMAP bit in 'flags'. */
446
#define gdFTEX_Unicode 0
447
#define gdFTEX_Shift_JIS 1
448
#define gdFTEX_Big5 2
450
BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
451
double ptsize, double angle, int x, int y,
452
char *string, gdFTStringExtraPtr strex);
454
/* Point type for use in polygon drawing. */
459
gdPoint, *gdPointPtr;
461
BGD_DECLARE(void) gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c);
462
BGD_DECLARE(void) gdImageOpenPolygon (gdImagePtr im, gdPointPtr p, int n, int c);
463
BGD_DECLARE(void) gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c);
465
/* These functions still work with truecolor images,
466
for which they never return error. */
467
BGD_DECLARE(int) gdImageColorAllocate (gdImagePtr im, int r, int g, int b);
468
/* gd 2.0: palette entries with non-opaque transparency are permitted. */
469
BGD_DECLARE(int) gdImageColorAllocateAlpha (gdImagePtr im, int r, int g, int b, int a);
470
/* Assumes opaque is the preferred alpha channel value */
471
BGD_DECLARE(int) gdImageColorClosest (gdImagePtr im, int r, int g, int b);
472
/* Closest match taking all four parameters into account.
473
A slightly different color with the same transparency
474
beats the exact same color with radically different
476
BGD_DECLARE(int) gdImageColorClosestAlpha (gdImagePtr im, int r, int g, int b, int a);
477
/* An alternate method */
478
BGD_DECLARE(int) gdImageColorClosestHWB (gdImagePtr im, int r, int g, int b);
479
/* Returns exact, 100% opaque matches only */
480
BGD_DECLARE(int) gdImageColorExact (gdImagePtr im, int r, int g, int b);
481
/* Returns an exact match only, including alpha */
482
BGD_DECLARE(int) gdImageColorExactAlpha (gdImagePtr im, int r, int g, int b, int a);
484
BGD_DECLARE(int) gdImageColorResolve (gdImagePtr im, int r, int g, int b);
485
/* Based on gdImageColorExactAlpha and gdImageColorClosestAlpha */
486
BGD_DECLARE(int) gdImageColorResolveAlpha (gdImagePtr im, int r, int g, int b, int a);
488
/* A simpler way to obtain an opaque truecolor value for drawing on a
489
truecolor image. Not for use with palette images! */
491
#define gdTrueColor(r, g, b) (((r) << 16) + \
495
/* Returns a truecolor value with an alpha channel component.
496
gdAlphaMax (127, **NOT 255**) is transparent, 0 is completely
499
#define gdTrueColorAlpha(r, g, b, a) (((a) << 24) + \
504
BGD_DECLARE(void) gdImageColorDeallocate (gdImagePtr im, int color);
506
/* Converts a truecolor image to a palette-based image,
507
using a high-quality two-pass quantization routine
508
which attempts to preserve alpha channel information
509
as well as R/G/B color information when creating
510
a palette. If ditherFlag is set, the image will be
511
dithered to approximate colors better, at the expense
512
of some obvious "speckling." colorsWanted can be
513
anything up to 256. If the original source image
514
includes photographic information or anything that
515
came out of a JPEG, 256 is strongly recommended.
517
Better yet, don't use these function -- write real
518
truecolor PNGs and JPEGs. The disk space gain of
519
conversion to palette is not great (for small images
520
it can be negative) and the quality loss is ugly.
522
DIFFERENCES: gdImageCreatePaletteFromTrueColor creates and
523
returns a new image. gdImageTrueColorToPalette modifies
524
an existing image, and the truecolor pixels are discarded. */
526
BGD_DECLARE(gdImagePtr) gdImageCreatePaletteFromTrueColor (gdImagePtr im, int ditherFlag,
529
BGD_DECLARE(void) gdImageTrueColorToPalette (gdImagePtr im, int ditherFlag,
532
/* Specifies a color index (if a palette image) or an
533
RGB color (if a truecolor image) which should be
534
considered 100% transparent. FOR TRUECOLOR IMAGES,
535
THIS IS IGNORED IF AN ALPHA CHANNEL IS BEING
536
SAVED. Use gdImageSaveAlpha(im, 0); to
537
turn off the saving of a full alpha channel in
538
a truecolor image. Note that gdImageColorTransparent
539
is usually compatible with older browsers that
540
do not understand full alpha channels well. TBB */
541
BGD_DECLARE(void) gdImageColorTransparent (gdImagePtr im, int color);
543
BGD_DECLARE(void) gdImagePaletteCopy (gdImagePtr dst, gdImagePtr src);
544
BGD_DECLARE(void) gdImageGif (gdImagePtr im, FILE * out);
545
BGD_DECLARE(void) gdImagePng (gdImagePtr im, FILE * out);
546
BGD_DECLARE(void) gdImagePngCtx (gdImagePtr im, gdIOCtx * out);
547
BGD_DECLARE(void) gdImageGifCtx (gdImagePtr im, gdIOCtx * out);
549
/* 2.0.12: Compression level: 0-9 or -1, where 0 is NO COMPRESSION at all,
550
1 is FASTEST but produces larger files, 9 provides the best
551
compression (smallest files) but takes a long time to compress, and
552
-1 selects the default compiled into the zlib library. */
553
BGD_DECLARE(void) gdImagePngEx (gdImagePtr im, FILE * out, int level);
554
BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * out, int level);
556
BGD_DECLARE(void) gdImageWBMP (gdImagePtr image, int fg, FILE * out);
557
BGD_DECLARE(void) gdImageWBMPCtx (gdImagePtr image, int fg, gdIOCtx * out);
559
/* Guaranteed to correctly free memory returned
560
by the gdImage*Ptr functions */
561
BGD_DECLARE(void) gdFree (void *m);
563
/* Best to free this memory with gdFree(), not free() */
564
BGD_DECLARE(void *) gdImageWBMPPtr (gdImagePtr im, int *size, int fg);
566
/* 100 is highest quality (there is always a little loss with JPEG).
567
0 is lowest. 10 is about the lowest useful setting. */
568
BGD_DECLARE(void) gdImageJpeg (gdImagePtr im, FILE * out, int quality);
569
BGD_DECLARE(void) gdImageJpegCtx (gdImagePtr im, gdIOCtx * out, int quality);
571
/* Best to free this memory with gdFree(), not free() */
572
BGD_DECLARE(void *) gdImageJpegPtr (gdImagePtr im, int *size, int quality);
574
/* Legal values for Disposal. gdDisposalNone is always used by
575
the built-in optimizer if previm is passed. */
580
gdDisposalRestoreBackground,
581
gdDisposalRestorePrevious
584
BGD_DECLARE(void) gdImageGifAnimBegin(gdImagePtr im, FILE *outFile, int GlobalCM, int Loops);
585
BGD_DECLARE(void) gdImageGifAnimAdd(gdImagePtr im, FILE *outFile, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm);
586
BGD_DECLARE(void) gdImageGifAnimEnd(FILE *outFile);
587
BGD_DECLARE(void) gdImageGifAnimBeginCtx(gdImagePtr im, gdIOCtx *out, int GlobalCM, int Loops);
588
BGD_DECLARE(void) gdImageGifAnimAddCtx(gdImagePtr im, gdIOCtx *out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm);
589
BGD_DECLARE(void) gdImageGifAnimEndCtx(gdIOCtx *out);
590
BGD_DECLARE(void *) gdImageGifAnimBeginPtr(gdImagePtr im, int *size, int GlobalCM, int Loops);
591
BGD_DECLARE(void *) gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm);
592
BGD_DECLARE(void *) gdImageGifAnimEndPtr(int *size);
594
/* A custom data sink. For backwards compatibility. Use
596
/* The sink function must return -1 on error, otherwise the number
597
of bytes written, which must be equal to len. */
598
/* context will be passed to your sink function. */
601
int (*sink) (void *context, const char *buffer, int len);
606
BGD_DECLARE(void) gdImagePngToSink (gdImagePtr im, gdSinkPtr out);
608
BGD_DECLARE(void) gdImageGd (gdImagePtr im, FILE * out);
609
BGD_DECLARE(void) gdImageGd2 (gdImagePtr im, FILE * out, int cs, int fmt);
611
/* Best to free this memory with gdFree(), not free() */
612
BGD_DECLARE(void *) gdImageGifPtr (gdImagePtr im, int *size);
614
/* Best to free this memory with gdFree(), not free() */
615
BGD_DECLARE(void *) gdImagePngPtr (gdImagePtr im, int *size);
616
BGD_DECLARE(void *) gdImagePngPtrEx (gdImagePtr im, int *size, int level);
618
/* Best to free this memory with gdFree(), not free() */
619
BGD_DECLARE(void *) gdImageGdPtr (gdImagePtr im, int *size);
621
/* Best to free this memory with gdFree(), not free() */
622
BGD_DECLARE(void *) gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size);
624
BGD_DECLARE(void) gdImageEllipse (gdImagePtr im, int cx, int cy, int w, int h,
627
/* Style is a bitwise OR ( | operator ) of these.
628
gdArc and gdChord are mutually exclusive;
629
gdChord just connects the starting and ending
630
angles with a straight line, while gdArc produces
631
a rounded edge. gdPie is a synonym for gdArc.
632
gdNoFill indicates that the arc or chord should be
633
outlined, not filled. gdEdged, used together with
634
gdNoFill, indicates that the beginning and ending
635
angles should be connected to the center; this is
636
a good way to outline (rather than fill) a
644
BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s,
645
int e, int color, int style);
646
BGD_DECLARE(void) gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e,
648
BGD_DECLARE(void) gdImageFilledEllipse (gdImagePtr im, int cx, int cy, int w, int h,
650
BGD_DECLARE(void) gdImageFillToBorder (gdImagePtr im, int x, int y, int border,
652
BGD_DECLARE(void) gdImageFill (gdImagePtr im, int x, int y, int color);
653
BGD_DECLARE(void) gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
654
int srcX, int srcY, int w, int h);
655
BGD_DECLARE(void) gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
656
int srcX, int srcY, int w, int h, int pct);
657
BGD_DECLARE(void) gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX,
658
int dstY, int srcX, int srcY, int w, int h,
661
/* Stretches or shrinks to fit, as needed. Does NOT attempt
662
to average the entire set of source pixels that scale down onto the
663
destination pixel. */
664
BGD_DECLARE(void) gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
665
int srcX, int srcY, int dstW, int dstH, int srcW,
668
/* gd 2.0: stretches or shrinks to fit, as needed. When called with a
669
truecolor destination image, this function averages the
670
entire set of source pixels that scale down onto the
671
destination pixel, taking into account what portion of the
672
destination pixel each source pixel represents. This is a
673
floating point operation, but this is not a performance issue
674
on modern hardware, except for some embedded devices. If the
675
destination is a palette image, gdImageCopyResized is
676
substituted automatically. */
677
BGD_DECLARE(void) gdImageCopyResampled (gdImagePtr dst, gdImagePtr src, int dstX,
678
int dstY, int srcX, int srcY, int dstW, int dstH,
681
/* gd 2.0.8: gdImageCopyRotated is added. Source
682
is a rectangle, with its upper left corner at
683
srcX and srcY. Destination is the *center* of
684
the rotated copy. Angle is in degrees, same as
685
gdImageArc. Floating point destination center
686
coordinates allow accurate rotation of
687
objects of odd-numbered width or height. */
688
BGD_DECLARE(void) gdImageCopyRotated (gdImagePtr dst,
690
double dstX, double dstY,
692
int srcWidth, int srcHeight, int angle);
694
BGD_DECLARE(void) gdImageSetBrush (gdImagePtr im, gdImagePtr brush);
695
BGD_DECLARE(void) gdImageSetTile (gdImagePtr im, gdImagePtr tile);
696
BGD_DECLARE(void) gdImageSetAntiAliased (gdImagePtr im, int c);
697
BGD_DECLARE(void) gdImageSetAntiAliasedDontBlend (gdImagePtr im, int c, int dont_blend);
698
BGD_DECLARE(void) gdImageSetStyle (gdImagePtr im, int *style, int noOfPixels);
699
/* Line thickness (defaults to 1). Affects lines, ellipses,
700
rectangles, polygons and so forth. */
701
BGD_DECLARE(void) gdImageSetThickness (gdImagePtr im, int thickness);
702
/* On or off (1 or 0) for all three of these. */
703
BGD_DECLARE(void) gdImageInterlace (gdImagePtr im, int interlaceArg);
704
BGD_DECLARE(void) gdImageAlphaBlending (gdImagePtr im, int alphaBlendingArg);
705
BGD_DECLARE(void) gdImageSaveAlpha (gdImagePtr im, int saveAlphaArg);
707
/* Macros to access information about images. */
709
/* Returns nonzero if the image is a truecolor image,
710
zero for a palette image. */
712
#define gdImageTrueColor(im) ((im)->trueColor)
714
#define gdImageSX(im) ((im)->sx)
715
#define gdImageSY(im) ((im)->sy)
716
#define gdImageColorsTotal(im) ((im)->colorsTotal)
717
#define gdImageRed(im, c) ((im)->trueColor ? gdTrueColorGetRed(c) : \
719
#define gdImageGreen(im, c) ((im)->trueColor ? gdTrueColorGetGreen(c) : \
721
#define gdImageBlue(im, c) ((im)->trueColor ? gdTrueColorGetBlue(c) : \
723
#define gdImageAlpha(im, c) ((im)->trueColor ? gdTrueColorGetAlpha(c) : \
725
#define gdImageGetTransparent(im) ((im)->transparent)
726
#define gdImageGetInterlaced(im) ((im)->interlace)
728
/* These macros provide direct access to pixels in
729
palette-based and truecolor images, respectively.
730
If you use these macros, you must perform your own
731
bounds checking. Use of the macro for the correct type
732
of image is also your responsibility. */
733
#define gdImagePalettePixel(im, x, y) (im)->pixels[(y)][(x)]
734
#define gdImageTrueColorPixel(im, x, y) (im)->tpixels[(y)][(x)]
736
/* I/O Support routines. */
738
BGD_DECLARE(gdIOCtx *) gdNewFileCtx (FILE *);
739
/* If data is null, size is ignored and an initial data buffer is
740
allocated automatically. NOTE: this function assumes gd has the right
741
to free or reallocate "data" at will! Also note that gd will free
742
"data" when the IO context is freed. If data is not null, it must point
743
to memory allocated with gdMalloc, or by a call to gdImage[something]Ptr.
744
If not, see gdNewDynamicCtxEx for an alternative. */
745
BGD_DECLARE(gdIOCtx *) gdNewDynamicCtx (int size, void *data);
746
/* 2.0.21: if freeFlag is nonzero, gd will free and/or reallocate "data" as
747
needed as described above. If freeFlag is zero, gd will never free
748
or reallocate "data," which means that the context should only be used
749
for *reading* an image from a memory buffer, or writing an image to a
750
memory buffer which is already large enough. If the memory buffer is
751
not large enough and an image write is attempted, the write operation
752
will fail. Those wishing to write an image to a buffer in memory have
753
a much simpler alternative in the gdImage[something]Ptr functions. */
754
BGD_DECLARE(gdIOCtx *) gdNewDynamicCtxEx (int size, void *data, int freeFlag);
755
BGD_DECLARE(gdIOCtx *) gdNewSSCtx (gdSourcePtr in, gdSinkPtr out);
756
BGD_DECLARE(void *) gdDPExtractData (struct gdIOCtx *ctx, int *size);
758
#define GD2_CHUNKSIZE 128
759
#define GD2_CHUNKSIZE_MIN 64
760
#define GD2_CHUNKSIZE_MAX 4096
765
#define GD2_FMT_RAW 1
766
#define GD2_FMT_COMPRESSED 2
768
/* Image comparison definitions */
769
BGD_DECLARE(int) gdImageCompare (gdImagePtr im1, gdImagePtr im2);
771
#define GD_CMP_IMAGE 1 /* Actual image IS different */
772
#define GD_CMP_NUM_COLORS 2 /* Number of Colours in pallette differ */
773
#define GD_CMP_COLOR 4 /* Image colours differ */
774
#define GD_CMP_SIZE_X 8 /* Image width differs */
775
#define GD_CMP_SIZE_Y 16 /* Image heights differ */
776
#define GD_CMP_TRANSPARENT 32 /* Transparent colour */
777
#define GD_CMP_BACKGROUND 64 /* Background colour */
778
#define GD_CMP_INTERLACE 128 /* Interlaced setting */
779
#define GD_CMP_TRUECOLOR 256 /* Truecolor vs palette differs */
781
/* resolution affects ttf font rendering, particularly hinting */
782
#define GD_RESOLUTION 96 /* pixels per inch */
788
/* newfangled special effects */