gd.h
来自「Linux/Unix下的绘图函数库(Graphic Drawing Librar」· C头文件 代码 · 共 796 行 · 第 1/3 页
H
796 行
/* These read the first frame only */BGD_DECLARE(gdImagePtr) gdImageCreateFromGif (FILE * fd);BGD_DECLARE(gdImagePtr) gdImageCreateFromGifCtx (gdIOCtxPtr in);BGD_DECLARE(gdImagePtr) gdImageCreateFromGifPtr (int size, void *data);BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMP (FILE * inFile);BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPCtx (gdIOCtx * infile);BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPPtr (int size, void *data);BGD_DECLARE(gdImagePtr) gdImageCreateFromJpeg (FILE * infile);BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegCtx (gdIOCtx * infile);BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtr (int size, void *data);/* A custom data source. *//* The source function must return -1 on error, otherwise the number of bytes fetched. 0 is EOF, not an error! *//* context will be passed to your source function. */ typedef struct { int (*source) (void *context, char *buffer, int len); void *context; } gdSource, *gdSourcePtr; /* Deprecated in favor of gdImageCreateFromPngCtx */BGD_DECLARE(gdImagePtr) gdImageCreateFromPngSource (gdSourcePtr in);BGD_DECLARE(gdImagePtr) gdImageCreateFromGd (FILE * in);BGD_DECLARE(gdImagePtr) gdImageCreateFromGdCtx (gdIOCtxPtr in);BGD_DECLARE(gdImagePtr) gdImageCreateFromGdPtr (int size, void *data);BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2 (FILE * in);BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in);BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ptr (int size, void *data);BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Part (FILE * in, int srcx, int srcy, int w, int h);BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartCtx (gdIOCtxPtr in, int srcx, int srcy, int w, int h);BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartPtr (int size, void *data, int srcx, int srcy, int w, int h); /* 2.0.10: prototype was missing */BGD_DECLARE(gdImagePtr) gdImageCreateFromXbm (FILE * in); /* NOTE: filename, not FILE */BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm (char *filename);BGD_DECLARE(void) gdImageDestroy (gdImagePtr im);/* Replaces or blends with the background depending on the most recent call to gdImageAlphaBlending and the alpha channel value of 'color'; default is to overwrite. Tiling and line styling are also implemented here. All other gd drawing functions pass through this call, allowing for many useful effects. */BGD_DECLARE(void) gdImageSetPixel (gdImagePtr im, int x, int y, int color);/* FreeType 2 text output with hook to extra flags */BGD_DECLARE(int) gdImageGetPixel (gdImagePtr im, int x, int y);BGD_DECLARE(int) gdImageGetTrueColorPixel (gdImagePtr im, int x, int y);BGD_DECLARE(void) gdImageAABlend (gdImagePtr im);BGD_DECLARE(void) gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color);/* For backwards compatibility only. Use gdImageSetStyle() for much more flexible line drawing. */BGD_DECLARE(void) gdImageDashedLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color);/* Corners specified (not width and height). Upper left first, lower right second. */BGD_DECLARE(void) gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color);/* Solid bar. Upper left corner first, lower right corner second. */BGD_DECLARE(void) gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color);BGD_DECLARE(void) gdImageSetClip(gdImagePtr im, int x1, int y1, int x2, int y2);BGD_DECLARE(void) gdImageGetClip(gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P);BGD_DECLARE(int) gdImageBoundsSafe (gdImagePtr im, int x, int y);BGD_DECLARE(void) gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);BGD_DECLARE(void) gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);BGD_DECLARE(void) gdImageString (gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);BGD_DECLARE(void) gdImageStringUp (gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);BGD_DECLARE(void) gdImageString16 (gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);BGD_DECLARE(void) gdImageStringUp16 (gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);/* 2.0.16: for thread-safe use of gdImageStringFT and friends, call this before allowing any thread to call gdImageStringFT. Otherwise it is invoked by the first thread to invoke gdImageStringFT, with a very small but real risk of a race condition. Return 0 on success, nonzero on failure to initialize freetype. */BGD_DECLARE(int) gdFontCacheSetup (void);/* Optional: clean up after application is done using fonts in BGD_DECLARE( ) gdImageStringFT(). */BGD_DECLARE(void) gdFontCacheShutdown (void);/* 2.0.20: for backwards compatibility. A few applications did start calling this function when it first appeared although it was never documented. Simply invokes gdFontCacheShutdown. */BGD_DECLARE(void) gdFreeFontCache (void);/* Calls gdImageStringFT. Provided for backwards compatibility only. */BGD_DECLARE(char *) gdImageStringTTF (gdImage * im, int *brect, int fg, char *fontlist, double ptsize, double angle, int x, int y, char *string);/* FreeType 2 text output */BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist, double ptsize, double angle, int x, int y, char *string);/* 2.0.5: provides an extensible way to pass additional parameters. Thanks to Wez Furlong, sorry for the delay. */ typedef struct { int flags; /* Logical OR of gdFTEX_ values */ double linespacing; /* fine tune line spacing for '\n' */ int charmap; /* TBB: 2.0.12: may be gdFTEX_Unicode, gdFTEX_Shift_JIS, or gdFTEX_Big5; when not specified, maps are searched for in the above order. */ int hdpi; /* if (flags & gdFTEX_RESOLUTION) */ int vdpi; /* if (flags & gdFTEX_RESOLUTION) */ char *xshow; /* if (flags & gdFTEX_XSHOW) then, on return, xshow is a malloc'ed string contining xshow position data for the last string. NB. The caller is responsible for gdFree'ing the xshow string. */ char *fontpath; /* if (flags & gdFTEX_RETURNFONTPATHNAME) then, on return, fontpath is a malloc'ed string containing the actual font file path name used, which can be interesting when fontconfig is in use. The caller is responsible for gdFree'ing the fontpath string. */ } gdFTStringExtra, *gdFTStringExtraPtr;#define gdFTEX_LINESPACE 1#define gdFTEX_CHARMAP 2#define gdFTEX_RESOLUTION 4#define gdFTEX_DISABLE_KERNING 8#define gdFTEX_XSHOW 16/* The default unless gdFTUseFontConfig(1); has been called: fontlist is a full or partial font file pathname or list thereof (i.e. just like before 2.0.29) */#define gdFTEX_FONTPATHNAME 32/* Necessary to use fontconfig patterns instead of font pathnames as the fontlist argument, unless gdFTUseFontConfig(1); has been called. New in 2.0.29 */#define gdFTEX_FONTCONFIG 64/* Sometimes interesting when fontconfig is used: the fontpath element of the structure above will contain a gdMalloc'd string copy of the actual font file pathname used, if this flag is set when the call is made */#define gdFTEX_RETURNFONTPATHNAME 128/* If flag is nonzero, the fontlist parameter to gdImageStringFT and gdImageStringFTEx shall be assumed to be a fontconfig font pattern if fontconfig was compiled into gd. This function returns zero if fontconfig is not available, nonzero otherwise. */BGD_DECLARE(int) gdFTUseFontConfig(int flag);/* These are NOT flags; set one in 'charmap' if you set the gdFTEX_CHARMAP bit in 'flags'. */#define gdFTEX_Unicode 0#define gdFTEX_Shift_JIS 1#define gdFTEX_Big5 2BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsize, double angle, int x, int y, char *string, gdFTStringExtraPtr strex);/* Point type for use in polygon drawing. */ typedef struct { int x, y; } gdPoint, *gdPointPtr;BGD_DECLARE(void) gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c);BGD_DECLARE(void) gdImageOpenPolygon (gdImagePtr im, gdPointPtr p, int n, int c);BGD_DECLARE(void) gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c);/* These functions still work with truecolor images, for which they never return error. */BGD_DECLARE(int) gdImageColorAllocate (gdImagePtr im, int r, int g, int b);/* gd 2.0: palette entries with non-opaque transparency are permitted. */BGD_DECLARE(int) gdImageColorAllocateAlpha (gdImagePtr im, int r, int g, int b, int a);/* Assumes opaque is the preferred alpha channel value */BGD_DECLARE(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 */BGD_DECLARE(int) gdImageColorClosestAlpha (gdImagePtr im, int r, int g, int b, int a);/* An alternate method */BGD_DECLARE(int) gdImageColorClosestHWB (gdImagePtr im, int r, int g, int b);/* Returns exact, 100% opaque matches only */BGD_DECLARE(int) gdImageColorExact (gdImagePtr im, int r, int g, int b);/* Returns an exact match only, including alpha */BGD_DECLARE(int) gdImageColorExactAlpha (gdImagePtr im, int r, int g, int b, int a);/* Opaque only */BGD_DECLARE(int) gdImageColorResolve (gdImagePtr im, int r, int g, int b);/* Based on gdImageColorExactAlpha and gdImageColorClosestAlpha */BGD_DECLARE(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))BGD_DECLARE(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 these 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. DIFFERENCES: gdImageCreatePaletteFromTrueColor creates and returns a new image. gdImageTrueColorToPalette modifies an existing image, and the truecolor pixels are discarded. */BGD_DECLARE(gdImagePtr) gdImageCreatePaletteFromTrueColor (gdImagePtr im, int ditherFlag, int colorsWanted);BGD_DECLARE(void) gdImageTrueColorToPalette (gdImagePtr im, int ditherFlag, int colorsWanted);/* Specifies a color index (if a palette image) or an
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?