📄 gd.h
字号:
/* Calls gdImageStringFT. Provided for backwards compatibility only. */char *gdImageStringTTF(gdImage *im, int *brect, int fg, char *fontlist, double ptsize, double angle, int x, int y, char *string);/* FreeType 2 text output */char *gdImageStringFT(gdImage *im, int *brect, int fg, char *fontlist, double ptsize, double angle, int x, int y, char *string);/* Point type for use in polygon drawing. */typedef struct { int x, y;} gdPoint, *gdPointPtr;void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c);void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c);/* These functions still work with truecolor images, for which they never return error. */int gdImageColorAllocate(gdImagePtr im, int r, int g, int b);/* gd 2.0: palette entries with non-opaque transparency are permitted. */int gdImageColorAllocateAlpha(gdImagePtr im, int r, int g, int b, int a);/* Assumes opaque is the preferred alpha channel value */int gdImageColorClosest(gdImagePtr im, int r, int g, int b);/* Closest match taking all four parameters into account. A slightly different color with the same transparency beats the exact same color with radically different transparency */int gdImageColorClosestAlpha(gdImagePtr im, int r, int g, int b, int a);/* Returns exact, 100% opaque matches only */int gdImageColorExact(gdImagePtr im, int r, int g, int b);/* Returns an exact match only, including alpha */int gdImageColorExactAlpha(gdImagePtr im, int r, int g, int b, int a);/* Opaque only */int gdImageColorResolve(gdImagePtr im, int r, int g, int b);/* Based on gdImageColorExactAlpha and gdImageColorClosestAlpha */int gdImageColorResolveAlpha(gdImagePtr im, int r, int g, int b, int a);/* A simpler way to obtain an opaque truecolor value for drawing on a truecolor image. Not for use with palette images! */#define gdTrueColor(r, g, b) (((r) << 16) + \ ((g) << 8) + \ (b))/* Returns a truecolor value with an alpha channel component. gdAlphaMax (127, **NOT 255**) is transparent, 0 is completely opaque. */#define gdTrueColorAlpha(r, g, b, a) (((a) << 24) + \ ((r) << 16) + \ ((g) << 8) + \ (b))void gdImageColorDeallocate(gdImagePtr im, int color);/* Converts a truecolor image to a palette-based image, using a high-quality two-pass quantization routine which attempts to preserve alpha channel information as well as R/G/B color information when creating a palette. If ditherFlag is set, the image will be dithered to approximate colors better, at the expense of some obvious "speckling." colorsWanted can be anything up to 256. If the original source image includes photographic information or anything that came out of a JPEG, 256 is strongly recommended. Better yet, don't use this function -- write real truecolor PNGs and JPEGs. The disk space gain of conversion to palette is not great (for small images it can be negative) and the quality loss is ugly. */void gdImageTrueColorToPalette(gdImagePtr im, int ditherFlag, int colorsWanted);/* Specifies a color index (if a palette image) or an RGB color (if a truecolor image) which should be considered 100% transparent. FOR TRUECOLOR IMAGES, THIS IS IGNORED IF AN ALPHA CHANNEL IS BEING SAVED. Use gdImageSaveAlpha(im, 0); to turn off the saving of a full alpha channel in a truecolor image. Note that gdImageColorTransparent is usually compatible with older browsers that do not understand full alpha channels well. TBB */void gdImageColorTransparent(gdImagePtr im, int color);void gdImagePaletteCopy(gdImagePtr dst, gdImagePtr src);void gdImagePng(gdImagePtr im, FILE *out);void gdImagePngCtx(gdImagePtr im, gdIOCtx *out);void gdImageWBMP(gdImagePtr image, int fg, FILE *out);void gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out);/* Guaranteed to correctly free memory returned by the gdImage*Ptr functions */void gdFree(void *m);/* Best to free this memory with gdFree(), not free() */void *gdImageWBMPPtr(gdImagePtr im, int *size, int fg);void gdImageJpeg(gdImagePtr im, FILE *out, int quality);void gdImageJpegCtx(gdImagePtr im, gdIOCtx *out, int quality);/* Best to free this memory with gdFree(), not free() */void *gdImageJpegPtr(gdImagePtr im, int *size, int quality);/* A custom data sink. For backwards compatibility. Use gdIOCtx instead. *//* The sink function must return -1 on error, otherwise the number of bytes written, which must be equal to len. *//* context will be passed to your sink function. */typedef struct { int (*sink) (void *context, const char *buffer, int len); void *context;} gdSink, *gdSinkPtr;void gdImagePngToSink(gdImagePtr im, gdSinkPtr out);void gdImageGd(gdImagePtr im, FILE *out);void gdImageGd2(gdImagePtr im, FILE *out, int cs, int fmt);/* Best to free this memory with gdFree(), not free() */void* gdImagePngPtr(gdImagePtr im, int *size);/* Best to free this memory with gdFree(), not free() */void* gdImageGdPtr(gdImagePtr im, int *size);/* Best to free this memory with gdFree(), not free() */void* gdImageGd2Ptr(gdImagePtr im, int cs, int fmt, int *size);void gdImageEllipse(gdImagePtr im, int cx, int cy, int w, int h, int color);/* Style is a bitwise OR ( | operator ) of these. gdArc and gdChord are mutually exclusive; gdChord just connects the starting and ending angles with a straight line, while gdArc produces a rounded edge. gdPie is a synonym for gdArc. gdNoFill indicates that the arc or chord should be outlined, not filled. gdEdged, used together with gdNoFill, indicates that the beginning and ending angles should be connected to the center; this is a good way to outline (rather than fill) a 'pie slice'. */#define gdArc 0#define gdPie gdArc#define gdChord 1#define gdNoFill 2#define gdEdged 4void gdImageFilledArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style);void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color);void gdImageFilledEllipse(gdImagePtr im, int cx, int cy, int w, int h, int color);void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color);void gdImageFill(gdImagePtr im, int x, int y, int color);void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h);void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct);void gdImageCopyMergeGray(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct);/* Stretches or shrinks to fit, as needed. Does NOT attempt to average the entire set of source pixels that scale down onto the destination pixel. */void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);/* gd 2.0: stretches or shrinks to fit, as needed. When called with a truecolor destination image, this function averages the entire set of source pixels that scale down onto the destination pixel, taking into account what portion of the destination pixel each source pixel represents. This is a floating point operation, but this is not a performance issue on modern hardware, except for some embedded devices. If the destination is a palette image, gdImageCopyResized is substituted automatically. */void gdImageCopyResampled(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);void gdImageSetBrush(gdImagePtr im, gdImagePtr brush);void gdImageSetTile(gdImagePtr im, gdImagePtr tile);void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels);/* Line thickness (defaults to 1). Affects lines, ellipses, rectangles, polygons and so forth. */void gdImageSetThickness(gdImagePtr im, int thickness);/* On or off (1 or 0) for all three of these. */void gdImageInterlace(gdImagePtr im, int interlaceArg);void gdImageAlphaBlending(gdImagePtr im, int alphaBlendingArg);void gdImageSaveAlpha(gdImagePtr im, int saveAlphaArg);/* Macros to access information about images. *//* Returns nonzero if the image is a truecolor image, zero for a palette image. */#define gdImageTrueColor(im) ((im)->trueColor)#define gdImageSX(im) ((im)->sx)#define gdImageSY(im) ((im)->sy)#define gdImageColorsTotal(im) ((im)->colorsTotal)#define gdImageRed(im, c) ((im)->trueColor ? gdTrueColorGetRed(c) : \ (im)->red[(c)])#define gdImageGreen(im, c) ((im)->trueColor ? gdTrueColorGetGreen(c) : \ (im)->green[(c)])#define gdImageBlue(im, c) ((im)->trueColor ? gdTrueColorGetBlue(c) : \ (im)->blue[(c)])#define gdImageAlpha(im, c) ((im)->trueColor ? gdTrueColorGetAlpha(c) : \ (im)->alpha[(c)])#define gdImageGetTransparent(im) ((im)->transparent)#define gdImageGetInterlaced(im) ((im)->interlace)/* These macros provide direct access to pixels in palette-based and truecolor images, respectively. If you use these macros, you must perform your own bounds checking. Use of the macro for the correct type of image is also your responsibility. */#define gdImagePalettePixel(im, x, y) (im)->pixels[(y)][(x)]#define gdImageTrueColorPixel(im, x, y) (im)->tpixels[(y)][(x)]/* I/O Support routines. */gdIOCtx* gdNewFileCtx(FILE*);gdIOCtx* gdNewDynamicCtx(int, void*);gdIOCtx* gdNewSSCtx(gdSourcePtr in, gdSinkPtr out);void* gdDPExtractData(struct gdIOCtx* ctx, int *size);#define GD2_CHUNKSIZE 128 #define GD2_CHUNKSIZE_MIN 64#define GD2_CHUNKSIZE_MAX 4096#define GD2_VERS 2#define GD2_ID "gd2"#define GD2_FMT_RAW 1#define GD2_FMT_COMPRESSED 2/* Image comparison definitions */int gdImageCompare(gdImagePtr im1, gdImagePtr im2);#define GD_CMP_IMAGE 1 /* Actual image IS different */#define GD_CMP_NUM_COLORS 2 /* Number of Colours in pallette differ */#define GD_CMP_COLOR 4 /* Image colours differ */#define GD_CMP_SIZE_X 8 /* Image width differs */#define GD_CMP_SIZE_Y 16 /* Image heights differ */#define GD_CMP_TRANSPARENT 32 /* Transparent colour */#define GD_CMP_BACKGROUND 64 /* Background colour */#define GD_CMP_INTERLACE 128 /* Interlaced setting */#define GD_CMP_TRUECOLOR 256 /* Truecolor vs palette differs *//* resolution affects ttf font rendering, particularly hinting */#define GD_RESOLUTION 96 /* pixels per inch */#ifdef __cplusplus}#endif#endif /* GD_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -