~ubuntu-branches/ubuntu/jaunty/texlive-bin/jaunty-security

« back to all changes in this revision

Viewing changes to build/source/libs/gd/gd.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2008-06-26 23:14:59 UTC
  • mfrom: (2.1.30 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080626231459-y02rjsrgtafu83yr
Tags: 2007.dfsg.2-3
add missing source roadmap.fig of roadmap.eps in fontinst documentation
(Closes: #482915) (urgency medium due to RC bug)
(new patch add-missing-fontinst-source)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifdef __cplusplus
 
2
extern "C" {
 
3
#endif
 
4
 
 
5
#ifndef GD_H
 
6
#define GD_H 1
 
7
 
 
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). */
 
11
 
 
12
/* 2.0.20: for headers */
 
13
 
 
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. */
 
17
 
 
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. */
 
21
 
 
22
#ifndef WIN32
 
23
#define NONDLL 1
 
24
#endif /* WIN32 */
 
25
 
 
26
#ifdef NONDLL
 
27
#define BGD_DECLARE(rt) extern rt
 
28
#else
 
29
#ifdef BGDWIN32
 
30
#define BGD_DECLARE(rt) __declspec(dllexport) rt __stdcall
 
31
#else
 
32
#define BGD_DECLARE(rt) __declspec(dllimport) rt _stdcall
 
33
#endif /* BGDWIN32 */
 
34
#endif /* NONDLL */
 
35
 
 
36
/* 2.0.20: for actual storage of exported data, functions don't need this,
 
37
  currently needed only for font pointers */
 
38
#ifdef NONDLL
 
39
/* 2.0.25: bring back extern */
 
40
#define BGD_EXPORT_DATA_PROT extern
 
41
#define BGD_EXPORT_DATA_IMPL
 
42
#else
 
43
#ifdef BGDWIN32
 
44
#define BGD_EXPORT_DATA_PROT __declspec(dllexport) extern
 
45
#define BGD_EXPORT_DATA_IMPL __declspec(dllexport)
 
46
#else
 
47
#define BGD_EXPORT_DATA_PROT __declspec(dllimport) extern
 
48
#define BGD_EXPORT_DATA_IMPL __declspec(dllimport) 
 
49
#endif /* BGDWIN32 */
 
50
#endif /* NONDLL */
 
51
 
 
52
#ifdef __cplusplus
 
53
extern "C"
 
54
{
 
55
#endif
 
56
 
 
57
/* some might want to set DEFAULT_FONTPATH from configure in config.h */
 
58
 
 
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"
 
63
#endif
 
64
#ifndef PATHSEPARATOR
 
65
#define PATHSEPARATOR ":"
 
66
#endif
 
67
 
 
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
 
77
 * documentation. */
 
78
 
 
79
/* stdio is needed for file I/O. */
 
80
#include <stdio.h>
 
81
#include "gd_io.h"
 
82
 
 
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. */
 
86
 
 
87
#define gdMaxColors 256
 
88
 
 
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. */
 
93
 
 
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. 
 
97
 
 
98
        True colors are repsented as follows:
 
99
 
 
100
        ARGB
 
101
 
 
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. */
 
109
 
 
110
#define gdAlphaMax 127
 
111
#define gdAlphaOpaque 0
 
112
#define gdAlphaTransparent 127
 
113
#define gdRedMax 255
 
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)
 
120
 
 
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. */
 
125
 
 
126
   BGD_DECLARE(int) gdAlphaBlend (int dest, int src);
 
127
 
 
128
  typedef struct gdImageStruct
 
129
  {
 
130
    /* Palette-based image pixels */
 
131
    unsigned char **pixels;
 
132
    int sx;
 
133
    int sy;
 
134
    /* These are valid in palette images only. See also
 
135
       'alpha', which appears later in the structure to
 
136
       preserve binary backwards compatibility */
 
137
    int colorsTotal;
 
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. */
 
152
    int transparent;
 
153
    int *polyInts;
 
154
    int polyAllocated;
 
155
    struct gdImageStruct *brush;
 
156
    struct gdImageStruct *tile;
 
157
    int brushColorMap[gdMaxColors];
 
158
    int tileColorMap[gdMaxColors];
 
159
    int styleLength;
 
160
    int stylePos;
 
161
    int *style;
 
162
    int interlace;
 
163
    /* New in 2.0: thickness of line. Initialized to 1. */
 
164
    int thick;
 
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
 
172
       in between. TBB */
 
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. */
 
176
    int trueColor;
 
177
    int **tpixels;
 
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. */
 
188
    int saveAlphaFlag;
 
189
 
 
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. */
 
192
 
 
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. */
 
195
    int AA;
 
196
    int AA_color;
 
197
    int AA_dont_blend;
 
198
 
 
199
    /* 2.0.12: simple clipping rectangle. These values
 
200
      must be checked for safety when set; please use
 
201
      gdImageSetClip */
 
202
    int cx1;
 
203
    int cy1;
 
204
    int cx2;
 
205
    int cy2;
 
206
  }
 
207
  gdImage;
 
208
 
 
209
  typedef gdImage *gdImagePtr;
 
210
 
 
211
  typedef struct
 
212
  {
 
213
    /* # of characters in font */
 
214
    int nchars;
 
215
    /* First character is numbered... (usually 32 = space) */
 
216
    int offset;
 
217
    /* Character width and height */
 
218
    int w;
 
219
    int h;
 
220
    /* Font data; array of characters, one row after another.
 
221
       Easily included in code, also easily loaded from
 
222
       data files. */
 
223
    char *data;
 
224
  }
 
225
  gdFont;
 
226
 
 
227
/* Text functions take these. */
 
228
  typedef gdFont *gdFontPtr;
 
229
 
 
230
/* For backwards compatibility only. Use gdImageSetStyle()
 
231
        for MUCH more flexible line drawing. Also see
 
232
        gdImageSetBrush(). */
 
233
#define gdDashSize 4
 
234
 
 
235
/* Special colors. */
 
236
 
 
237
#define gdStyled (-2)
 
238
#define gdBrushed (-3)
 
239
#define gdStyledBrushed (-4)
 
240
#define gdTiled (-5)
 
241
 
 
242
/* NOT the same as the transparent color index.
 
243
        This is used in line styles only. */
 
244
#define gdTransparent (-6)
 
245
 
 
246
#define gdAntiAliased (-7)
 
247
 
 
248
/* Functions to manipulate images. */
 
249
 
 
250
/* Creates a palette-based image (up to 256 colors). */
 
251
BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy);
 
252
 
 
253
/* An alternate name for the above (2.0). */
 
254
#define gdImageCreatePalette gdImageCreate
 
255
 
 
256
/* Creates a truecolor image (millions of colors). */
 
257
BGD_DECLARE(gdImagePtr) gdImageCreateTrueColor (int sx, int sy);
 
258
 
 
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);
 
267
 
 
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);
 
278
 
 
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. */
 
283
 
 
284
  typedef struct
 
285
  {
 
286
    int (*source) (void *context, char *buffer, int len);
 
287
    void *context;
 
288
  }
 
289
  gdSource, *gdSourcePtr;
 
290
 
 
291
   /* Deprecated in favor of gdImageCreateFromPngCtx */
 
292
BGD_DECLARE(gdImagePtr) gdImageCreateFromPngSource (gdSourcePtr in);
 
293
 
 
294
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd (FILE * in);
 
295
BGD_DECLARE(gdImagePtr) gdImageCreateFromGdCtx (gdIOCtxPtr in);
 
296
BGD_DECLARE(gdImagePtr) gdImageCreateFromGdPtr (int size, void *data);
 
297
 
 
298
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2 (FILE * in);
 
299
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in);
 
300
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ptr (int size, void *data);
 
301
 
 
302
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Part (FILE * in, int srcx, int srcy, int w,
 
303
                                       int h);
 
304
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartCtx (gdIOCtxPtr in, int srcx, int srcy,
 
305
                                          int w, int h);
 
306
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartPtr (int size, void *data, int srcx, int srcy,
 
307
                                          int w, int h);
 
308
  /* 2.0.10: prototype was missing */
 
309
BGD_DECLARE(gdImagePtr) gdImageCreateFromXbm (FILE * in);
 
310
 
 
311
  /* NOTE: filename, not FILE */
 
312
BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm (char *filename);
 
313
 
 
314
BGD_DECLARE(void) gdImageDestroy (gdImagePtr im);
 
315
 
 
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. */
 
322
 
 
323
BGD_DECLARE(void) gdImageSetPixel (gdImagePtr im, int x, int y, int color);
 
324
/* FreeType 2 text output with hook to extra flags */
 
325
 
 
326
BGD_DECLARE(int) gdImageGetPixel (gdImagePtr im, int x, int y);
 
327
BGD_DECLARE(int) gdImageGetTrueColorPixel (gdImagePtr im, int x, int y);
 
328
 
 
329
BGD_DECLARE(void) gdImageAABlend (gdImagePtr im);
 
330
 
 
331
BGD_DECLARE(void) gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color);
 
332
 
 
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,
 
336
                          int color);
 
337
/* Corners specified (not width and height). Upper left first, lower right
 
338
        second. */
 
339
BGD_DECLARE(void) gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2,
 
340
                         int color);
 
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,
 
343
                               int color);
 
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,
 
348
                    int color);
 
349
BGD_DECLARE(void) gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c,
 
350
                      int color);
 
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);
 
359
 
 
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);
 
366
 
 
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);
 
374
 
 
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,
 
378
                          char *string);
 
379
 
 
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,
 
383
                         char *string);
 
384
 
 
385
/* 2.0.5: provides an extensible way to pass additional parameters.
 
386
        Thanks to Wez Furlong, sorry for the delay. */
 
387
 
 
388
  typedef struct
 
389
  {
 
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
 
401
                           the last string.
 
402
 
 
403
                           NB. The caller is responsible for gdFree'ing
 
404
                           the xshow string. 
 
405
                         */
 
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
 
410
                           is in use. 
 
411
 
 
412
                           The caller is responsible for gdFree'ing the
 
413
                           fontpath string.
 
414
                        */
 
415
 
 
416
  }
 
417
  gdFTStringExtra, *gdFTStringExtraPtr;
 
418
 
 
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
 
437
 
 
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);
 
443
 
 
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
 
449
 
 
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);
 
453
 
 
454
/* Point type for use in polygon drawing. */
 
455
  typedef struct
 
456
  {
 
457
    int x, y;
 
458
  }
 
459
  gdPoint, *gdPointPtr;
 
460
 
 
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);
 
464
 
 
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
 
475
        transparency */
 
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);
 
483
/* Opaque only */
 
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);
 
487
 
 
488
/* A simpler way to obtain an opaque truecolor value for drawing on a
 
489
        truecolor image. Not for use with palette images! */
 
490
 
 
491
#define gdTrueColor(r, g, b) (((r) << 16) + \
 
492
        ((g) << 8) + \
 
493
        (b))
 
494
 
 
495
/* Returns a truecolor value with an alpha channel component.
 
496
        gdAlphaMax (127, **NOT 255**) is transparent, 0 is completely
 
497
        opaque. */
 
498
 
 
499
#define gdTrueColorAlpha(r, g, b, a) (((a) << 24) + \
 
500
        ((r) << 16) + \
 
501
        ((g) << 8) + \
 
502
        (b))
 
503
 
 
504
BGD_DECLARE(void) gdImageColorDeallocate (gdImagePtr im, int color);
 
505
 
 
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.
 
516
 
 
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. 
 
521
 
 
522
        DIFFERENCES: gdImageCreatePaletteFromTrueColor creates and
 
523
        returns a new image. gdImageTrueColorToPalette modifies 
 
524
        an existing image, and the truecolor pixels are discarded. */
 
525
 
 
526
BGD_DECLARE(gdImagePtr) gdImageCreatePaletteFromTrueColor (gdImagePtr im, int ditherFlag,
 
527
                                  int colorsWanted);
 
528
 
 
529
BGD_DECLARE(void) gdImageTrueColorToPalette (gdImagePtr im, int ditherFlag,
 
530
                                  int colorsWanted);
 
531
 
 
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);
 
542
 
 
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);
 
548
 
 
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);
 
555
 
 
556
BGD_DECLARE(void) gdImageWBMP (gdImagePtr image, int fg, FILE * out);
 
557
BGD_DECLARE(void) gdImageWBMPCtx (gdImagePtr image, int fg, gdIOCtx * out);
 
558
 
 
559
/* Guaranteed to correctly free memory returned
 
560
        by the gdImage*Ptr functions */
 
561
BGD_DECLARE(void) gdFree (void *m);
 
562
 
 
563
/* Best to free this memory with gdFree(), not free() */
 
564
BGD_DECLARE(void *) gdImageWBMPPtr (gdImagePtr im, int *size, int fg);
 
565
 
 
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);
 
570
 
 
571
/* Best to free this memory with gdFree(), not free() */
 
572
BGD_DECLARE(void *) gdImageJpegPtr (gdImagePtr im, int *size, int quality);
 
573
 
 
574
/* Legal values for Disposal. gdDisposalNone is always used by
 
575
        the built-in optimizer if previm is passed. */
 
576
 
 
577
enum {
 
578
        gdDisposalUnknown,
 
579
        gdDisposalNone,
 
580
        gdDisposalRestoreBackground,
 
581
        gdDisposalRestorePrevious
 
582
};
 
583
 
 
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);
 
593
 
 
594
/* A custom data sink. For backwards compatibility. Use
 
595
        gdIOCtx instead. */
 
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. */
 
599
  typedef struct
 
600
  {
 
601
    int (*sink) (void *context, const char *buffer, int len);
 
602
    void *context;
 
603
  }
 
604
  gdSink, *gdSinkPtr;
 
605
 
 
606
BGD_DECLARE(void) gdImagePngToSink (gdImagePtr im, gdSinkPtr out);
 
607
 
 
608
BGD_DECLARE(void) gdImageGd (gdImagePtr im, FILE * out);
 
609
BGD_DECLARE(void) gdImageGd2 (gdImagePtr im, FILE * out, int cs, int fmt);
 
610
 
 
611
/* Best to free this memory with gdFree(), not free() */
 
612
BGD_DECLARE(void *) gdImageGifPtr (gdImagePtr im, int *size);
 
613
 
 
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);
 
617
 
 
618
/* Best to free this memory with gdFree(), not free() */
 
619
BGD_DECLARE(void *) gdImageGdPtr (gdImagePtr im, int *size);
 
620
 
 
621
/* Best to free this memory with gdFree(), not free() */
 
622
BGD_DECLARE(void *) gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size);
 
623
 
 
624
BGD_DECLARE(void) gdImageEllipse (gdImagePtr im, int cx, int cy, int w, int h,
 
625
                       int color);
 
626
 
 
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
 
637
        'pie slice'. */
 
638
#define gdArc   0
 
639
#define gdPie   gdArc
 
640
#define gdChord 1
 
641
#define gdNoFill 2
 
642
#define gdEdged 4
 
643
 
 
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,
 
647
                   int color);
 
648
BGD_DECLARE(void) gdImageFilledEllipse (gdImagePtr im, int cx, int cy, int w, int h,
 
649
                             int color);
 
650
BGD_DECLARE(void) gdImageFillToBorder (gdImagePtr im, int x, int y, int border,
 
651
                            int color);
 
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,
 
659
                             int pct);
 
660
 
 
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,
 
666
                           int srcH);
 
667
 
 
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,
 
679
                             int srcW, int srcH);
 
680
 
 
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,
 
689
                           gdImagePtr src,
 
690
                           double dstX, double dstY,
 
691
                           int srcX, int srcY,
 
692
                           int srcWidth, int srcHeight, int angle);
 
693
 
 
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);
 
706
 
 
707
/* Macros to access information about images. */
 
708
 
 
709
/* Returns nonzero if the image is a truecolor image,
 
710
        zero for a palette image. */
 
711
 
 
712
#define gdImageTrueColor(im) ((im)->trueColor)
 
713
 
 
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) : \
 
718
        (im)->red[(c)])
 
719
#define gdImageGreen(im, c) ((im)->trueColor ? gdTrueColorGetGreen(c) : \
 
720
        (im)->green[(c)])
 
721
#define gdImageBlue(im, c) ((im)->trueColor ? gdTrueColorGetBlue(c) : \
 
722
        (im)->blue[(c)])
 
723
#define gdImageAlpha(im, c) ((im)->trueColor ? gdTrueColorGetAlpha(c) : \
 
724
        (im)->alpha[(c)])
 
725
#define gdImageGetTransparent(im) ((im)->transparent)
 
726
#define gdImageGetInterlaced(im) ((im)->interlace)
 
727
 
 
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)]
 
735
 
 
736
/* I/O Support routines. */
 
737
 
 
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);
 
757
 
 
758
#define GD2_CHUNKSIZE           128
 
759
#define GD2_CHUNKSIZE_MIN       64
 
760
#define GD2_CHUNKSIZE_MAX       4096
 
761
 
 
762
#define GD2_VERS                2
 
763
#define GD2_ID                  "gd2"
 
764
 
 
765
#define GD2_FMT_RAW             1
 
766
#define GD2_FMT_COMPRESSED      2
 
767
 
 
768
/* Image comparison definitions */
 
769
BGD_DECLARE(int) gdImageCompare (gdImagePtr im1, gdImagePtr im2);
 
770
 
 
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 */
 
780
 
 
781
/* resolution affects ttf font rendering, particularly hinting */
 
782
#define GD_RESOLUTION           96      /* pixels per inch */
 
783
 
 
784
#ifdef __cplusplus
 
785
}
 
786
#endif
 
787
 
 
788
/* newfangled special effects */
 
789
#include "gdfx.h"
 
790
 
 
791
#endif                          /* GD_H */
 
792
 
 
793
#ifdef __cplusplus
 
794
}
 
795
#endif