00001 #ifndef GD_H
00002 #define GD_H 1
00003
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <stdio.h>
00021 #include "gd_io.h"
00022
00023
00024
00025 #define gdMaxColors 256
00026
00027
00028
00029
00030
00031
00032 typedef struct gdImageStruct {
00033 unsigned char ** pixels;
00034 int sx;
00035 int sy;
00036 int colorsTotal;
00037 int red[gdMaxColors];
00038 int green[gdMaxColors];
00039 int blue[gdMaxColors];
00040 int open[gdMaxColors];
00041 int transparent;
00042 int *polyInts;
00043 int polyAllocated;
00044 struct gdImageStruct *brush;
00045 struct gdImageStruct *tile;
00046 int brushColorMap[gdMaxColors];
00047 int tileColorMap[gdMaxColors];
00048 int styleLength;
00049 int stylePos;
00050 int *style;
00051 int interlace;
00052 } gdImage;
00053
00054 typedef gdImage * gdImagePtr;
00055
00056 typedef struct {
00057
00058 int nchars;
00059
00060 int offset;
00061
00062 int w;
00063 int h;
00064
00065
00066
00067 char *data;
00068 } gdFont;
00069
00070
00071 typedef gdFont *gdFontPtr;
00072
00073
00074
00075
00076 #define gdDashSize 4
00077
00078
00079
00080 #define gdStyled (-2)
00081 #define gdBrushed (-3)
00082 #define gdStyledBrushed (-4)
00083 #define gdTiled (-5)
00084
00085
00086
00087 #define gdTransparent (-6)
00088
00089
00090
00091 gdImagePtr gdImageCreate(int sx, int sy);
00092 gdImagePtr gdImageCreateFromPng(FILE *fd);
00093 gdImagePtr gdImageCreateFromPngCtx(gdIOCtxPtr in);
00094
00095
00096
00097
00098
00099
00100 typedef struct {
00101 int (*source) (void *context, char *buffer, int len);
00102 void *context;
00103 } gdSource, *gdSourcePtr;
00104
00105 gdImagePtr gdImageCreateFromPngSource(gdSourcePtr in);
00106
00107 gdImagePtr gdImageCreateFromGd(FILE *in);
00108 gdImagePtr gdImageCreateFromGdCtx(gdIOCtxPtr in);
00109
00110 gdImagePtr gdImageCreateFromGd2(FILE *in);
00111 gdImagePtr gdImageCreateFromGd2Ctx(gdIOCtxPtr in);
00112
00113 gdImagePtr gdImageCreateFromGd2Part(FILE *in, int srcx, int srcy, int w, int h);
00114 gdImagePtr gdImageCreateFromGd2PartCtx(gdIOCtxPtr in, int srcx, int srcy, int w, int h);
00115
00116 gdImagePtr gdImageCreateFromXbm(FILE *fd);
00117
00118 void gdImageDestroy(gdImagePtr im);
00119 void gdImageSetPixel(gdImagePtr im, int x, int y, int color);
00120 int gdImageGetPixel(gdImagePtr im, int x, int y);
00121 void gdImageLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00122
00123
00124 void gdImageDashedLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00125
00126
00127 void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00128
00129 void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00130 int gdImageBoundsSafe(gdImagePtr im, int x, int y);
00131 void gdImageChar(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
00132 void gdImageCharUp(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
00133 void gdImageString(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);
00134 void gdImageStringUp(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);
00135 void gdImageString16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
00136 void gdImageStringUp16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
00137
00138 char *gdImageStringTTF(gdImage *im, int *brect, int fg, char *fontname,
00139 double ptsize, double angle, int x, int y, char *string);
00140
00141
00142
00143 typedef struct {
00144 int x, y;
00145 } gdPoint, *gdPointPtr;
00146
00147 void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c);
00148 void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c);
00149
00150 int gdImageColorAllocate(gdImagePtr im, int r, int g, int b);
00151 int gdImageColorClosest(gdImagePtr im, int r, int g, int b);
00152 int gdImageColorExact(gdImagePtr im, int r, int g, int b);
00153 int gdImageColorResolve(gdImagePtr im, int r, int g, int b);
00154 void gdImageColorDeallocate(gdImagePtr im, int color);
00155 void gdImageColorTransparent(gdImagePtr im, int color);
00156 void gdImagePaletteCopy(gdImagePtr dst, gdImagePtr src);
00157 void gdImagePng(gdImagePtr im, FILE *out);
00158 void gdImagePngCtx(gdImagePtr im, gdIOCtx *out);
00159
00160
00161
00162
00163
00164 typedef struct {
00165 int (*sink) (void *context, const char *buffer, int len);
00166 void *context;
00167 } gdSink, *gdSinkPtr;
00168
00169 void gdImagePngToSink(gdImagePtr im, gdSinkPtr out);
00170
00171 void gdImageGd(gdImagePtr im, FILE *out);
00172 void gdImageGd2(gdImagePtr im, FILE *out, int cs, int fmt);
00173 void* gdImagePngPtr(gdImagePtr im, int *size);
00174 void* gdImageGdPtr(gdImagePtr im, int *size);
00175 void* gdImageGd2Ptr(gdImagePtr im, int cs, int fmt, int *size);
00176 void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color);
00177 void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color);
00178 void gdImageFill(gdImagePtr im, int x, int y, int color);
00179 void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h);
00180 void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
00181 int srcX, int srcY, int w, int h, int pct);
00182 void gdImageCopyMergeGray(gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
00183 int srcX, int srcY, int w, int h, int pct);
00184
00185
00186 void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);
00187 void gdImageSetBrush(gdImagePtr im, gdImagePtr brush);
00188 void gdImageSetTile(gdImagePtr im, gdImagePtr tile);
00189 void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels);
00190
00191 void gdImageInterlace(gdImagePtr im, int interlaceArg);
00192
00193
00194
00195 #define gdImageSX(im) ((im)->sx)
00196 #define gdImageSY(im) ((im)->sy)
00197 #define gdImageColorsTotal(im) ((im)->colorsTotal)
00198 #define gdImageRed(im, c) ((im)->red[(c)])
00199 #define gdImageGreen(im, c) ((im)->green[(c)])
00200 #define gdImageBlue(im, c) ((im)->blue[(c)])
00201 #define gdImageGetTransparent(im) ((im)->transparent)
00202 #define gdImageGetInterlaced(im) ((im)->interlace)
00203
00204
00205
00206 gdIOCtx* gdNewFileCtx(FILE*);
00207 gdIOCtx* gdNewDynamicCtx(int, void*);
00208 gdIOCtx* gdNewSSCtx(gdSourcePtr in, gdSinkPtr out);
00209 void* gdDPExtractData(struct gdIOCtx* ctx, int *size);
00210
00211
00212 #define GD2_CHUNKSIZE 128
00213 #define GD2_CHUNKSIZE_MIN 64
00214 #define GD2_CHUNKSIZE_MAX 4096
00215
00216 #define GD2_VERS 1
00217 #define GD2_ID "gd2"
00218 #define GD2_FMT_RAW 1
00219 #define GD2_FMT_COMPRESSED 2
00220
00221
00222 int gdImageCompare(gdImagePtr im1, gdImagePtr im2);
00223
00224 #define GD_CMP_IMAGE 1
00225 #define GD_CMP_NUM_COLORS 2
00226 #define GD_CMP_COLOR 4
00227 #define GD_CMP_SIZE_X 8
00228 #define GD_CMP_SIZE_Y 16
00229 #define GD_CMP_TRANSPARENT 32
00230 #define GD_CMP_BACKGROUND 64
00231 #define GD_CMP_INTERLACE 128
00232
00233 #ifdef __cplusplus
00234 }
00235 #endif
00236
00237 #endif