Initial revision
[rrdtool.git] / libraries / gd1.3 / gd.h
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 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
97         second. */
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);
108
109 /* Point type for use in polygon drawing. */
110
111 typedef struct {
112         int x, y;
113 } gdPoint, *gdPointPtr;
114
115 void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c);
116 void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c);
117
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);
136
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)
147 #endif