| 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, char c, int color); | 
|---|
| 104 | void gdImageString(gdImagePtr im, gdFontPtr f, int x, int y, char *s, int color); | 
|---|
| 105 | void gdImageStringUp(gdImagePtr im, gdFontPtr f, int x, int y, char *s, int color); | 
|---|
| 106 |  | 
|---|
| 107 | /* Point type for use in polygon drawing. */ | 
|---|
| 108 |  | 
|---|
| 109 | typedef struct { | 
|---|
| 110 | int x, y; | 
|---|
| 111 | } gdPoint, *gdPointPtr; | 
|---|
| 112 |  | 
|---|
| 113 | void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c); | 
|---|
| 114 | void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c); | 
|---|
| 115 |  | 
|---|
| 116 | int gdImageColorAllocate(gdImagePtr im, int r, int g, int b); | 
|---|
| 117 | int gdImageColorClosest(gdImagePtr im, int r, int g, int b); | 
|---|
| 118 | int gdImageColorExact(gdImagePtr im, int r, int g, int b); | 
|---|
| 119 | void gdImageColorDeallocate(gdImagePtr im, int color); | 
|---|
| 120 | void gdImageColorTransparent(gdImagePtr im, int color); | 
|---|
| 121 | void gdImageGif(gdImagePtr im, FILE *out); | 
|---|
| 122 | void gdImageGd(gdImagePtr im, FILE *out); | 
|---|
| 123 | void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color); | 
|---|
| 124 | void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color); | 
|---|
| 125 | void gdImageFill(gdImagePtr im, int x, int y, int color); | 
|---|
| 126 | void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h); | 
|---|
| 127 | /* Stretches or shrinks to fit, as needed */ | 
|---|
| 128 | void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH); | 
|---|
| 129 | void gdImageSetBrush(gdImagePtr im, gdImagePtr brush); | 
|---|
| 130 | void gdImageSetTile(gdImagePtr im, gdImagePtr tile); | 
|---|
| 131 | void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels); | 
|---|
| 132 | /* On or off (1 or 0) */ | 
|---|
| 133 | void gdImageInterlace(gdImagePtr im, int interlaceArg); | 
|---|
| 134 |  | 
|---|
| 135 | /* Macros to access information about images. READ ONLY. Changing | 
|---|
| 136 | these values will NOT have the desired result. */ | 
|---|
| 137 | #define gdImageSX(im) ((im)->sx) | 
|---|
| 138 | #define gdImageSY(im) ((im)->sy) | 
|---|
| 139 | #define gdImageColorsTotal(im) ((im)->colorsTotal) | 
|---|
| 140 | #define gdImageRed(im, c) ((im)->red[(c)]) | 
|---|
| 141 | #define gdImageGreen(im, c) ((im)->green[(c)]) | 
|---|
| 142 | #define gdImageBlue(im, c) ((im)->blue[(c)]) | 
|---|
| 143 | #define gdImageGetTransparent(im) ((im)->transparent) | 
|---|
| 144 | #define gdImageGetInterlaced(im) ((im)->interlace) | 
|---|
| 145 | #endif | 
|---|