Annotation of embedaddon/php/ext/gd/libgd/gd.h, revision 1.1.1.1

1.1       misho       1: #ifndef GD_H
                      2: #define GD_H 1
                      3: 
                      4: #ifdef __cplusplus
                      5: extern "C" {
                      6: #endif
                      7: 
                      8: #ifdef HAVE_CONFIG_H
                      9: #include "config.h"
                     10: #endif
                     11: 
                     12: #include "php_compat.h"
                     13: 
                     14: #define GD_MAJOR_VERSION 2
                     15: #define GD_MINOR_VERSION 0
                     16: #define GD_RELEASE_VERSION 35
                     17: #define GD_EXTRA_VERSION ""
                     18: #define GD_VERSION_STRING "2.0.35"
                     19: 
                     20: #ifdef NETWARE
                     21: /* default fontpath for netware systems */
                     22: #define DEFAULT_FONTPATH "sys:/java/nwgfx/lib/x11/fonts/ttf;."
                     23: #define PATHSEPARATOR ";"
                     24: #elif defined(WIN32)
                     25: /* default fontpath for windows systems */
                     26: #define DEFAULT_FONTPATH "c:\\winnt\\fonts;c:\\windows\\fonts;."
                     27: #define PATHSEPARATOR ";"
                     28: #else
                     29: /* default fontpath for unix systems */
                     30: #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:."
                     31: #define PATHSEPARATOR ":"
                     32: #endif
                     33: 
                     34: /* gd.h: declarations file for the graphic-draw module.
                     35:  * Permission to use, copy, modify, and distribute this software and its
                     36:  * documentation for any purpose and without fee is hereby granted, provided
                     37:  * that the above copyright notice appear in all copies and that both that
                     38:  * copyright notice and this permission notice appear in supporting
                     39:  * documentation.  This software is provided "AS IS." Thomas Boutell and
                     40:  * Boutell.Com, Inc. disclaim all warranties, either express or implied,
                     41:  * including but not limited to implied warranties of merchantability and
                     42:  * fitness for a particular purpose, with respect to this code and accompanying
                     43:  * documentation. */
                     44: 
                     45: /* stdio is needed for file I/O. */
                     46: #include <stdio.h>
                     47: #include "gd_io.h"
                     48: 
                     49: void php_gd_error_ex(int type, const char *format, ...);
                     50: 
                     51: void php_gd_error(const char *format, ...);
                     52: 
                     53: 
                     54: /* The maximum number of palette entries in palette-based images.
                     55:        In the wonderful new world of gd 2.0, you can of course have
                     56:        many more colors when using truecolor mode. */
                     57: 
                     58: #define gdMaxColors 256
                     59: 
                     60: /* Image type. See functions below; you will not need to change
                     61:        the elements directly. Use the provided macros to
                     62:        access sx, sy, the color table, and colorsTotal for
                     63:        read-only purposes. */
                     64: 
                     65: /* If 'truecolor' is set true, the image is truecolor;
                     66:        pixels are represented by integers, which
                     67:        must be 32 bits wide or more.
                     68: 
                     69:        True colors are repsented as follows:
                     70: 
                     71:        ARGB
                     72: 
                     73:        Where 'A' (alpha channel) occupies only the
                     74:        LOWER 7 BITS of the MSB. This very small
                     75:        loss of alpha channel resolution allows gd 2.x
                     76:        to keep backwards compatibility by allowing
                     77:        signed integers to be used to represent colors,
                     78:        and negative numbers to represent special cases,
                     79:        just as in gd 1.x. */
                     80: 
                     81: #define gdAlphaMax 127
                     82: #define gdAlphaOpaque 0
                     83: #define gdAlphaTransparent 127
                     84: #define gdRedMax 255
                     85: #define gdGreenMax 255
                     86: #define gdBlueMax 255
                     87: #define gdTrueColorGetAlpha(c) (((c) & 0x7F000000) >> 24)
                     88: #define gdTrueColorGetRed(c) (((c) & 0xFF0000) >> 16)
                     89: #define gdTrueColorGetGreen(c) (((c) & 0x00FF00) >> 8)
                     90: #define gdTrueColorGetBlue(c) ((c) & 0x0000FF)
                     91: #define gdEffectReplace 0
                     92: #define gdEffectAlphaBlend 1
                     93: #define gdEffectNormal 2
                     94: #define gdEffectOverlay 3
                     95: 
                     96: 
                     97: /* This function accepts truecolor pixel values only. The
                     98:        source color is composited with the destination color
                     99:        based on the alpha channel value of the source color.
                    100:        The resulting color is opaque. */
                    101: 
                    102: int gdAlphaBlend(int dest, int src);
                    103: 
                    104: typedef struct gdImageStruct {
                    105:        /* Palette-based image pixels */
                    106:        unsigned char ** pixels;
                    107:        int sx;
                    108:        int sy;
                    109:        /* These are valid in palette images only. See also
                    110:                'alpha', which appears later in the structure to
                    111:                preserve binary backwards compatibility */
                    112:        int colorsTotal;
                    113:        int red[gdMaxColors];
                    114:        int green[gdMaxColors];
                    115:        int blue[gdMaxColors];
                    116:        int open[gdMaxColors];
                    117:        /* For backwards compatibility, this is set to the
                    118:                first palette entry with 100% transparency,
                    119:                and is also set and reset by the
                    120:                gdImageColorTransparent function. Newer
                    121:                applications can allocate palette entries
                    122:                with any desired level of transparency; however,
                    123:                bear in mind that many viewers, notably
                    124:                many web browsers, fail to implement
                    125:                full alpha channel for PNG and provide
                    126:                support for full opacity or transparency only. */
                    127:        int transparent;
                    128:        int *polyInts;
                    129:        int polyAllocated;
                    130:        struct gdImageStruct *brush;
                    131:        struct gdImageStruct *tile;
                    132:        int brushColorMap[gdMaxColors];
                    133:        int tileColorMap[gdMaxColors];
                    134:        int styleLength;
                    135:        int stylePos;
                    136:        int *style;
                    137:        int interlace;
                    138:        /* New in 2.0: thickness of line. Initialized to 1. */
                    139:        int thick;
                    140:        /* New in 2.0: alpha channel for palettes. Note that only
                    141:                Macintosh Internet Explorer and (possibly) Netscape 6
                    142:                really support multiple levels of transparency in
                    143:                palettes, to my knowledge, as of 2/15/01. Most
                    144:                common browsers will display 100% opaque and
                    145:                100% transparent correctly, and do something
                    146:                unpredictable and/or undesirable for levels
                    147:                in between. TBB */
                    148:        int alpha[gdMaxColors];
                    149:        /* Truecolor flag and pixels. New 2.0 fields appear here at the
                    150:                end to minimize breakage of existing object code. */
                    151:        int trueColor;
                    152:        int ** tpixels;
                    153:        /* Should alpha channel be copied, or applied, each time a
                    154:                pixel is drawn? This applies to truecolor images only.
                    155:                No attempt is made to alpha-blend in palette images,
                    156:                even if semitransparent palette entries exist.
                    157:                To do that, build your image as a truecolor image,
                    158:                then quantize down to 8 bits. */
                    159:        int alphaBlendingFlag;
                    160:        /* Should antialias functions be used */
                    161:        int antialias;
                    162:        /* Should the alpha channel of the image be saved? This affects
                    163:                PNG at the moment; other future formats may also
                    164:                have that capability. JPEG doesn't. */
                    165:        int saveAlphaFlag;
                    166: 
                    167: 
                    168:        /* 2.0.12: anti-aliased globals */
                    169:        int AA;
                    170:        int AA_color;
                    171:        int AA_dont_blend;
                    172:        unsigned char **AA_opacity;
                    173:        int AA_polygon;
                    174:        /* Stored and pre-computed variables for determining the perpendicular
                    175:         * distance from a point to the anti-aliased line being drawn:
                    176:         */
                    177:        int AAL_x1;
                    178:        int AAL_y1;
                    179:        int AAL_x2;
                    180:        int AAL_y2;
                    181:        int AAL_Bx_Ax;
                    182:        int AAL_By_Ay;
                    183:        int AAL_LAB_2;
                    184:        float AAL_LAB;
                    185: 
                    186:        /* 2.0.12: simple clipping rectangle. These values must be checked for safety when set; please use gdImageSetClip */
                    187:        int cx1;
                    188:        int cy1;
                    189:        int cx2;
                    190:        int cy2;
                    191: } gdImage;
                    192: 
                    193: typedef gdImage * gdImagePtr;
                    194: 
                    195: typedef struct {
                    196:        /* # of characters in font */
                    197:        int nchars;
                    198:        /* First character is numbered... (usually 32 = space) */
                    199:        int offset;
                    200:        /* Character width and height */
                    201:        int w;
                    202:        int h;
                    203:        /* Font data; array of characters, one row after another.
                    204:                Easily included in code, also easily loaded from
                    205:                data files. */
                    206:        char *data;
                    207: } gdFont;
                    208: 
                    209: /* Text functions take these. */
                    210: typedef gdFont *gdFontPtr;
                    211: 
                    212: /* For backwards compatibility only. Use gdImageSetStyle()
                    213:        for MUCH more flexible line drawing. Also see
                    214:        gdImageSetBrush(). */
                    215: #define gdDashSize 4
                    216: 
                    217: /* Special colors. */
                    218: 
                    219: #define gdStyled (-2)
                    220: #define gdBrushed (-3)
                    221: #define gdStyledBrushed (-4)
                    222: #define gdTiled (-5)
                    223: 
                    224: /* NOT the same as the transparent color index.
                    225:        This is used in line styles only. */
                    226: #define gdTransparent (-6)
                    227: 
                    228: #define gdAntiAliased (-7)
                    229: 
                    230: /* Functions to manipulate images. */
                    231: 
                    232: /* Creates a palette-based image (up to 256 colors). */
                    233: gdImagePtr gdImageCreate(int sx, int sy);
                    234: 
                    235: /* An alternate name for the above (2.0). */
                    236: #define gdImageCreatePalette gdImageCreate
                    237: 
                    238: /* Creates a truecolor image (millions of colors). */
                    239: gdImagePtr gdImageCreateTrueColor(int sx, int sy);
                    240: 
                    241: /* Creates an image from various file types. These functions
                    242:        return a palette or truecolor image based on the
                    243:        nature of the file being loaded. Truecolor PNG
                    244:        stays truecolor; palette PNG stays palette-based;
                    245:        JPEG is always truecolor. */
                    246: gdImagePtr gdImageCreateFromPng(FILE *fd);
                    247: gdImagePtr gdImageCreateFromPngCtx(gdIOCtxPtr in);
                    248: gdImagePtr gdImageCreateFromWBMP(FILE *inFile);
                    249: gdImagePtr gdImageCreateFromWBMPCtx(gdIOCtx *infile);
                    250: gdImagePtr gdImageCreateFromJpeg(FILE *infile, int ignore_warning);
                    251: gdImagePtr gdImageCreateFromJpegCtx(gdIOCtx *infile, int ignore_warning);
                    252: 
                    253: int gdJpegGetVersionInt();
                    254: const char * gdPngGetVersionString();
                    255: 
                    256: int gdJpegGetVersionInt();
                    257: const char * gdJpegGetVersionString();
                    258: 
                    259: /* A custom data source. */
                    260: /* The source function must return -1 on error, otherwise the number
                    261:         of bytes fetched. 0 is EOF, not an error! */
                    262: /* context will be passed to your source function. */
                    263: 
                    264: typedef struct {
                    265:         int (*source) (void *context, char *buffer, int len);
                    266:         void *context;
                    267: } gdSource, *gdSourcePtr;
                    268: 
                    269: gdImagePtr gdImageCreateFromPngSource(gdSourcePtr in);
                    270: 
                    271: gdImagePtr gdImageCreateFromGd(FILE *in);
                    272: gdImagePtr gdImageCreateFromGdCtx(gdIOCtxPtr in);
                    273: 
                    274: gdImagePtr gdImageCreateFromGd2(FILE *in);
                    275: gdImagePtr gdImageCreateFromGd2Ctx(gdIOCtxPtr in);
                    276: 
                    277: gdImagePtr gdImageCreateFromGd2Part(FILE *in, int srcx, int srcy, int w, int h);
                    278: gdImagePtr gdImageCreateFromGd2PartCtx(gdIOCtxPtr in, int srcx, int srcy, int w, int h);
                    279: 
                    280: gdImagePtr gdImageCreateFromXbm(FILE *fd);
                    281: void gdImageXbmCtx(gdImagePtr image, char* file_name, int fg, gdIOCtx * out);
                    282: 
                    283: gdImagePtr gdImageCreateFromXpm (char *filename);
                    284: 
                    285: void gdImageDestroy(gdImagePtr im);
                    286: 
                    287: /* Replaces or blends with the background depending on the
                    288:        most recent call to gdImageAlphaBlending and the
                    289:        alpha channel value of 'color'; default is to overwrite.
                    290:        Tiling and line styling are also implemented
                    291:        here. All other gd drawing functions pass through this call,
                    292:        allowing for many useful effects. */
                    293: 
                    294: void gdImageSetPixel(gdImagePtr im, int x, int y, int color);
                    295: 
                    296: int gdImageGetTrueColorPixel (gdImagePtr im, int x, int y);
                    297: int gdImageGetPixel(gdImagePtr im, int x, int y);
                    298: 
                    299: void gdImageAABlend(gdImagePtr im);
                    300: 
                    301: void gdImageLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
                    302: void gdImageAALine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
                    303: 
                    304: /* For backwards compatibility only. Use gdImageSetStyle()
                    305:        for much more flexible line drawing. */
                    306: void gdImageDashedLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
                    307: /* Corners specified (not width and height). Upper left first, lower right
                    308:        second. */
                    309: void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
                    310: /* Solid bar. Upper left corner first, lower right corner second. */
                    311: void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
                    312: void gdImageSetClip(gdImagePtr im, int x1, int y1, int x2, int y2);
                    313: void gdImageGetClip(gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P);
                    314: void gdImageChar(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
                    315: void gdImageCharUp(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
                    316: void gdImageString(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);
                    317: void gdImageStringUp(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);
                    318: void gdImageString16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
                    319: void gdImageStringUp16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
                    320: 
                    321: /*
                    322:  * The following functions are required to be called prior to the
                    323:  * use of any sort of threads in a module load / shutdown function
                    324:  * respectively.
                    325:  */
                    326: void gdFontCacheMutexSetup();
                    327: void gdFontCacheMutexShutdown();
                    328: 
                    329: /* 2.0.16: for thread-safe use of gdImageStringFT and friends,
                    330:  * call this before allowing any thread to call gdImageStringFT.
                    331:  * Otherwise it is invoked by the first thread to invoke
                    332:  * gdImageStringFT, with a very small but real risk of a race condition.
                    333:  * Return 0 on success, nonzero on failure to initialize freetype.
                    334:  */
                    335: int gdFontCacheSetup(void);
                    336: 
                    337: /* Optional: clean up after application is done using fonts in gdImageStringFT(). */
                    338: void gdFontCacheShutdown(void);
                    339: 
                    340: /* Calls gdImageStringFT. Provided for backwards compatibility only. */
                    341: char *gdImageStringTTF(gdImage *im, int *brect, int fg, char *fontlist,
                    342:                 double ptsize, double angle, int x, int y, char *string);
                    343: 
                    344: /* FreeType 2 text output */
                    345: char *gdImageStringFT(gdImage *im, int *brect, int fg, char *fontlist,
                    346:                 double ptsize, double angle, int x, int y, char *string);
                    347: 
                    348: typedef struct {
                    349:        double linespacing;     /* fine tune line spacing for '\n' */
                    350:        int flags;              /* Logical OR of gdFTEX_ values */
                    351:        int charmap;            /* TBB: 2.0.12: may be gdFTEX_Unicode,
                    352:                                   gdFTEX_Shift_JIS, or gdFTEX_Big5;
                    353:                                   when not specified, maps are searched
                    354:                                   for in the above order. */
                    355:        int hdpi;
                    356:        int vdpi;
                    357: }
                    358:  gdFTStringExtra, *gdFTStringExtraPtr;
                    359: 
                    360: #define gdFTEX_LINESPACE 1
                    361: #define gdFTEX_CHARMAP 2
                    362: #define gdFTEX_RESOLUTION 4
                    363: 
                    364: /* These are NOT flags; set one in 'charmap' if you set the gdFTEX_CHARMAP bit in 'flags'. */
                    365: #define gdFTEX_Unicode 0
                    366: #define gdFTEX_Shift_JIS 1
                    367: #define gdFTEX_Big5 2
                    368: 
                    369: /* FreeType 2 text output with fine tuning */
                    370: char *
                    371: gdImageStringFTEx(gdImage * im, int *brect, int fg, char * fontlist,
                    372:                double ptsize, double angle, int x, int y, char * string,
                    373:                gdFTStringExtraPtr strex);
                    374: 
                    375: 
                    376: /* Point type for use in polygon drawing. */
                    377: typedef struct {
                    378:        int x, y;
                    379: } gdPoint, *gdPointPtr;
                    380: 
                    381: void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c);
                    382: void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c);
                    383: 
                    384: /* These functions still work with truecolor images,
                    385:        for which they never return error. */
                    386: int gdImageColorAllocate(gdImagePtr im, int r, int g, int b);
                    387: /* gd 2.0: palette entries with non-opaque transparency are permitted. */
                    388: int gdImageColorAllocateAlpha(gdImagePtr im, int r, int g, int b, int a);
                    389: /* Assumes opaque is the preferred alpha channel value */
                    390: int gdImageColorClosest(gdImagePtr im, int r, int g, int b);
                    391: /* Closest match taking all four parameters into account.
                    392:        A slightly different color with the same transparency
                    393:        beats the exact same color with radically different
                    394:        transparency */
                    395: int gdImageColorClosestAlpha(gdImagePtr im, int r, int g, int b, int a);
                    396: /* An alternate method */
                    397: int gdImageColorClosestHWB(gdImagePtr im, int r, int g, int b);
                    398: /* Returns exact, 100% opaque matches only */
                    399: int gdImageColorExact(gdImagePtr im, int r, int g, int b);
                    400: /* Returns an exact match only, including alpha */
                    401: int gdImageColorExactAlpha(gdImagePtr im, int r, int g, int b, int a);
                    402: /* Opaque only */
                    403: int gdImageColorResolve(gdImagePtr im, int r, int g, int b);
                    404: /* Based on gdImageColorExactAlpha and gdImageColorClosestAlpha */
                    405: int gdImageColorResolveAlpha(gdImagePtr im, int r, int g, int b, int a);
                    406: 
                    407: /* A simpler way to obtain an opaque truecolor value for drawing on a
                    408:        truecolor image. Not for use with palette images! */
                    409: 
                    410: #define gdTrueColor(r, g, b) (((r) << 16) + \
                    411:        ((g) << 8) + \
                    412:        (b))
                    413: 
                    414: /* Returns a truecolor value with an alpha channel component.
                    415:        gdAlphaMax (127, **NOT 255**) is transparent, 0 is completely
                    416:        opaque. */
                    417: 
                    418: #define gdTrueColorAlpha(r, g, b, a) (((a) << 24) + \
                    419:        ((r) << 16) + \
                    420:        ((g) << 8) + \
                    421:        (b))
                    422: 
                    423: void gdImageColorDeallocate(gdImagePtr im, int color);
                    424: 
                    425: /* Converts a truecolor image to a palette-based image,
                    426:        using a high-quality two-pass quantization routine
                    427:        which attempts to preserve alpha channel information
                    428:        as well as R/G/B color information when creating
                    429:        a palette. If ditherFlag is set, the image will be
                    430:        dithered to approximate colors better, at the expense
                    431:        of some obvious "speckling." colorsWanted can be
                    432:        anything up to 256. If the original source image
                    433:        includes photographic information or anything that
                    434:        came out of a JPEG, 256 is strongly recommended.
                    435: 
                    436:        Better yet, don't use this function -- write real
                    437:        truecolor PNGs and JPEGs. The disk space gain of
                    438:         conversion to palette is not great (for small images
                    439:         it can be negative) and the quality loss is ugly. */
                    440: 
                    441: gdImagePtr gdImageCreatePaletteFromTrueColor (gdImagePtr im, int ditherFlag, int colorsWanted);
                    442: 
                    443: void gdImageTrueColorToPalette(gdImagePtr im, int ditherFlag, int colorsWanted);
                    444: 
                    445: 
                    446: /* An attempt at getting the results of gdImageTrueColorToPalette
                    447:        to look a bit more like the original (im1 is the original
                    448:        and im2 is the palette version */
                    449: int gdImageColorMatch(gdImagePtr im1, gdImagePtr im2);
                    450: 
                    451: /* Specifies a color index (if a palette image) or an
                    452:        RGB color (if a truecolor image) which should be
                    453:        considered 100% transparent. FOR TRUECOLOR IMAGES,
                    454:        THIS IS IGNORED IF AN ALPHA CHANNEL IS BEING
                    455:        SAVED. Use gdImageSaveAlpha(im, 0); to
                    456:        turn off the saving of a full alpha channel in
                    457:        a truecolor image. Note that gdImageColorTransparent
                    458:        is usually compatible with older browsers that
                    459:        do not understand full alpha channels well. TBB */
                    460: void gdImageColorTransparent(gdImagePtr im, int color);
                    461: 
                    462: void gdImagePaletteCopy(gdImagePtr dst, gdImagePtr src);
                    463: void gdImagePng(gdImagePtr im, FILE *out);
                    464: void gdImagePngCtx(gdImagePtr im, gdIOCtx *out);
                    465: void gdImageGif(gdImagePtr im, FILE *out);
                    466: void gdImageGifCtx(gdImagePtr im, gdIOCtx *out);
                    467: /* 2.0.12: Compression level: 0-9 or -1, where 0 is NO COMPRESSION at all,
                    468:  * 1 is FASTEST but produces larger files, 9 provides the best
                    469:  * compression (smallest files) but takes a long time to compress, and
                    470:  * -1 selects the default compiled into the zlib library.
                    471:  */
                    472: void gdImagePngEx(gdImagePtr im, FILE * out, int level, int basefilter);
                    473: void gdImagePngCtxEx(gdImagePtr im, gdIOCtx * out, int level, int basefilter);
                    474: 
                    475: void gdImageWBMP(gdImagePtr image, int fg, FILE *out);
                    476: void gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out);
                    477: 
                    478: /* Guaranteed to correctly free memory returned
                    479:        by the gdImage*Ptr functions */
                    480: void gdFree(void *m);
                    481: 
                    482: /* Best to free this memory with gdFree(), not free() */
                    483: void *gdImageWBMPPtr(gdImagePtr im, int *size, int fg);
                    484: 
                    485: /* 100 is highest quality (there is always a little loss with JPEG).
                    486:        0 is lowest. 10 is about the lowest useful setting. */
                    487: void gdImageJpeg(gdImagePtr im, FILE *out, int quality);
                    488: void gdImageJpegCtx(gdImagePtr im, gdIOCtx *out, int quality);
                    489: 
                    490: /* Best to free this memory with gdFree(), not free() */
                    491: void *gdImageJpegPtr(gdImagePtr im, int *size, int quality);
                    492: 
                    493: gdImagePtr gdImageCreateFromGif(FILE *fd);
                    494: gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr in);
                    495: gdImagePtr gdImageCreateFromGifSource(gdSourcePtr in);
                    496: 
                    497: /* A custom data sink. For backwards compatibility. Use
                    498:        gdIOCtx instead. */
                    499: /* The sink function must return -1 on error, otherwise the number
                    500:         of bytes written, which must be equal to len. */
                    501: /* context will be passed to your sink function. */
                    502: typedef struct {
                    503:         int (*sink) (void *context, const char *buffer, int len);
                    504:         void *context;
                    505: } gdSink, *gdSinkPtr;
                    506: 
                    507: void gdImagePngToSink(gdImagePtr im, gdSinkPtr out);
                    508: 
                    509: void gdImageGd(gdImagePtr im, FILE *out);
                    510: void gdImageGd2(gdImagePtr im, FILE *out, int cs, int fmt);
                    511: 
                    512: /* Best to free this memory with gdFree(), not free() */
                    513: void* gdImagePngPtr(gdImagePtr im, int *size);
                    514: 
                    515: /* Best to free this memory with gdFree(), not free() */
                    516: void* gdImageGdPtr(gdImagePtr im, int *size);
                    517: void *gdImagePngPtrEx(gdImagePtr im, int *size, int level, int basefilter);
                    518: 
                    519: /* Best to free this memory with gdFree(), not free() */
                    520: void* gdImageGd2Ptr(gdImagePtr im, int cs, int fmt, int *size);
                    521: 
                    522: void gdImageEllipse(gdImagePtr im, int cx, int cy, int w, int h, int c);
                    523: 
                    524: /* Style is a bitwise OR ( | operator ) of these.
                    525:        gdArc and gdChord are mutually exclusive;
                    526:        gdChord just connects the starting and ending
                    527:        angles with a straight line, while gdArc produces
                    528:        a rounded edge. gdPie is a synonym for gdArc.
                    529:        gdNoFill indicates that the arc or chord should be
                    530:        outlined, not filled. gdEdged, used together with
                    531:        gdNoFill, indicates that the beginning and ending
                    532:        angles should be connected to the center; this is
                    533:        a good way to outline (rather than fill) a
                    534:        'pie slice'. */
                    535: #define gdArc   0
                    536: #define gdPie   gdArc
                    537: #define gdChord 1
                    538: #define gdNoFill 2
                    539: #define gdEdged 4
                    540: 
                    541: void gdImageFilledArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style);
                    542: void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color);
                    543: void gdImageFilledEllipse(gdImagePtr im, int cx, int cy, int w, int h, int color);
                    544: void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color);
                    545: void gdImageFill(gdImagePtr im, int x, int y, int color);
                    546: void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h);
                    547: void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
                    548:                        int srcX, int srcY, int w, int h, int pct);
                    549: void gdImageCopyMergeGray(gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
                    550:                         int srcX, int srcY, int w, int h, int pct);
                    551: 
                    552: /* Stretches or shrinks to fit, as needed. Does NOT attempt
                    553:        to average the entire set of source pixels that scale down onto the
                    554:        destination pixel. */
                    555: void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);
                    556: 
                    557: /* gd 2.0: stretches or shrinks to fit, as needed. When called with a
                    558:        truecolor destination image, this function averages the
                    559:        entire set of source pixels that scale down onto the
                    560:        destination pixel, taking into account what portion of the
                    561:        destination pixel each source pixel represents. This is a
                    562:        floating point operation, but this is not a performance issue
                    563:        on modern hardware, except for some embedded devices. If the
                    564:        destination is a palette image, gdImageCopyResized is
                    565:        substituted automatically. */
                    566: void gdImageCopyResampled(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);
                    567: 
                    568: gdImagePtr gdImageRotate90(gdImagePtr src, int ignoretransparent);
                    569: gdImagePtr gdImageRotate180(gdImagePtr src, int ignoretransparent);
                    570: gdImagePtr gdImageRotate270(gdImagePtr src, int ignoretransparent);
                    571: gdImagePtr gdImageRotate45(gdImagePtr src, double dAngle, int clrBack, int ignoretransparent);
                    572: gdImagePtr gdImageRotate (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent);
                    573: 
                    574: void gdImageSetBrush(gdImagePtr im, gdImagePtr brush);
                    575: void gdImageSetTile(gdImagePtr im, gdImagePtr tile);
                    576: void gdImageSetAntiAliased(gdImagePtr im, int c);
                    577: void gdImageSetAntiAliasedDontBlend(gdImagePtr im, int c, int dont_blend);
                    578: void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels);
                    579: /* Line thickness (defaults to 1). Affects lines, ellipses,
                    580:        rectangles, polygons and so forth. */
                    581: void gdImageSetThickness(gdImagePtr im, int thickness);
                    582: /* On or off (1 or 0) for all three of these. */
                    583: void gdImageInterlace(gdImagePtr im, int interlaceArg);
                    584: void gdImageAlphaBlending(gdImagePtr im, int alphaBlendingArg);
                    585: void gdImageAntialias(gdImagePtr im, int antialias);
                    586: void gdImageSaveAlpha(gdImagePtr im, int saveAlphaArg);
                    587: 
                    588: enum gdPixelateMode {
                    589:        GD_PIXELATE_UPPERLEFT,
                    590:        GD_PIXELATE_AVERAGE
                    591: };
                    592: 
                    593: int gdImagePixelate(gdImagePtr im, int block_size, const unsigned int mode);
                    594: 
                    595: /* Macros to access information about images. */
                    596: 
                    597: /* Returns nonzero if the image is a truecolor image,
                    598:        zero for a palette image. */
                    599: 
                    600: #define gdImageTrueColor(im) ((im)->trueColor)
                    601: 
                    602: #define gdImageSX(im) ((im)->sx)
                    603: #define gdImageSY(im) ((im)->sy)
                    604: #define gdImageColorsTotal(im) ((im)->colorsTotal)
                    605: #define gdImageRed(im, c) ((im)->trueColor ? gdTrueColorGetRed(c) : \
                    606:        (im)->red[(c)])
                    607: #define gdImageGreen(im, c) ((im)->trueColor ? gdTrueColorGetGreen(c) : \
                    608:        (im)->green[(c)])
                    609: #define gdImageBlue(im, c) ((im)->trueColor ? gdTrueColorGetBlue(c) : \
                    610:        (im)->blue[(c)])
                    611: #define gdImageAlpha(im, c) ((im)->trueColor ? gdTrueColorGetAlpha(c) : \
                    612:        (im)->alpha[(c)])
                    613: #define gdImageGetTransparent(im) ((im)->transparent)
                    614: #define gdImageGetInterlaced(im) ((im)->interlace)
                    615: 
                    616: /* These macros provide direct access to pixels in
                    617:        palette-based and truecolor images, respectively.
                    618:        If you use these macros, you must perform your own
                    619:        bounds checking. Use of the macro for the correct type
                    620:        of image is also your responsibility. */
                    621: #define gdImagePalettePixel(im, x, y) (im)->pixels[(y)][(x)]
                    622: #define gdImageTrueColorPixel(im, x, y) (im)->tpixels[(y)][(x)]
                    623: 
                    624: /* I/O Support routines. */
                    625: 
                    626: gdIOCtx* gdNewFileCtx(FILE*);
                    627: gdIOCtx* gdNewDynamicCtx(int, void*);
                    628: gdIOCtx *gdNewDynamicCtxEx(int size, void *data, int freeFlag);
                    629: gdIOCtx* gdNewSSCtx(gdSourcePtr in, gdSinkPtr out);
                    630: void* gdDPExtractData(struct gdIOCtx* ctx, int *size);
                    631: 
                    632: #define GD2_CHUNKSIZE           128
                    633: #define GD2_CHUNKSIZE_MIN      64
                    634: #define GD2_CHUNKSIZE_MAX       4096
                    635: 
                    636: #define GD2_VERS                2
                    637: #define GD2_ID                  "gd2"
                    638: #define GD2_FMT_RAW             1
                    639: #define GD2_FMT_COMPRESSED      2
                    640: 
                    641: 
                    642: /* filters section
                    643:  *
                    644:  * Negate the imag src, white becomes black,
                    645:  * The red, green, and blue intensities of an image are negated.
                    646:  * White becomes black, yellow becomes blue, etc.
                    647:  */
                    648: int gdImageNegate(gdImagePtr src);
                    649: 
                    650: /* Convert the image src to a grayscale image */
                    651: int gdImageGrayScale(gdImagePtr src);
                    652: 
                    653: /* Set the brightness level <brightness> for the image src */
                    654: int gdImageBrightness(gdImagePtr src, int brightness);
                    655: 
                    656: /* Set the contrast level <contrast> for the image <src> */
                    657: int gdImageContrast(gdImagePtr src, double contrast);
                    658: 
                    659: /* Simply adds or substracts respectively red, green or blue to a pixel */
                    660: int gdImageColor(gdImagePtr src, const int red, const int green, const int blue, const int alpha);
                    661: 
                    662: /* Image convolution by a 3x3 custom matrix */
                    663: int gdImageConvolution(gdImagePtr src, float ft[3][3], float filter_div, float offset);
                    664: 
                    665: int gdImageEdgeDetectQuick(gdImagePtr src);
                    666: 
                    667: int gdImageGaussianBlur(gdImagePtr im);
                    668: 
                    669: int gdImageSelectiveBlur( gdImagePtr src);
                    670: 
                    671: int gdImageEmboss(gdImagePtr im);
                    672: 
                    673: int gdImageMeanRemoval(gdImagePtr im);
                    674: 
                    675: int gdImageSmooth(gdImagePtr im, float weight);
                    676: 
                    677: /* Image comparison definitions */
                    678: int gdImageCompare(gdImagePtr im1, gdImagePtr im2);
                    679: 
                    680: #define GD_CMP_IMAGE           1       /* Actual image IS different */
                    681: #define GD_CMP_NUM_COLORS      2       /* Number of Colours in pallette differ */
                    682: #define GD_CMP_COLOR           4       /* Image colours differ */
                    683: #define GD_CMP_SIZE_X          8       /* Image width differs */
                    684: #define GD_CMP_SIZE_Y          16      /* Image heights differ */
                    685: #define GD_CMP_TRANSPARENT     32      /* Transparent colour */
                    686: #define GD_CMP_BACKGROUND      64      /* Background colour */
                    687: #define GD_CMP_INTERLACE       128     /* Interlaced setting */
                    688: #define GD_CMP_TRUECOLOR       256     /* Truecolor vs palette differs */
                    689: 
                    690: /* resolution affects ttf font rendering, particularly hinting */
                    691: #define GD_RESOLUTION           96      /* pixels per inch */
                    692: 
                    693: #ifdef __cplusplus
                    694: }
                    695: #endif
                    696: 
                    697: /* 2.0.12: this now checks the clipping rectangle */
                    698: #define gdImageBoundsSafe(im, x, y) (!((((y) < (im)->cy1) || ((y) > (im)->cy2)) || (((x) < (im)->cx1) || ((x) > (im)->cx2))))
                    699: 
                    700: #endif /* GD_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>