gd.h

来自「Linux/Unix下的绘图函数库(Graphic Drawing Librar」· C头文件 代码 · 共 796 行 · 第 1/3 页

H
796
字号
	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 */BGD_DECLARE(void) gdImageColorTransparent (gdImagePtr im, int color);BGD_DECLARE(void) gdImagePaletteCopy (gdImagePtr dst, gdImagePtr src);BGD_DECLARE(void) gdImageGif (gdImagePtr im, FILE * out);BGD_DECLARE(void) gdImagePng (gdImagePtr im, FILE * out);BGD_DECLARE(void) gdImagePngCtx (gdImagePtr im, gdIOCtx * out);BGD_DECLARE(void) gdImageGifCtx (gdImagePtr im, gdIOCtx * out);/* 2.0.12: Compression level: 0-9 or -1, where 0 is NO COMPRESSION at all,  1 is FASTEST but produces larger files, 9 provides the best  compression (smallest files) but takes a long time to compress, and  -1 selects the default compiled into the zlib library. */BGD_DECLARE(void) gdImagePngEx (gdImagePtr im, FILE * out, int level);BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * out, int level);BGD_DECLARE(void) gdImageWBMP (gdImagePtr image, int fg, FILE * out);BGD_DECLARE(void) gdImageWBMPCtx (gdImagePtr image, int fg, gdIOCtx * out);/* Guaranteed to correctly free memory returned	by the gdImage*Ptr functions */BGD_DECLARE(void) gdFree (void *m);/* Best to free this memory with gdFree(), not free() */BGD_DECLARE(void *) gdImageWBMPPtr (gdImagePtr im, int *size, int fg);/* 100 is highest quality (there is always a little loss with JPEG).	0 is lowest. 10 is about the lowest useful setting. */BGD_DECLARE(void) gdImageJpeg (gdImagePtr im, FILE * out, int quality);BGD_DECLARE(void) gdImageJpegCtx (gdImagePtr im, gdIOCtx * out, int quality);/* Best to free this memory with gdFree(), not free() */BGD_DECLARE(void *) gdImageJpegPtr (gdImagePtr im, int *size, int quality);/* Legal values for Disposal. gdDisposalNone is always used by	the built-in optimizer if previm is passed. */enum {	gdDisposalUnknown,	gdDisposalNone,	gdDisposalRestoreBackground,	gdDisposalRestorePrevious};BGD_DECLARE(void) gdImageGifAnimBegin(gdImagePtr im, FILE *outFile, int GlobalCM, int Loops);BGD_DECLARE(void) gdImageGifAnimAdd(gdImagePtr im, FILE *outFile, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm);BGD_DECLARE(void) gdImageGifAnimEnd(FILE *outFile);BGD_DECLARE(void) gdImageGifAnimBeginCtx(gdImagePtr im, gdIOCtx *out, int GlobalCM, int Loops);BGD_DECLARE(void) gdImageGifAnimAddCtx(gdImagePtr im, gdIOCtx *out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm);BGD_DECLARE(void) gdImageGifAnimEndCtx(gdIOCtx *out);BGD_DECLARE(void *) gdImageGifAnimBeginPtr(gdImagePtr im, int *size, int GlobalCM, int Loops);BGD_DECLARE(void *) gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm);BGD_DECLARE(void *) gdImageGifAnimEndPtr(int *size);/* 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;BGD_DECLARE(void) gdImagePngToSink (gdImagePtr im, gdSinkPtr out);BGD_DECLARE(void) gdImageGd (gdImagePtr im, FILE * out);BGD_DECLARE(void) gdImageGd2 (gdImagePtr im, FILE * out, int cs, int fmt);/* Best to free this memory with gdFree(), not free() */BGD_DECLARE(void *) gdImageGifPtr (gdImagePtr im, int *size);/* Best to free this memory with gdFree(), not free() */BGD_DECLARE(void *) gdImagePngPtr (gdImagePtr im, int *size);BGD_DECLARE(void *) gdImagePngPtrEx (gdImagePtr im, int *size, int level);/* Best to free this memory with gdFree(), not free() */BGD_DECLARE(void *) gdImageGdPtr (gdImagePtr im, int *size);/* Best to free this memory with gdFree(), not free() */BGD_DECLARE(void *) gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size);BGD_DECLARE(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 4BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s,			 int e, int color, int style);BGD_DECLARE(void) gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e,		   int color);BGD_DECLARE(void) gdImageFilledEllipse (gdImagePtr im, int cx, int cy, int w, int h,			     int color);BGD_DECLARE(void) gdImageFillToBorder (gdImagePtr im, int x, int y, int border,			    int color);BGD_DECLARE(void) gdImageFill (gdImagePtr im, int x, int y, int color);BGD_DECLARE(void) gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,		    int srcX, int srcY, int w, int h);BGD_DECLARE(void) gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,			 int srcX, int srcY, int w, int h, int pct);BGD_DECLARE(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. */BGD_DECLARE(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. */BGD_DECLARE(void) gdImageCopyResampled (gdImagePtr dst, gdImagePtr src, int dstX,			     int dstY, int srcX, int srcY, int dstW, int dstH,			     int srcW, int srcH);/* gd 2.0.8: gdImageCopyRotated is added. Source        is a rectangle, with its upper left corner at        srcX and srcY. Destination is the *center* of        the rotated copy. Angle is in degrees, same as        gdImageArc. Floating point destination center        coordinates allow accurate rotation of        objects of odd-numbered width or height. */BGD_DECLARE(void) gdImageCopyRotated (gdImagePtr dst,			   gdImagePtr src,			   double dstX, double dstY,			   int srcX, int srcY,			   int srcWidth, int srcHeight, int angle);BGD_DECLARE(void) gdImageSetBrush (gdImagePtr im, gdImagePtr brush);BGD_DECLARE(void) gdImageSetTile (gdImagePtr im, gdImagePtr tile);BGD_DECLARE(void) gdImageSetAntiAliased (gdImagePtr im, int c);BGD_DECLARE(void) gdImageSetAntiAliasedDontBlend (gdImagePtr im, int c, int dont_blend);BGD_DECLARE(void) gdImageSetStyle (gdImagePtr im, int *style, int noOfPixels);/* Line thickness (defaults to 1). Affects lines, ellipses, 	rectangles, polygons and so forth. */BGD_DECLARE(void) gdImageSetThickness (gdImagePtr im, int thickness);/* On or off (1 or 0) for all three of these. */BGD_DECLARE(void) gdImageInterlace (gdImagePtr im, int interlaceArg);BGD_DECLARE(void) gdImageAlphaBlending (gdImagePtr im, int alphaBlendingArg);BGD_DECLARE(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. */BGD_DECLARE(gdIOCtx *) gdNewFileCtx (FILE *);  /* If data is null, size is ignored and an initial data buffer is    allocated automatically. NOTE: this function assumes gd has the right     to free or reallocate "data" at will! Also note that gd will free     "data" when the IO context is freed. If data is not null, it must point    to memory allocated with gdMalloc, or by a call to gdImage[something]Ptr.    If not, see gdNewDynamicCtxEx for an alternative. */BGD_DECLARE(gdIOCtx *) gdNewDynamicCtx (int size, void *data);  /* 2.0.21: if freeFlag is nonzero, gd will free and/or reallocate "data" as    needed as described above. If freeFlag is zero, gd will never free     or reallocate "data," which means that the context should only be used    for *reading* an image from a memory buffer, or writing an image to a    memory buffer which is already large enough. If the memory buffer is    not large enough and an image write is attempted, the write operation    will fail. Those wishing to write an image to a buffer in memory have    a much simpler alternative in the gdImage[something]Ptr functions. */BGD_DECLARE(gdIOCtx *) gdNewDynamicCtxEx (int size, void *data, int freeFlag);BGD_DECLARE(gdIOCtx *) gdNewSSCtx (gdSourcePtr in, gdSinkPtr out);BGD_DECLARE(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 */BGD_DECLARE(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/* newfangled special effects */#include "gdfx.h"#endif				/* GD_H */#ifdef __cplusplus}#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?