00001 00002 /* 00003 * THIS FILE IS UNDER RCS - DO NOT MODIFY UNLESS YOU HAVE 00004 * CHECKED IT OUT USING THE COMMAND CHECKOUT. 00005 * 00006 * $Id: gd_8h-source.html 2161 2006-05-19 16:55:03Z paulf $ 00007 * 00008 * Revision history: 00009 * $Log$ 00009 * Revision 1.1 2006/05/19 16:55:02 paulf 00009 * first inclusion 00009 * 00010 * Revision 1.1 2000/02/14 20:05:54 lucky 00011 * Initial revision 00012 * 00013 * 00014 */ 00015 00016 #ifndef GD_H 00017 #define GD_H 1 00018 00019 /* gd.h: declarations file for the gifdraw module. 00020 00021 Written by Tom Boutell, 5/94. 00022 Copyright 1994, Cold Spring Harbor Labs. 00023 Permission granted to use this code in any fashion provided 00024 that this notice is retained and any alterations are 00025 labeled as such. It is requested, but not required, that 00026 you share extensions to this module with us so that we 00027 can incorporate them into new versions. */ 00028 00029 /* stdio is needed for file I/O. */ 00030 #include <stdio.h> 00031 00032 /* This can't be changed, it's part of the GIF specification. */ 00033 00034 #define gdMaxColors 256 00035 00036 /* Image type. See functions below; you will not need to change 00037 the elements directly. Use the provided macros to 00038 access sx, sy, the color table, and colorsTotal for 00039 read-only purposes. */ 00040 00041 typedef struct gdImageStruct { 00042 unsigned char ** pixels; 00043 int sx; 00044 int sy; 00045 int colorsTotal; 00046 int red[gdMaxColors]; 00047 int green[gdMaxColors]; 00048 int blue[gdMaxColors]; 00049 int open[gdMaxColors]; 00050 int transparent; 00051 int *polyInts; 00052 int polyAllocated; 00053 struct gdImageStruct *brush; 00054 struct gdImageStruct *tile; 00055 int brushColorMap[gdMaxColors]; 00056 int tileColorMap[gdMaxColors]; 00057 int styleLength; 00058 int stylePos; 00059 int *style; 00060 int interlace; 00061 } gdImage; 00062 00063 typedef gdImage * gdImagePtr; 00064 00065 typedef struct { 00066 /* # of characters in font */ 00067 int nchars; 00068 /* First character is numbered... (usually 32 = space) */ 00069 int offset; 00070 /* Character width and height */ 00071 int w; 00072 int h; 00073 /* Font data; array of characters, one row after another. 00074 Easily included in code, also easily loaded from 00075 data files. */ 00076 char *data; 00077 } gdFont; 00078 00079 /* Text functions take these. */ 00080 typedef gdFont *gdFontPtr; 00081 00082 /* For backwards compatibility only. Use gdImageSetStyle() 00083 for MUCH more flexible line drawing. Also see 00084 gdImageSetBrush(). */ 00085 #define gdDashSize 4 00086 00087 /* Special colors. */ 00088 00089 #define gdStyled (-2) 00090 #define gdBrushed (-3) 00091 #define gdStyledBrushed (-4) 00092 #define gdTiled (-5) 00093 00094 /* NOT the same as the transparent color index. 00095 This is used in line styles only. */ 00096 #define gdTransparent (-6) 00097 00098 /* Functions to manipulate images. */ 00099 00100 gdImagePtr gdImageCreate(int sx, int sy); 00101 gdImagePtr gdImageCreateFromGif(FILE *fd); 00102 gdImagePtr gdImageCreateFromGd(FILE *in); 00103 gdImagePtr gdImageCreateFromXbm(FILE *fd); 00104 void gdImageDestroy(gdImagePtr im); 00105 void gdImageSetPixel(gdImagePtr im, int x, int y, int color); 00106 int gdImageGetPixel(gdImagePtr im, int x, int y); 00107 void gdImageLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color); 00108 /* For backwards compatibility only. Use gdImageSetStyle() 00109 for much more flexible line drawing. */ 00110 void gdImageDashedLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color); 00111 /* Corners specified (not width and height). Upper left first, lower right 00112 second. */ 00113 void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color); 00114 /* Solid bar. Upper left corner first, lower right corner second. */ 00115 void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color); 00116 int gdImageBoundsSafe(gdImagePtr im, int x, int y); 00117 void gdImageChar(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color); 00118 void gdImageCharUp(gdImagePtr im, gdFontPtr f, int x, int y, char c, int color); 00119 void gdImageString(gdImagePtr im, gdFontPtr f, int x, int y, char *s, int color); 00120 void gdImageStringUp(gdImagePtr im, gdFontPtr f, int x, int y, char *s, int color); 00121 00122 /* Point type for use in polygon drawing. */ 00123 00124 typedef struct { 00125 int x, y; 00126 } gdPoint, *gdPointPtr; 00127 00128 void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c); 00129 void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c); 00130 00131 int gdImageColorAllocate(gdImagePtr im, int r, int g, int b); 00132 int gdImageColorClosest(gdImagePtr im, int r, int g, int b); 00133 int gdImageColorExact(gdImagePtr im, int r, int g, int b); 00134 void gdImageColorDeallocate(gdImagePtr im, int color); 00135 void gdImageColorTransparent(gdImagePtr im, int color); 00136 void gdImageGif(gdImagePtr im, FILE *out); 00137 void gdImageGd(gdImagePtr im, FILE *out); 00138 void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color); 00139 void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color); 00140 void gdImageFill(gdImagePtr im, int x, int y, int color); 00141 void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h); 00142 /* Stretches or shrinks to fit, as needed */ 00143 void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH); 00144 void gdImageSetBrush(gdImagePtr im, gdImagePtr brush); 00145 void gdImageSetTile(gdImagePtr im, gdImagePtr tile); 00146 void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels); 00147 /* On or off (1 or 0) */ 00148 void gdImageInterlace(gdImagePtr im, int interlaceArg); 00149 00150 /* Macros to access information about images. READ ONLY. Changing 00151 these values will NOT have the desired result. */ 00152 #define gdImageSX(im) ((im)->sx) 00153 #define gdImageSY(im) ((im)->sy) 00154 #define gdImageColorsTotal(im) ((im)->colorsTotal) 00155 #define gdImageRed(im, c) ((im)->red[(c)]) 00156 #define gdImageGreen(im, c) ((im)->green[(c)]) 00157 #define gdImageBlue(im, c) ((im)->blue[(c)]) 00158 #define gdImageGetTransparent(im) ((im)->transparent) 00159 #define gdImageGetInterlaced(im) ((im)->interlace) 00160 #endif