Back to index

wims  3.65+svn20090927
gd.h
Go to the documentation of this file.
00001 #ifndef GD_H
00002 #define GD_H 1
00003 
00004 /* gd.h: declarations file for the gifdraw module.
00005 
00006        Written by Tom Boutell, 5/94.
00007        Copyright 1994, Cold Spring Harbor Labs.
00008        Permission granted to use this code in any fashion provided
00009        that this notice is retained and any alterations are
00010        labeled as such. It is requested, but not required, that
00011        you share extensions to this module with us so that we
00012        can incorporate them into new versions. */
00013 
00014 /* stdio is needed for file I/O. */
00015 #include <stdio.h>
00016 
00017 /* This can't be changed, it's part of the GIF specification. */
00018 
00019 #define gdMaxColors 256
00020 
00021 /* Image type. See functions below; you will not need to change
00022        the elements directly. Use the provided macros to
00023        access sx, sy, the color table, and colorsTotal for 
00024        read-only purposes. */
00025 
00026 typedef struct gdImageStruct {
00027        unsigned char ** pixels;
00028        int sx;
00029        int sy;
00030        int colorsTotal;
00031        int red[gdMaxColors];
00032        int green[gdMaxColors];
00033        int blue[gdMaxColors]; 
00034        int open[gdMaxColors];
00035        int transparent;
00036        int *polyInts;
00037        int polyAllocated;
00038        struct gdImageStruct *brush;
00039        struct gdImageStruct *tile; 
00040        int brushColorMap[gdMaxColors];
00041        int tileColorMap[gdMaxColors];
00042        int styleLength;
00043        int stylePos;
00044        int *style;
00045        int interlace;
00046 } gdImage;
00047 
00048 typedef gdImage * gdImagePtr;
00049 
00050 typedef struct {
00051        /* # of characters in font */
00052        int nchars;
00053        /* First character is numbered... (usually 32 = space) */
00054        int offset;
00055        /* Character width and height */
00056        int w;
00057        int h;
00058        /* Font data; array of characters, one row after another.
00059               Easily included in code, also easily loaded from
00060               data files. */
00061        char *data;
00062 } gdFont;
00063 
00064 /* Text functions take these. */
00065 typedef gdFont *gdFontPtr;
00066 
00067 /* For backwards compatibility only. Use gdImageSetStyle()
00068        for MUCH more flexible line drawing. Also see
00069        gdImageSetBrush(). */
00070 #define gdDashSize 4
00071 
00072 /* Special colors. */
00073 
00074 #define gdStyled (-2)
00075 #define gdBrushed (-3)
00076 #define gdStyledBrushed (-4)
00077 #define gdTiled (-5)
00078 
00079 /* NOT the same as the transparent color index.
00080        This is used in line styles only. */
00081 #define gdTransparent (-6)
00082 
00083 /* Functions to manipulate images. */
00084 
00085 gdImagePtr gdImageCreate(int sx, int sy);
00086 gdImagePtr gdImageCreateFromGif(FILE *fd);
00087 gdImagePtr gdImageCreateFromGd(FILE *in);
00088 gdImagePtr gdImageCreateFromXbm(FILE *fd);
00089 void gdImageDestroy(gdImagePtr im);
00090 void gdImageSetPixel(gdImagePtr im, int x, int y, int color);
00091 int gdImageGetPixel(gdImagePtr im, int x, int y);
00092 void gdImageLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00093 /* For backwards compatibility only. Use gdImageSetStyle()
00094        for much more flexible line drawing. */
00095 void gdImageDashedLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00096 /* Corners specified (not width and height). Upper left first, lower right
00097        second. */
00098 void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00099 /* Solid bar. Upper left corner first, lower right corner second. */
00100 void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00101 int gdImageBoundsSafe(gdImagePtr im, int x, int y);
00102 void gdImageChar(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
00103 void gdImageCharUp(gdImagePtr im, gdFontPtr f, int x, int y, char c, int color);
00104 void gdImageString(gdImagePtr im, gdFontPtr f, int x, int y, char *s, int color);
00105 void gdImageStringUp(gdImagePtr im, gdFontPtr f, int x, int y, char *s, int color);
00106 
00107 /* Point type for use in polygon drawing. */
00108 
00109 typedef struct {
00110        int x, y;
00111 } gdPoint, *gdPointPtr;
00112 
00113 void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c);
00114 void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c);
00115 
00116 int gdImageColorAllocate(gdImagePtr im, int r, int g, int b);
00117 int gdImageColorClosest(gdImagePtr im, int r, int g, int b);
00118 int gdImageColorExact(gdImagePtr im, int r, int g, int b);
00119 void gdImageColorDeallocate(gdImagePtr im, int color);
00120 void gdImageColorTransparent(gdImagePtr im, int color);
00121 void gdImageGif(gdImagePtr im, FILE *out);
00122 void gdImageGd(gdImagePtr im, FILE *out);
00123 void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color);
00124 void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color);
00125 void gdImageFill(gdImagePtr im, int x, int y, int color);
00126 void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h);
00127 /* Stretches or shrinks to fit, as needed */
00128 void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);
00129 void gdImageSetBrush(gdImagePtr im, gdImagePtr brush);
00130 void gdImageSetTile(gdImagePtr im, gdImagePtr tile);
00131 void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels);
00132 /* On or off (1 or 0) */
00133 void gdImageInterlace(gdImagePtr im, int interlaceArg);
00134 
00135 /* Macros to access information about images. READ ONLY. Changing
00136        these values will NOT have the desired result. */
00137 #define gdImageSX(im) ((im)->sx)
00138 #define gdImageSY(im) ((im)->sy)
00139 #define gdImageColorsTotal(im) ((im)->colorsTotal)
00140 #define gdImageRed(im, c) ((im)->red[(c)])
00141 #define gdImageGreen(im, c) ((im)->green[(c)])
00142 #define gdImageBlue(im, c) ((im)->blue[(c)])
00143 #define gdImageGetTransparent(im) ((im)->transparent)
00144 #define gdImageGetInterlaced(im) ((im)->interlace)
00145 #endif