Back to index

php5  5.3.10
gd.h
Go to the documentation of this file.
00001 #ifndef GD_H
00002 #define GD_H 1
00003 
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007 
00008 #ifdef HAVE_CONFIG_H
00009 #include "config.h"
00010 #endif
00011 
00012 #include "php_compat.h"
00013 
00014 #define GD_MAJOR_VERSION 2
00015 #define GD_MINOR_VERSION 0
00016 #define GD_RELEASE_VERSION 35
00017 #define GD_EXTRA_VERSION ""
00018 #define GD_VERSION_STRING "2.0.35"
00019 
00020 #ifdef NETWARE
00021 /* default fontpath for netware systems */
00022 #define DEFAULT_FONTPATH "sys:/java/nwgfx/lib/x11/fonts/ttf;."
00023 #define PATHSEPARATOR ";"
00024 #elif defined(WIN32)
00025 /* default fontpath for windows systems */
00026 #define DEFAULT_FONTPATH "c:\\winnt\\fonts;c:\\windows\\fonts;."
00027 #define PATHSEPARATOR ";"
00028 #else
00029 /* default fontpath for unix systems */
00030 #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:."
00031 #define PATHSEPARATOR ":"
00032 #endif
00033 
00034 /* gd.h: declarations file for the graphic-draw module.
00035  * Permission to use, copy, modify, and distribute this software and its
00036  * documentation for any purpose and without fee is hereby granted, provided
00037  * that the above copyright notice appear in all copies and that both that
00038  * copyright notice and this permission notice appear in supporting
00039  * documentation.  This software is provided "AS IS." Thomas Boutell and
00040  * Boutell.Com, Inc. disclaim all warranties, either express or implied,
00041  * including but not limited to implied warranties of merchantability and
00042  * fitness for a particular purpose, with respect to this code and accompanying
00043  * documentation. */
00044 
00045 /* stdio is needed for file I/O. */
00046 #include <stdio.h>
00047 #include "gd_io.h"
00048 
00049 void php_gd_error_ex(int type, const char *format, ...);
00050 
00051 void php_gd_error(const char *format, ...);
00052 
00053 
00054 /* The maximum number of palette entries in palette-based images.
00055        In the wonderful new world of gd 2.0, you can of course have
00056        many more colors when using truecolor mode. */
00057 
00058 #define gdMaxColors 256
00059 
00060 /* Image type. See functions below; you will not need to change
00061        the elements directly. Use the provided macros to
00062        access sx, sy, the color table, and colorsTotal for
00063        read-only purposes. */
00064 
00065 /* If 'truecolor' is set true, the image is truecolor;
00066        pixels are represented by integers, which
00067        must be 32 bits wide or more.
00068 
00069        True colors are repsented as follows:
00070 
00071        ARGB
00072 
00073        Where 'A' (alpha channel) occupies only the
00074        LOWER 7 BITS of the MSB. This very small
00075        loss of alpha channel resolution allows gd 2.x
00076        to keep backwards compatibility by allowing
00077        signed integers to be used to represent colors,
00078        and negative numbers to represent special cases,
00079        just as in gd 1.x. */
00080 
00081 #define gdAlphaMax 127
00082 #define gdAlphaOpaque 0
00083 #define gdAlphaTransparent 127
00084 #define gdRedMax 255
00085 #define gdGreenMax 255
00086 #define gdBlueMax 255
00087 #define gdTrueColorGetAlpha(c) (((c) & 0x7F000000) >> 24)
00088 #define gdTrueColorGetRed(c) (((c) & 0xFF0000) >> 16)
00089 #define gdTrueColorGetGreen(c) (((c) & 0x00FF00) >> 8)
00090 #define gdTrueColorGetBlue(c) ((c) & 0x0000FF)
00091 #define gdEffectReplace 0
00092 #define gdEffectAlphaBlend 1
00093 #define gdEffectNormal 2
00094 #define gdEffectOverlay 3
00095 
00096 
00097 /* This function accepts truecolor pixel values only. The
00098        source color is composited with the destination color
00099        based on the alpha channel value of the source color.
00100        The resulting color is opaque. */
00101 
00102 int gdAlphaBlend(int dest, int src);
00103 
00104 typedef struct gdImageStruct {
00105        /* Palette-based image pixels */
00106        unsigned char ** pixels;
00107        int sx;
00108        int sy;
00109        /* These are valid in palette images only. See also
00110               'alpha', which appears later in the structure to
00111               preserve binary backwards compatibility */
00112        int colorsTotal;
00113        int red[gdMaxColors];
00114        int green[gdMaxColors];
00115        int blue[gdMaxColors];
00116        int open[gdMaxColors];
00117        /* For backwards compatibility, this is set to the
00118               first palette entry with 100% transparency,
00119               and is also set and reset by the
00120               gdImageColorTransparent function. Newer
00121               applications can allocate palette entries
00122               with any desired level of transparency; however,
00123               bear in mind that many viewers, notably
00124               many web browsers, fail to implement
00125               full alpha channel for PNG and provide
00126               support for full opacity or transparency only. */
00127        int transparent;
00128        int *polyInts;
00129        int polyAllocated;
00130        struct gdImageStruct *brush;
00131        struct gdImageStruct *tile;
00132        int brushColorMap[gdMaxColors];
00133        int tileColorMap[gdMaxColors];
00134        int styleLength;
00135        int stylePos;
00136        int *style;
00137        int interlace;
00138        /* New in 2.0: thickness of line. Initialized to 1. */
00139        int thick;
00140        /* New in 2.0: alpha channel for palettes. Note that only
00141               Macintosh Internet Explorer and (possibly) Netscape 6
00142               really support multiple levels of transparency in
00143               palettes, to my knowledge, as of 2/15/01. Most
00144               common browsers will display 100% opaque and
00145               100% transparent correctly, and do something
00146               unpredictable and/or undesirable for levels
00147               in between. TBB */
00148        int alpha[gdMaxColors];
00149        /* Truecolor flag and pixels. New 2.0 fields appear here at the
00150               end to minimize breakage of existing object code. */
00151        int trueColor;
00152        int ** tpixels;
00153        /* Should alpha channel be copied, or applied, each time a
00154               pixel is drawn? This applies to truecolor images only.
00155               No attempt is made to alpha-blend in palette images,
00156               even if semitransparent palette entries exist.
00157               To do that, build your image as a truecolor image,
00158               then quantize down to 8 bits. */
00159        int alphaBlendingFlag;
00160        /* Should antialias functions be used */
00161        int antialias;
00162        /* Should the alpha channel of the image be saved? This affects
00163               PNG at the moment; other future formats may also
00164               have that capability. JPEG doesn't. */
00165        int saveAlphaFlag;
00166 
00167 
00168        /* 2.0.12: anti-aliased globals */
00169        int AA;
00170        int AA_color;
00171        int AA_dont_blend;
00172        unsigned char **AA_opacity;
00173        int AA_polygon;
00174        /* Stored and pre-computed variables for determining the perpendicular
00175         * distance from a point to the anti-aliased line being drawn:
00176         */
00177        int AAL_x1;
00178        int AAL_y1;
00179        int AAL_x2;
00180        int AAL_y2;
00181        int AAL_Bx_Ax;
00182        int AAL_By_Ay;
00183        int AAL_LAB_2;
00184        float AAL_LAB;
00185 
00186        /* 2.0.12: simple clipping rectangle. These values must be checked for safety when set; please use gdImageSetClip */
00187        int cx1;
00188        int cy1;
00189        int cx2;
00190        int cy2;
00191 } gdImage;
00192 
00193 typedef gdImage * gdImagePtr;
00194 
00195 typedef struct {
00196        /* # of characters in font */
00197        int nchars;
00198        /* First character is numbered... (usually 32 = space) */
00199        int offset;
00200        /* Character width and height */
00201        int w;
00202        int h;
00203        /* Font data; array of characters, one row after another.
00204               Easily included in code, also easily loaded from
00205               data files. */
00206        char *data;
00207 } gdFont;
00208 
00209 /* Text functions take these. */
00210 typedef gdFont *gdFontPtr;
00211 
00212 /* For backwards compatibility only. Use gdImageSetStyle()
00213        for MUCH more flexible line drawing. Also see
00214        gdImageSetBrush(). */
00215 #define gdDashSize 4
00216 
00217 /* Special colors. */
00218 
00219 #define gdStyled (-2)
00220 #define gdBrushed (-3)
00221 #define gdStyledBrushed (-4)
00222 #define gdTiled (-5)
00223 
00224 /* NOT the same as the transparent color index.
00225        This is used in line styles only. */
00226 #define gdTransparent (-6)
00227 
00228 #define gdAntiAliased (-7)
00229 
00230 /* Functions to manipulate images. */
00231 
00232 /* Creates a palette-based image (up to 256 colors). */
00233 gdImagePtr gdImageCreate(int sx, int sy);
00234 
00235 /* An alternate name for the above (2.0). */
00236 #define gdImageCreatePalette gdImageCreate
00237 
00238 /* Creates a truecolor image (millions of colors). */
00239 gdImagePtr gdImageCreateTrueColor(int sx, int sy);
00240 
00241 /* Creates an image from various file types. These functions
00242        return a palette or truecolor image based on the
00243        nature of the file being loaded. Truecolor PNG
00244        stays truecolor; palette PNG stays palette-based;
00245        JPEG is always truecolor. */
00246 gdImagePtr gdImageCreateFromPng(FILE *fd);
00247 gdImagePtr gdImageCreateFromPngCtx(gdIOCtxPtr in);
00248 gdImagePtr gdImageCreateFromWBMP(FILE *inFile);
00249 gdImagePtr gdImageCreateFromWBMPCtx(gdIOCtx *infile);
00250 gdImagePtr gdImageCreateFromJpeg(FILE *infile, int ignore_warning);
00251 gdImagePtr gdImageCreateFromJpegCtx(gdIOCtx *infile, int ignore_warning);
00252 
00253 int gdJpegGetVersionInt();
00254 const char * gdPngGetVersionString();
00255 
00256 int gdJpegGetVersionInt();
00257 const char * gdJpegGetVersionString();
00258 
00259 /* A custom data source. */
00260 /* The source function must return -1 on error, otherwise the number
00261         of bytes fetched. 0 is EOF, not an error! */
00262 /* context will be passed to your source function. */
00263 
00264 typedef struct {
00265         int (*source) (void *context, char *buffer, int len);
00266         void *context;
00267 } gdSource, *gdSourcePtr;
00268 
00269 gdImagePtr gdImageCreateFromPngSource(gdSourcePtr in);
00270 
00271 gdImagePtr gdImageCreateFromGd(FILE *in);
00272 gdImagePtr gdImageCreateFromGdCtx(gdIOCtxPtr in);
00273 
00274 gdImagePtr gdImageCreateFromGd2(FILE *in);
00275 gdImagePtr gdImageCreateFromGd2Ctx(gdIOCtxPtr in);
00276 
00277 gdImagePtr gdImageCreateFromGd2Part(FILE *in, int srcx, int srcy, int w, int h);
00278 gdImagePtr gdImageCreateFromGd2PartCtx(gdIOCtxPtr in, int srcx, int srcy, int w, int h);
00279 
00280 gdImagePtr gdImageCreateFromXbm(FILE *fd);
00281 void gdImageXbmCtx(gdImagePtr image, char* file_name, int fg, gdIOCtx * out);
00282 
00283 gdImagePtr gdImageCreateFromXpm (char *filename);
00284 
00285 void gdImageDestroy(gdImagePtr im);
00286 
00287 /* Replaces or blends with the background depending on the
00288        most recent call to gdImageAlphaBlending and the
00289        alpha channel value of 'color'; default is to overwrite.
00290        Tiling and line styling are also implemented
00291        here. All other gd drawing functions pass through this call,
00292        allowing for many useful effects. */
00293 
00294 void gdImageSetPixel(gdImagePtr im, int x, int y, int color);
00295 
00296 int gdImageGetTrueColorPixel (gdImagePtr im, int x, int y);
00297 int gdImageGetPixel(gdImagePtr im, int x, int y);
00298 
00299 void gdImageAABlend(gdImagePtr im);
00300 
00301 void gdImageLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00302 void gdImageAALine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00303 
00304 /* For backwards compatibility only. Use gdImageSetStyle()
00305        for much more flexible line drawing. */
00306 void gdImageDashedLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00307 /* Corners specified (not width and height). Upper left first, lower right
00308        second. */
00309 void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00310 /* Solid bar. Upper left corner first, lower right corner second. */
00311 void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00312 void gdImageSetClip(gdImagePtr im, int x1, int y1, int x2, int y2);
00313 void gdImageGetClip(gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P);
00314 void gdImageChar(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
00315 void gdImageCharUp(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
00316 void gdImageString(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);
00317 void gdImageStringUp(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);
00318 void gdImageString16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
00319 void gdImageStringUp16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
00320 
00321 /*
00322  * The following functions are required to be called prior to the
00323  * use of any sort of threads in a module load / shutdown function
00324  * respectively.
00325  */
00326 void gdFontCacheMutexSetup();
00327 void gdFontCacheMutexShutdown();
00328 
00329 /* 2.0.16: for thread-safe use of gdImageStringFT and friends,
00330  * call this before allowing any thread to call gdImageStringFT.
00331  * Otherwise it is invoked by the first thread to invoke
00332  * gdImageStringFT, with a very small but real risk of a race condition.
00333  * Return 0 on success, nonzero on failure to initialize freetype.
00334  */
00335 int gdFontCacheSetup(void);
00336 
00337 /* Optional: clean up after application is done using fonts in gdImageStringFT(). */
00338 void gdFontCacheShutdown(void);
00339 
00340 /* Calls gdImageStringFT. Provided for backwards compatibility only. */
00341 char *gdImageStringTTF(gdImage *im, int *brect, int fg, char *fontlist,
00342                 double ptsize, double angle, int x, int y, char *string);
00343 
00344 /* FreeType 2 text output */
00345 char *gdImageStringFT(gdImage *im, int *brect, int fg, char *fontlist,
00346                 double ptsize, double angle, int x, int y, char *string);
00347 
00348 typedef struct {
00349        double linespacing;  /* fine tune line spacing for '\n' */
00350        int flags;           /* Logical OR of gdFTEX_ values */
00351        int charmap;         /* TBB: 2.0.12: may be gdFTEX_Unicode,
00352                                gdFTEX_Shift_JIS, or gdFTEX_Big5;
00353                                when not specified, maps are searched
00354                                for in the above order. */
00355        int hdpi;
00356        int vdpi;
00357 }
00358  gdFTStringExtra, *gdFTStringExtraPtr;
00359 
00360 #define gdFTEX_LINESPACE 1
00361 #define gdFTEX_CHARMAP 2
00362 #define gdFTEX_RESOLUTION 4
00363 
00364 /* These are NOT flags; set one in 'charmap' if you set the gdFTEX_CHARMAP bit in 'flags'. */
00365 #define gdFTEX_Unicode 0
00366 #define gdFTEX_Shift_JIS 1
00367 #define gdFTEX_Big5 2
00368 
00369 /* FreeType 2 text output with fine tuning */
00370 char *
00371 gdImageStringFTEx(gdImage * im, int *brect, int fg, char * fontlist,
00372               double ptsize, double angle, int x, int y, char * string,
00373               gdFTStringExtraPtr strex);
00374 
00375 
00376 /* Point type for use in polygon drawing. */
00377 typedef struct {
00378        int x, y;
00379 } gdPoint, *gdPointPtr;
00380 
00381 void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c);
00382 void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c);
00383 
00384 /* These functions still work with truecolor images,
00385        for which they never return error. */
00386 int gdImageColorAllocate(gdImagePtr im, int r, int g, int b);
00387 /* gd 2.0: palette entries with non-opaque transparency are permitted. */
00388 int gdImageColorAllocateAlpha(gdImagePtr im, int r, int g, int b, int a);
00389 /* Assumes opaque is the preferred alpha channel value */
00390 int gdImageColorClosest(gdImagePtr im, int r, int g, int b);
00391 /* Closest match taking all four parameters into account.
00392        A slightly different color with the same transparency
00393        beats the exact same color with radically different
00394        transparency */
00395 int gdImageColorClosestAlpha(gdImagePtr im, int r, int g, int b, int a);
00396 /* An alternate method */
00397 int gdImageColorClosestHWB(gdImagePtr im, int r, int g, int b);
00398 /* Returns exact, 100% opaque matches only */
00399 int gdImageColorExact(gdImagePtr im, int r, int g, int b);
00400 /* Returns an exact match only, including alpha */
00401 int gdImageColorExactAlpha(gdImagePtr im, int r, int g, int b, int a);
00402 /* Opaque only */
00403 int gdImageColorResolve(gdImagePtr im, int r, int g, int b);
00404 /* Based on gdImageColorExactAlpha and gdImageColorClosestAlpha */
00405 int gdImageColorResolveAlpha(gdImagePtr im, int r, int g, int b, int a);
00406 
00407 /* A simpler way to obtain an opaque truecolor value for drawing on a
00408        truecolor image. Not for use with palette images! */
00409 
00410 #define gdTrueColor(r, g, b) (((r) << 16) + \
00411        ((g) << 8) + \
00412        (b))
00413 
00414 /* Returns a truecolor value with an alpha channel component.
00415        gdAlphaMax (127, **NOT 255**) is transparent, 0 is completely
00416        opaque. */
00417 
00418 #define gdTrueColorAlpha(r, g, b, a) (((a) << 24) + \
00419        ((r) << 16) + \
00420        ((g) << 8) + \
00421        (b))
00422 
00423 void gdImageColorDeallocate(gdImagePtr im, int color);
00424 
00425 /* Converts a truecolor image to a palette-based image,
00426        using a high-quality two-pass quantization routine
00427        which attempts to preserve alpha channel information
00428        as well as R/G/B color information when creating
00429        a palette. If ditherFlag is set, the image will be
00430        dithered to approximate colors better, at the expense
00431        of some obvious "speckling." colorsWanted can be
00432        anything up to 256. If the original source image
00433        includes photographic information or anything that
00434        came out of a JPEG, 256 is strongly recommended.
00435 
00436        Better yet, don't use this function -- write real
00437        truecolor PNGs and JPEGs. The disk space gain of
00438         conversion to palette is not great (for small images
00439         it can be negative) and the quality loss is ugly. */
00440 
00441 gdImagePtr gdImageCreatePaletteFromTrueColor (gdImagePtr im, int ditherFlag, int colorsWanted);
00442 
00443 void gdImageTrueColorToPalette(gdImagePtr im, int ditherFlag, int colorsWanted);
00444 
00445 
00446 /* An attempt at getting the results of gdImageTrueColorToPalette
00447        to look a bit more like the original (im1 is the original
00448        and im2 is the palette version */
00449 int gdImageColorMatch(gdImagePtr im1, gdImagePtr im2);
00450 
00451 /* Specifies a color index (if a palette image) or an
00452        RGB color (if a truecolor image) which should be
00453        considered 100% transparent. FOR TRUECOLOR IMAGES,
00454        THIS IS IGNORED IF AN ALPHA CHANNEL IS BEING
00455        SAVED. Use gdImageSaveAlpha(im, 0); to
00456        turn off the saving of a full alpha channel in
00457        a truecolor image. Note that gdImageColorTransparent
00458        is usually compatible with older browsers that
00459        do not understand full alpha channels well. TBB */
00460 void gdImageColorTransparent(gdImagePtr im, int color);
00461 
00462 void gdImagePaletteCopy(gdImagePtr dst, gdImagePtr src);
00463 void gdImagePng(gdImagePtr im, FILE *out);
00464 void gdImagePngCtx(gdImagePtr im, gdIOCtx *out);
00465 void gdImageGif(gdImagePtr im, FILE *out);
00466 void gdImageGifCtx(gdImagePtr im, gdIOCtx *out);
00467 /* 2.0.12: Compression level: 0-9 or -1, where 0 is NO COMPRESSION at all,
00468  * 1 is FASTEST but produces larger files, 9 provides the best
00469  * compression (smallest files) but takes a long time to compress, and
00470  * -1 selects the default compiled into the zlib library.
00471  */
00472 void gdImagePngEx(gdImagePtr im, FILE * out, int level, int basefilter);
00473 void gdImagePngCtxEx(gdImagePtr im, gdIOCtx * out, int level, int basefilter);
00474 
00475 void gdImageWBMP(gdImagePtr image, int fg, FILE *out);
00476 void gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out);
00477 
00478 /* Guaranteed to correctly free memory returned
00479        by the gdImage*Ptr functions */
00480 void gdFree(void *m);
00481 
00482 /* Best to free this memory with gdFree(), not free() */
00483 void *gdImageWBMPPtr(gdImagePtr im, int *size, int fg);
00484 
00485 /* 100 is highest quality (there is always a little loss with JPEG).
00486        0 is lowest. 10 is about the lowest useful setting. */
00487 void gdImageJpeg(gdImagePtr im, FILE *out, int quality);
00488 void gdImageJpegCtx(gdImagePtr im, gdIOCtx *out, int quality);
00489 
00490 /* Best to free this memory with gdFree(), not free() */
00491 void *gdImageJpegPtr(gdImagePtr im, int *size, int quality);
00492 
00493 gdImagePtr gdImageCreateFromGif(FILE *fd);
00494 gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr in);
00495 gdImagePtr gdImageCreateFromGifSource(gdSourcePtr in);
00496 
00497 /* A custom data sink. For backwards compatibility. Use
00498        gdIOCtx instead. */
00499 /* The sink function must return -1 on error, otherwise the number
00500         of bytes written, which must be equal to len. */
00501 /* context will be passed to your sink function. */
00502 typedef struct {
00503         int (*sink) (void *context, const char *buffer, int len);
00504         void *context;
00505 } gdSink, *gdSinkPtr;
00506 
00507 void gdImagePngToSink(gdImagePtr im, gdSinkPtr out);
00508 
00509 void gdImageGd(gdImagePtr im, FILE *out);
00510 void gdImageGd2(gdImagePtr im, FILE *out, int cs, int fmt);
00511 
00512 /* Best to free this memory with gdFree(), not free() */
00513 void* gdImagePngPtr(gdImagePtr im, int *size);
00514 
00515 /* Best to free this memory with gdFree(), not free() */
00516 void* gdImageGdPtr(gdImagePtr im, int *size);
00517 void *gdImagePngPtrEx(gdImagePtr im, int *size, int level, int basefilter);
00518 
00519 /* Best to free this memory with gdFree(), not free() */
00520 void* gdImageGd2Ptr(gdImagePtr im, int cs, int fmt, int *size);
00521 
00522 void gdImageEllipse(gdImagePtr im, int cx, int cy, int w, int h, int c);
00523 
00524 /* Style is a bitwise OR ( | operator ) of these.
00525        gdArc and gdChord are mutually exclusive;
00526        gdChord just connects the starting and ending
00527        angles with a straight line, while gdArc produces
00528        a rounded edge. gdPie is a synonym for gdArc.
00529        gdNoFill indicates that the arc or chord should be
00530        outlined, not filled. gdEdged, used together with
00531        gdNoFill, indicates that the beginning and ending
00532        angles should be connected to the center; this is
00533        a good way to outline (rather than fill) a
00534        'pie slice'. */
00535 #define gdArc   0
00536 #define gdPie   gdArc
00537 #define gdChord 1
00538 #define gdNoFill 2
00539 #define gdEdged 4
00540 
00541 void gdImageFilledArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style);
00542 void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color);
00543 void gdImageFilledEllipse(gdImagePtr im, int cx, int cy, int w, int h, int color);
00544 void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color);
00545 void gdImageFill(gdImagePtr im, int x, int y, int color);
00546 void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h);
00547 void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
00548                      int srcX, int srcY, int w, int h, int pct);
00549 void gdImageCopyMergeGray(gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
00550                         int srcX, int srcY, int w, int h, int pct);
00551 
00552 /* Stretches or shrinks to fit, as needed. Does NOT attempt
00553        to average the entire set of source pixels that scale down onto the
00554        destination pixel. */
00555 void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);
00556 
00557 /* gd 2.0: stretches or shrinks to fit, as needed. When called with a
00558        truecolor destination image, this function averages the
00559        entire set of source pixels that scale down onto the
00560        destination pixel, taking into account what portion of the
00561        destination pixel each source pixel represents. This is a
00562        floating point operation, but this is not a performance issue
00563        on modern hardware, except for some embedded devices. If the
00564        destination is a palette image, gdImageCopyResized is
00565        substituted automatically. */
00566 void gdImageCopyResampled(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);
00567 
00568 gdImagePtr gdImageRotate90(gdImagePtr src, int ignoretransparent);
00569 gdImagePtr gdImageRotate180(gdImagePtr src, int ignoretransparent);
00570 gdImagePtr gdImageRotate270(gdImagePtr src, int ignoretransparent);
00571 gdImagePtr gdImageRotate45(gdImagePtr src, double dAngle, int clrBack, int ignoretransparent);
00572 gdImagePtr gdImageRotate (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent);
00573 
00574 void gdImageSetBrush(gdImagePtr im, gdImagePtr brush);
00575 void gdImageSetTile(gdImagePtr im, gdImagePtr tile);
00576 void gdImageSetAntiAliased(gdImagePtr im, int c);
00577 void gdImageSetAntiAliasedDontBlend(gdImagePtr im, int c, int dont_blend);
00578 void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels);
00579 /* Line thickness (defaults to 1). Affects lines, ellipses,
00580        rectangles, polygons and so forth. */
00581 void gdImageSetThickness(gdImagePtr im, int thickness);
00582 /* On or off (1 or 0) for all three of these. */
00583 void gdImageInterlace(gdImagePtr im, int interlaceArg);
00584 void gdImageAlphaBlending(gdImagePtr im, int alphaBlendingArg);
00585 void gdImageAntialias(gdImagePtr im, int antialias);
00586 void gdImageSaveAlpha(gdImagePtr im, int saveAlphaArg);
00587 
00588 enum gdPixelateMode {
00589        GD_PIXELATE_UPPERLEFT,
00590        GD_PIXELATE_AVERAGE
00591 };
00592 
00593 int gdImagePixelate(gdImagePtr im, int block_size, const unsigned int mode);
00594 
00595 /* Macros to access information about images. */
00596 
00597 /* Returns nonzero if the image is a truecolor image,
00598        zero for a palette image. */
00599 
00600 #define gdImageTrueColor(im) ((im)->trueColor)
00601 
00602 #define gdImageSX(im) ((im)->sx)
00603 #define gdImageSY(im) ((im)->sy)
00604 #define gdImageColorsTotal(im) ((im)->colorsTotal)
00605 #define gdImageRed(im, c) ((im)->trueColor ? gdTrueColorGetRed(c) : \
00606        (im)->red[(c)])
00607 #define gdImageGreen(im, c) ((im)->trueColor ? gdTrueColorGetGreen(c) : \
00608        (im)->green[(c)])
00609 #define gdImageBlue(im, c) ((im)->trueColor ? gdTrueColorGetBlue(c) : \
00610        (im)->blue[(c)])
00611 #define gdImageAlpha(im, c) ((im)->trueColor ? gdTrueColorGetAlpha(c) : \
00612        (im)->alpha[(c)])
00613 #define gdImageGetTransparent(im) ((im)->transparent)
00614 #define gdImageGetInterlaced(im) ((im)->interlace)
00615 
00616 /* These macros provide direct access to pixels in
00617        palette-based and truecolor images, respectively.
00618        If you use these macros, you must perform your own
00619        bounds checking. Use of the macro for the correct type
00620        of image is also your responsibility. */
00621 #define gdImagePalettePixel(im, x, y) (im)->pixels[(y)][(x)]
00622 #define gdImageTrueColorPixel(im, x, y) (im)->tpixels[(y)][(x)]
00623 
00624 /* I/O Support routines. */
00625 
00626 gdIOCtx* gdNewFileCtx(FILE*);
00627 gdIOCtx* gdNewDynamicCtx(int, void*);
00628 gdIOCtx *gdNewDynamicCtxEx(int size, void *data, int freeFlag);
00629 gdIOCtx* gdNewSSCtx(gdSourcePtr in, gdSinkPtr out);
00630 void* gdDPExtractData(struct gdIOCtx* ctx, int *size);
00631 
00632 #define GD2_CHUNKSIZE           128
00633 #define GD2_CHUNKSIZE_MIN   64
00634 #define GD2_CHUNKSIZE_MAX       4096
00635 
00636 #define GD2_VERS                2
00637 #define GD2_ID                  "gd2"
00638 #define GD2_FMT_RAW             1
00639 #define GD2_FMT_COMPRESSED      2
00640 
00641 
00642 /* filters section
00643  *
00644  * Negate the imag src, white becomes black,
00645  * The red, green, and blue intensities of an image are negated.
00646  * White becomes black, yellow becomes blue, etc.
00647  */
00648 int gdImageNegate(gdImagePtr src);
00649 
00650 /* Convert the image src to a grayscale image */
00651 int gdImageGrayScale(gdImagePtr src);
00652 
00653 /* Set the brightness level <brightness> for the image src */
00654 int gdImageBrightness(gdImagePtr src, int brightness);
00655 
00656 /* Set the contrast level <contrast> for the image <src> */
00657 int gdImageContrast(gdImagePtr src, double contrast);
00658 
00659 /* Simply adds or substracts respectively red, green or blue to a pixel */
00660 int gdImageColor(gdImagePtr src, const int red, const int green, const int blue, const int alpha);
00661 
00662 /* Image convolution by a 3x3 custom matrix */
00663 int gdImageConvolution(gdImagePtr src, float ft[3][3], float filter_div, float offset);
00664 
00665 int gdImageEdgeDetectQuick(gdImagePtr src);
00666 
00667 int gdImageGaussianBlur(gdImagePtr im);
00668 
00669 int gdImageSelectiveBlur( gdImagePtr src);
00670 
00671 int gdImageEmboss(gdImagePtr im);
00672 
00673 int gdImageMeanRemoval(gdImagePtr im);
00674 
00675 int gdImageSmooth(gdImagePtr im, float weight);
00676 
00677 /* Image comparison definitions */
00678 int gdImageCompare(gdImagePtr im1, gdImagePtr im2);
00679 
00680 #define GD_CMP_IMAGE        1      /* Actual image IS different */
00681 #define GD_CMP_NUM_COLORS   2      /* Number of Colours in pallette differ */
00682 #define GD_CMP_COLOR        4      /* Image colours differ */
00683 #define GD_CMP_SIZE_X              8      /* Image width differs */
00684 #define GD_CMP_SIZE_Y              16     /* Image heights differ */
00685 #define GD_CMP_TRANSPARENT  32     /* Transparent colour */
00686 #define GD_CMP_BACKGROUND   64     /* Background colour */
00687 #define GD_CMP_INTERLACE    128    /* Interlaced setting */
00688 #define GD_CMP_TRUECOLOR    256    /* Truecolor vs palette differs */
00689 
00690 /* resolution affects ttf font rendering, particularly hinting */
00691 #define GD_RESOLUTION           96      /* pixels per inch */
00692 
00693 #ifdef __cplusplus
00694 }
00695 #endif
00696 
00697 /* 2.0.12: this now checks the clipping rectangle */
00698 #define gdImageBoundsSafe(im, x, y) (!((((y) < (im)->cy1) || ((y) > (im)->cy2)) || (((x) < (im)->cx1) || ((x) > (im)->cx2))))
00699 
00700 #endif /* GD_H */