Back to index

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