~ubuntu-branches/ubuntu/wily/ntop/wily-proposed

« back to all changes in this revision

Viewing changes to gdchart0.94c/gd-1.8.3/gd.h

  • Committer: Bazaar Package Importer
  • Author(s): Dennis Schoen
  • Date: 2002-04-12 11:38:47 UTC
  • Revision ID: james.westby@ubuntu.com-20020412113847-4k4yydw0pzybc6g8
Tags: upstream-2.0.0
ImportĀ upstreamĀ versionĀ 2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef GD_H
 
2
#define GD_H 1
 
3
 
 
4
#ifdef __cplusplus
 
5
extern "C" {
 
6
#endif
 
7
 
 
8
/* gd.h: declarations file for the graphic-draw module.
 
9
 * Permission to use, copy, modify, and distribute this software and its
 
10
 * documentation for any purpose and without fee is hereby granted, provided
 
11
 * that the above copyright notice appear in all copies and that both that
 
12
 * copyright notice and this permission notice appear in supporting
 
13
 * documentation.  This software is provided "AS IS." Thomas Boutell and
 
14
 * Boutell.Com, Inc. disclaim all warranties, either express or implied, 
 
15
 * including but not limited to implied warranties of merchantability and 
 
16
 * fitness for a particular purpose, with respect to this code and accompanying
 
17
 * documentation. */
 
18
 
 
19
/* stdio is needed for file I/O. */
 
20
#include <stdio.h>
 
21
#include "gd_io.h"
 
22
 
 
23
/* This can't be changed in the current palette-only version of gd. */
 
24
 
 
25
#define gdMaxColors 256
 
26
 
 
27
/* Image type. See functions below; you will not need to change
 
28
        the elements directly. Use the provided macros to
 
29
        access sx, sy, the color table, and colorsTotal for 
 
30
        read-only purposes. */
 
31
 
 
32
typedef struct gdImageStruct {
 
33
        unsigned char ** pixels;
 
34
        int sx;
 
35
        int sy;
 
36
        int colorsTotal;
 
37
        int red[gdMaxColors];
 
38
        int green[gdMaxColors];
 
39
        int blue[gdMaxColors]; 
 
40
        int open[gdMaxColors];
 
41
        int transparent;
 
42
        int *polyInts;
 
43
        int polyAllocated;
 
44
        struct gdImageStruct *brush;
 
45
        struct gdImageStruct *tile;     
 
46
        int brushColorMap[gdMaxColors];
 
47
        int tileColorMap[gdMaxColors];
 
48
        int styleLength;
 
49
        int stylePos;
 
50
        int *style;
 
51
        int interlace;
 
52
} gdImage;
 
53
 
 
54
typedef gdImage * gdImagePtr;
 
55
 
 
56
typedef struct {
 
57
        /* # of characters in font */
 
58
        int nchars;
 
59
        /* First character is numbered... (usually 32 = space) */
 
60
        int offset;
 
61
        /* Character width and height */
 
62
        int w;
 
63
        int h;
 
64
        /* Font data; array of characters, one row after another.
 
65
                Easily included in code, also easily loaded from
 
66
                data files. */
 
67
        char *data;
 
68
} gdFont;
 
69
 
 
70
/* Text functions take these. */
 
71
typedef gdFont *gdFontPtr;
 
72
 
 
73
/* For backwards compatibility only. Use gdImageSetStyle()
 
74
        for MUCH more flexible line drawing. Also see
 
75
        gdImageSetBrush(). */
 
76
#define gdDashSize 4
 
77
 
 
78
/* Special colors. */
 
79
 
 
80
#define gdStyled (-2)
 
81
#define gdBrushed (-3)
 
82
#define gdStyledBrushed (-4)
 
83
#define gdTiled (-5)
 
84
 
 
85
/* NOT the same as the transparent color index.
 
86
        This is used in line styles only. */
 
87
#define gdTransparent (-6)
 
88
 
 
89
/* Functions to manipulate images. */
 
90
 
 
91
gdImagePtr gdImageCreate(int sx, int sy);
 
92
gdImagePtr gdImageCreateFromPng(FILE *fd);
 
93
gdImagePtr gdImageCreateFromPngCtx(gdIOCtxPtr in);
 
94
 
 
95
/* A custom data source. */
 
96
/* The source function must return -1 on error, otherwise the number
 
97
        of bytes fetched. 0 is EOF, not an error! */
 
98
/* context will be passed to your source function. */
 
99
 
 
100
typedef struct {
 
101
        int (*source) (void *context, char *buffer, int len);
 
102
        void *context;
 
103
} gdSource, *gdSourcePtr;
 
104
 
 
105
gdImagePtr gdImageCreateFromPngSource(gdSourcePtr in);
 
106
 
 
107
gdImagePtr gdImageCreateFromGd(FILE *in);
 
108
gdImagePtr gdImageCreateFromGdCtx(gdIOCtxPtr in);
 
109
 
 
110
gdImagePtr gdImageCreateFromGd2(FILE *in);
 
111
gdImagePtr gdImageCreateFromGd2Ctx(gdIOCtxPtr in);
 
112
 
 
113
gdImagePtr gdImageCreateFromGd2Part(FILE *in, int srcx, int srcy, int w, int h);
 
114
gdImagePtr gdImageCreateFromGd2PartCtx(gdIOCtxPtr in, int srcx, int srcy, int w, int h);
 
115
 
 
116
gdImagePtr gdImageCreateFromXbm(FILE *fd);
 
117
 
 
118
void gdImageDestroy(gdImagePtr im);
 
119
void gdImageSetPixel(gdImagePtr im, int x, int y, int color);
 
120
int gdImageGetPixel(gdImagePtr im, int x, int y);
 
121
void gdImageLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
 
122
/* For backwards compatibility only. Use gdImageSetStyle()
 
123
        for much more flexible line drawing. */
 
124
void gdImageDashedLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
 
125
/* Corners specified (not width and height). Upper left first, lower right
 
126
        second. */
 
127
void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
 
128
/* Solid bar. Upper left corner first, lower right corner second. */
 
129
void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
 
130
int gdImageBoundsSafe(gdImagePtr im, int x, int y);
 
131
void gdImageChar(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
 
132
void gdImageCharUp(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
 
133
void gdImageString(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);
 
134
void gdImageStringUp(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);
 
135
void gdImageString16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
 
136
void gdImageStringUp16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
 
137
 
 
138
char *gdImageStringTTF(gdImage *im, int *brect, int fg, char *fontname,
 
139
                double ptsize, double angle, int x, int y, char *string);
 
140
 
 
141
/* Point type for use in polygon drawing. */
 
142
 
 
143
typedef struct {
 
144
        int x, y;
 
145
} gdPoint, *gdPointPtr;
 
146
 
 
147
void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c);
 
148
void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c);
 
149
 
 
150
int gdImageColorAllocate(gdImagePtr im, int r, int g, int b);
 
151
int gdImageColorClosest(gdImagePtr im, int r, int g, int b);
 
152
int gdImageColorExact(gdImagePtr im, int r, int g, int b);
 
153
int gdImageColorResolve(gdImagePtr im, int r, int g, int b);
 
154
void gdImageColorDeallocate(gdImagePtr im, int color);
 
155
void gdImageColorTransparent(gdImagePtr im, int color);
 
156
void gdImagePaletteCopy(gdImagePtr dst, gdImagePtr src);
 
157
void gdImagePng(gdImagePtr im, FILE *out);
 
158
void gdImagePngCtx(gdImagePtr im, gdIOCtx *out);
 
159
 
 
160
void gdImageWBMP(gdImagePtr image, int fg, FILE *out);
 
161
void gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out);
 
162
void *gdImageWBMPPtr(gdImagePtr im, int *size, int fg);
 
163
gdImagePtr gdImageCreateFromWBMP(FILE *inFile);
 
164
gdImagePtr gdImageCreateFromWBMPCtx(gdIOCtx *infile); 
 
165
 
 
166
 
 
167
void gdImageJpeg(gdImagePtr im, FILE *out, int quality);
 
168
void gdImageJpegCtx(gdImagePtr im, gdIOCtx *out, int quality);
 
169
void *gdImageJpegPtr(gdImagePtr im, int *size, int quality);
 
170
gdImagePtr gdImageCreateFromJpeg(FILE *infile);
 
171
gdImagePtr gdImageCreateFromJpegCtx(gdIOCtx *infile);
 
172
 
 
173
/* A custom data sink. For backwards compatibility. Use
 
174
        gdIOCtx instead. */
 
175
/* The sink function must return -1 on error, otherwise the number
 
176
        of bytes written, which must be equal to len. */
 
177
/* context will be passed to your sink function. */
 
178
typedef struct {
 
179
        int (*sink) (void *context, const char *buffer, int len);
 
180
        void *context;
 
181
} gdSink, *gdSinkPtr;
 
182
 
 
183
void gdImagePngToSink(gdImagePtr im, gdSinkPtr out);
 
184
 
 
185
void gdImageGd(gdImagePtr im, FILE *out);
 
186
void gdImageGd2(gdImagePtr im, FILE *out, int cs, int fmt);
 
187
void* gdImagePngPtr(gdImagePtr im, int *size);
 
188
void* gdImageGdPtr(gdImagePtr im, int *size);
 
189
void* gdImageGd2Ptr(gdImagePtr im, int cs, int fmt, int *size);
 
190
void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color);
 
191
void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color);
 
192
void gdImageFill(gdImagePtr im, int x, int y, int color);
 
193
void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h);
 
194
void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, 
 
195
                        int srcX, int srcY, int w, int h, int pct);
 
196
void gdImageCopyMergeGray(gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
 
197
                        int srcX, int srcY, int w, int h, int pct);
 
198
 
 
199
/* Stretches or shrinks to fit, as needed */
 
200
void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);
 
201
void gdImageSetBrush(gdImagePtr im, gdImagePtr brush);
 
202
void gdImageSetTile(gdImagePtr im, gdImagePtr tile);
 
203
void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels);
 
204
/* On or off (1 or 0) */
 
205
void gdImageInterlace(gdImagePtr im, int interlaceArg);
 
206
 
 
207
/* Macros to access information about images. READ ONLY. Changing
 
208
        these values will NOT have the desired result. */
 
209
#define gdImageSX(im) ((im)->sx)
 
210
#define gdImageSY(im) ((im)->sy)
 
211
#define gdImageColorsTotal(im) ((im)->colorsTotal)
 
212
#define gdImageRed(im, c) ((im)->red[(c)])
 
213
#define gdImageGreen(im, c) ((im)->green[(c)])
 
214
#define gdImageBlue(im, c) ((im)->blue[(c)])
 
215
#define gdImageGetTransparent(im) ((im)->transparent)
 
216
#define gdImageGetInterlaced(im) ((im)->interlace)
 
217
 
 
218
/* I/O Support routines. */
 
219
 
 
220
gdIOCtx* gdNewFileCtx(FILE*);
 
221
gdIOCtx* gdNewDynamicCtx(int, void*);
 
222
gdIOCtx* gdNewSSCtx(gdSourcePtr in, gdSinkPtr out);
 
223
void* gdDPExtractData(struct gdIOCtx* ctx, int *size);
 
224
 
 
225
 
 
226
#define GD2_CHUNKSIZE           128 
 
227
#define GD2_CHUNKSIZE_MIN       64
 
228
#define GD2_CHUNKSIZE_MAX       4096
 
229
 
 
230
#define GD2_VERS                1
 
231
#define GD2_ID                  "gd2"
 
232
#define GD2_FMT_RAW             1
 
233
#define GD2_FMT_COMPRESSED      2
 
234
 
 
235
/* Image comparison definitions */
 
236
int gdImageCompare(gdImagePtr im1, gdImagePtr im2);
 
237
 
 
238
#define GD_CMP_IMAGE            1       /* Actual image IS different */
 
239
#define GD_CMP_NUM_COLORS       2       /* Number of Colours in pallette differ */
 
240
#define GD_CMP_COLOR            4       /* Image colours differ */
 
241
#define GD_CMP_SIZE_X           8       /* Image width differs */
 
242
#define GD_CMP_SIZE_Y           16      /* Image heights differ */
 
243
#define GD_CMP_TRANSPARENT      32      /* Transparent colour */
 
244
#define GD_CMP_BACKGROUND       64      /* Background colour */
 
245
#define GD_CMP_INTERLACE        128     /* Interlaced setting */
 
246
 
 
247
#ifdef __cplusplus
 
248
}
 
249
#endif
 
250
 
 
251
#endif /* GD_H */