1 #ifndef GD_H 2 #define GD_H 1 3 4 /* gd.h: declarations file for the gifdraw module. 5 6 Written by Tom Boutell, 5/94. 7 Copyright 1994, Cold Spring Harbor Labs. 8 Permission granted to use this code in any fashion provided 9 that this notice is retained and any alterations are 10 labeled as such. It is requested, but not required, that 11 you share extensions to this module with us so that we 12 can incorporate them into new versions. */ 13 14 /* stdio is needed for file I/O. */ 15 #include <stdio.h> 16 17 /* This can't be changed, it's part of the GIF specification. */ 18 19 #define gdMaxColors 256 20 21 /* Image type. See functions below; you will not need to change 22 the elements directly. Use the provided macros to 23 access sx, sy, the color table, and colorsTotal for 24 read-only purposes. */ 25 26 typedef struct gdImageStruct { 27 unsigned char ** pixels; 28 int sx; 29 int sy; 30 int colorsTotal; 31 int red[gdMaxColors]; 32 int green[gdMaxColors]; 33 int blue[gdMaxColors]; 34 int open[gdMaxColors]; 35 int transparent; 36 int *polyInts; 37 int polyAllocated; 38 struct gdImageStruct *brush; 39 struct gdImageStruct *tile; 40 int brushColorMap[gdMaxColors]; 41 int tileColorMap[gdMaxColors]; 42 int styleLength; 43 int stylePos; 44 int *style; 45 int interlace; 46 } gdImage; 47 48 typedef gdImage * gdImagePtr; 49 50 typedef struct { 51 /* # of characters in font */ 52 int nchars; 53 /* First character is numbered... (usually 32 = space) */ 54 int offset; 55 /* Character width and height */ 56 int w; 57 int h; 58 /* Font data; array of characters, one row after another. 59 Easily included in code, also easily loaded from 60 data files. */ 61 char *data; 62 } gdFont; 63 64 /* Text functions take these. */ 65 typedef gdFont *gdFontPtr; 66 67 /* For backwards compatibility only. Use gdImageSetStyle() 68 for MUCH more flexible line drawing. Also see 69 gdImageSetBrush(). */ 70 #define gdDashSize 4 71 72 /* Special colors. */ 73 74 #define gdStyled (-2) 75 #define gdBrushed (-3) 76 #define gdStyledBrushed (-4) 77 #define gdTiled (-5) 78 79 /* NOT the same as the transparent color index. 80 This is used in line styles only. */ 81 #define gdTransparent (-6) 82 83 /* Functions to manipulate images. */ 84 85 gdImagePtr gdImageCreate(int sx, int sy); 86 gdImagePtr gdImageCreateFromGif(FILE *fd); 87 gdImagePtr gdImageCreateFromGd(FILE *in); 88 gdImagePtr gdImageCreateFromXbm(FILE *fd); 89 void gdImageDestroy(gdImagePtr im); 90 void gdImageSetPixel(gdImagePtr im, int x, int y, int color); 91 int gdImageGetPixel(gdImagePtr im, int x, int y); 92 void gdImageLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color); 93 /* For backwards compatibility only. Use gdImageSetStyle() 94 for much more flexible line drawing. */ 95 void gdImageDashedLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color); 96 /* Corners specified (not width and height). Upper left first, lower right 97 second. */ 98 void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color); 99 /* Solid bar. Upper left corner first, lower right corner second. */ 100 void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color); 101 int gdImageBoundsSafe(gdImagePtr im, int x, int y); 102 void gdImageChar(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color); 103 void gdImageCharUp(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color); 104 105 void gdImageString(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color); 106 void gdImageStringUp(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color); 107 /* void gdImageString(gdImagePtr im, gdFontPtr f, int x, int y, char *s, int color); this avoids gcc4 warning */ 108 /* void gdImageStringUp(gdImagePtr im, gdFontPtr f, int x, int y, char *s, int color); this avoids gcc4 warning */ 109 110 void gdImageString16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color); 111 void gdImageStringUp16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color); 112 113 /* Point type for use in polygon drawing. */ 114 115 typedef struct { 116 int x, y; 117 } gdPoint, *gdPointPtr; 118 119 void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c); 120 void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c); 121 122 int gdImageColorAllocate(gdImagePtr im, int r, int g, int b); 123 int gdImageColorClosest(gdImagePtr im, int r, int g, int b); 124 int gdImageColorExact(gdImagePtr im, int r, int g, int b); 125 void gdImageColorDeallocate(gdImagePtr im, int color); 126 void gdImageColorTransparent(gdImagePtr im, int color); 127 void gdImageGif(gdImagePtr im, FILE *out); 128 void gdImageGd(gdImagePtr im, FILE *out); 129 void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color); 130 void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color); 131 void gdImageFill(gdImagePtr im, int x, int y, int color); 132 void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h); 133 /* Stretches or shrinks to fit, as needed */ 134 void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH); 135 void gdImageSetBrush(gdImagePtr im, gdImagePtr brush); 136 void gdImageSetTile(gdImagePtr im, gdImagePtr tile); 137 void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels); 138 /* On or off (1 or 0) */ 139 void gdImageInterlace(gdImagePtr im, int interlaceArg); 140 141 /* Macros to access information about images. READ ONLY. Changing 142 these values will NOT have the desired result. */ 143 #define gdImageSX(im) ((im)->sx) 144 #define gdImageSY(im) ((im)->sy) 145 #define gdImageColorsTotal(im) ((im)->colorsTotal) 146 #define gdImageRed(im, c) ((im)->red[(c)]) 147 #define gdImageGreen(im, c) ((im)->green[(c)]) 148 #define gdImageBlue(im, c) ((im)->blue[(c)]) 149 #define gdImageGetTransparent(im) ((im)->transparent) 150 #define gdImageGetInterlaced(im) ((im)->interlace) 151 #endif 152