gd.h

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

H
796
字号
#ifdef __cplusplusextern "C" {#endif#ifndef GD_H#define GD_H 1/* Do the DLL dance: dllexport when building the DLL,	dllimport when importing from it, nothing when	not on Silly Silly Windows (tm Aardman Productions). *//* 2.0.20: for headers *//* 2.0.24: __stdcall also needed for Visual BASIC 	and other languages. This breaks ABI compatibility	with previous DLL revs, but it's necessary. *//* 2.0.29: WIN32 programmers can declare the NONDLL macro if they	wish to build gd as a static library or by directly including	the gd sources in a project. */#ifndef WIN32#define NONDLL 1#endif /* WIN32 */#ifdef NONDLL#define BGD_DECLARE(rt) extern rt#else#ifdef BGDWIN32#define BGD_DECLARE(rt) __declspec(dllexport) rt __stdcall#else#define BGD_DECLARE(rt) __declspec(dllimport) rt _stdcall#endif /* BGDWIN32 */#endif /* NONDLL *//* 2.0.20: for actual storage of exported data, functions don't need this,  currently needed only for font pointers */#ifdef NONDLL/* 2.0.25: bring back extern */#define BGD_EXPORT_DATA_PROT extern#define BGD_EXPORT_DATA_IMPL#else#ifdef BGDWIN32#define BGD_EXPORT_DATA_PROT __declspec(dllexport) extern#define BGD_EXPORT_DATA_IMPL __declspec(dllexport)#else#define BGD_EXPORT_DATA_PROT __declspec(dllimport) extern#define BGD_EXPORT_DATA_IMPL __declspec(dllimport) #endif /* BGDWIN32 */#endif /* NONDLL */#ifdef __cplusplusextern "C"{#endif/* some might want to set DEFAULT_FONTPATH from configure in config.h *//* 2.0.23: more Type 1 fonts */#ifndef DEFAULT_FONTPATH/* default fontpath for unix systems  - whatever happened to standards ! */#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:/usr/lib/X11/fonts/Type1:/usr/openwin/lib/X11/fonts/Type1"#endif#ifndef PATHSEPARATOR#define PATHSEPARATOR ":"#endif/* gd.h: declarations file for the graphic-draw module. * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation.  This software is provided "AS IS." Thomas Boutell and * Boutell.Com, Inc. disclaim all warranties, either express or implied,  * including but not limited to implied warranties of merchantability and  * fitness for a particular purpose, with respect to this code and accompanying * documentation. *//* stdio is needed for file I/O. */#include <stdio.h>#include "gd_io.h"/* The maximum number of palette entries in palette-based images.	In the wonderful new world of gd 2.0, you can of course have	many more colors when using truecolor mode. */#define gdMaxColors 256/* Image type. See functions below; you will not need to change	the elements directly. Use the provided macros to	access sx, sy, the color table, and colorsTotal for 	read-only purposes. *//* If 'truecolor' is set true, the image is truecolor; 	pixels are represented by integers, which	must be 32 bits wide or more. 	True colors are repsented as follows:	ARGB	Where 'A' (alpha channel) occupies only the	LOWER 7 BITS of the MSB. This very small 	loss of alpha channel resolution allows gd 2.x	to keep backwards compatibility by allowing	signed integers to be used to represent colors,	and negative numbers to represent special cases,	just as in gd 1.x. */#define gdAlphaMax 127#define gdAlphaOpaque 0#define gdAlphaTransparent 127#define gdRedMax 255#define gdGreenMax 255#define gdBlueMax 255#define gdTrueColorGetAlpha(c) (((c) & 0x7F000000) >> 24)#define gdTrueColorGetRed(c) (((c) & 0xFF0000) >> 16)#define gdTrueColorGetGreen(c) (((c) & 0x00FF00) >> 8)#define gdTrueColorGetBlue(c) ((c) & 0x0000FF)/* This function accepts truecolor pixel values only. The 	source color is composited with the destination color	based on the alpha channel value of the source color.	The resulting color is opaque. */   BGD_DECLARE(int) gdAlphaBlend (int dest, int src);  typedef struct gdImageStruct  {    /* Palette-based image pixels */    unsigned char **pixels;    int sx;    int sy;    /* These are valid in palette images only. See also       'alpha', which appears later in the structure to       preserve binary backwards compatibility */    int colorsTotal;    int red[gdMaxColors];    int green[gdMaxColors];    int blue[gdMaxColors];    int open[gdMaxColors];    /* For backwards compatibility, this is set to the       first palette entry with 100% transparency,       and is also set and reset by the        gdImageColorTransparent function. Newer       applications can allocate palette entries       with any desired level of transparency; however,       bear in mind that many viewers, notably       many web browsers, fail to implement       full alpha channel for PNG and provide       support for full opacity or transparency only. */    int transparent;    int *polyInts;    int polyAllocated;    struct gdImageStruct *brush;    struct gdImageStruct *tile;    int brushColorMap[gdMaxColors];    int tileColorMap[gdMaxColors];    int styleLength;    int stylePos;    int *style;    int interlace;    /* New in 2.0: thickness of line. Initialized to 1. */    int thick;    /* New in 2.0: alpha channel for palettes. Note that only       Macintosh Internet Explorer and (possibly) Netscape 6       really support multiple levels of transparency in       palettes, to my knowledge, as of 2/15/01. Most       common browsers will display 100% opaque and       100% transparent correctly, and do something        unpredictable and/or undesirable for levels       in between. TBB */    int alpha[gdMaxColors];    /* Truecolor flag and pixels. New 2.0 fields appear here at the       end to minimize breakage of existing object code. */    int trueColor;    int **tpixels;    /* Should alpha channel be copied, or applied, each time a       pixel is drawn? This applies to truecolor images only.       No attempt is made to alpha-blend in palette images,       even if semitransparent palette entries exist.        To do that, build your image as a truecolor image,       then quantize down to 8 bits. */    int alphaBlendingFlag;    /* Should the alpha channel of the image be saved? This affects       PNG at the moment; other future formats may also       have that capability. JPEG doesn't. */    int saveAlphaFlag;    /* There should NEVER BE ACCESSOR MACROS FOR ITEMS BELOW HERE, so this       part of the structure can be safely changed in new releases. */    /* 2.0.12: anti-aliased globals. 2.0.26: just a few vestiges after      switching to the fast, memory-cheap implementation from PHP-gd. */    int AA;    int AA_color;    int AA_dont_blend;    /* 2.0.12: simple clipping rectangle. These values      must be checked for safety when set; please use      gdImageSetClip */    int cx1;    int cy1;    int cx2;    int cy2;  }  gdImage;  typedef gdImage *gdImagePtr;  typedef struct  {    /* # of characters in font */    int nchars;    /* First character is numbered... (usually 32 = space) */    int offset;    /* Character width and height */    int w;    int h;    /* Font data; array of characters, one row after another.       Easily included in code, also easily loaded from       data files. */    char *data;  }  gdFont;/* Text functions take these. */  typedef gdFont *gdFontPtr;/* For backwards compatibility only. Use gdImageSetStyle()	for MUCH more flexible line drawing. Also see	gdImageSetBrush(). */#define gdDashSize 4/* Special colors. */#define gdStyled (-2)#define gdBrushed (-3)#define gdStyledBrushed (-4)#define gdTiled (-5)/* NOT the same as the transparent color index.	This is used in line styles only. */#define gdTransparent (-6)#define gdAntiAliased (-7)/* Functions to manipulate images. *//* Creates a palette-based image (up to 256 colors). */BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy);/* An alternate name for the above (2.0). */#define gdImageCreatePalette gdImageCreate/* Creates a truecolor image (millions of colors). */BGD_DECLARE(gdImagePtr) gdImageCreateTrueColor (int sx, int sy);/* Creates an image from various file types. These functions	return a palette or truecolor image based on the	nature of the file being loaded. Truecolor PNG	stays truecolor; palette PNG stays palette-based;	JPEG is always truecolor. */BGD_DECLARE(gdImagePtr) gdImageCreateFromPng (FILE * fd);BGD_DECLARE(gdImagePtr) gdImageCreateFromPngCtx (gdIOCtxPtr in);BGD_DECLARE(gdImagePtr) gdImageCreateFromPngPtr (int size, void *data);

⌨️ 快捷键说明

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