4 /* gd.h: declarations file for the gifdraw module.
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. */
14 /* stdio is needed for file I/O. */
17 /* This can't be changed, it's part of the GIF specification. */
19 #define gdMaxColors 256
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. */
26 typedef struct gdImageStruct {
27 unsigned char ** pixels;
32 int green[gdMaxColors];
33 int blue[gdMaxColors];
34 int open[gdMaxColors];
38 struct gdImageStruct *brush;
39 struct gdImageStruct *tile;
40 int brushColorMap[gdMaxColors];
41 int tileColorMap[gdMaxColors];
48 typedef gdImage * gdImagePtr;
51 /* # of characters in font */
53 /* First character is numbered... (usually 32 = space) */
55 /* Character width and height */
58 /* Font data; array of characters, one row after another.
59 Easily included in code, also easily loaded from
64 /* Text functions take these. */
65 typedef gdFont *gdFontPtr;
67 /* For backwards compatibility only. Use gdImageSetStyle()
68 for MUCH more flexible line drawing. Also see
75 #define gdBrushed (-3)
76 #define gdStyledBrushed (-4)
79 /* NOT the same as the transparent color index.
80 This is used in line styles only. */
81 #define gdTransparent (-6)
83 /* Functions to manipulate images. */
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 xA, int yA, int xB, int yB, int color);
93 /* For backwards compatibility only. Use gdImageSetStyle()
94 for much more flexible line drawing. */
95 void gdImageDashedLine(gdImagePtr im, int xA, int yA, int xB, int yB, int color);
96 /* Corners specified (not width and height). Upper left first, lower right
98 void gdImageRectangle(gdImagePtr im, int xA, int yA, int xB, int yB, int color);
99 /* Solid bar. Upper left corner first, lower right corner second. */
100 void gdImageFilledRectangle(gdImagePtr im, int xA, int yA, int xB, int yB, 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 void gdImageString(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);
105 void gdImageStringUp(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);
106 void gdImageString16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
107 void gdImageStringUp16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
109 /* Point type for use in polygon drawing. */
113 } gdPoint, *gdPointPtr;
115 void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c);
116 void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c);
118 int gdImageColorAllocate(gdImagePtr im, int r, int g, int b);
119 int gdImageColorClosest(gdImagePtr im, int r, int g, int b);
120 int gdImageColorExact(gdImagePtr im, int r, int g, int b);
121 void gdImageColorDeallocate(gdImagePtr im, int color);
122 void gdImageColorTransparent(gdImagePtr im, int color);
123 void gdImageGif(gdImagePtr im, FILE *out);
124 void gdImageGd(gdImagePtr im, FILE *out);
125 void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color);
126 void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color);
127 void gdImageFill(gdImagePtr im, int x, int y, int color);
128 void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h);
129 /* Stretches or shrinks to fit, as needed */
130 void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);
131 void gdImageSetBrush(gdImagePtr im, gdImagePtr brush);
132 void gdImageSetTile(gdImagePtr im, gdImagePtr tile);
133 void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels);
134 /* On or off (1 or 0) */
135 void gdImageInterlace(gdImagePtr im, int interlaceArg);
137 /* Macros to access information about images. READ ONLY. Changing
138 these values will NOT have the desired result. */
139 #define gdImageSX(im) ((im)->sx)
140 #define gdImageSY(im) ((im)->sy)
141 #define gdImageColorsTotal(im) ((im)->colorsTotal)
142 #define gdImageRed(im, c) ((im)->red[(c)])
143 #define gdImageGreen(im, c) ((im)->green[(c)])
144 #define gdImageBlue(im, c) ((im)->blue[(c)])
145 #define gdImageGetTransparent(im) ((im)->transparent)
146 #define gdImageGetInterlaced(im) ((im)->interlace)