mgd.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 gdGifBufferStruct {
00051    char *data;
00052    int size;
00053 } gdGifBuffer;
00054 
00055 typedef struct {
00056    /* # of characters in font */
00057    int nchars;
00058    /* First character is numbered... (usually 32 = space) */
00059    int offset;
00060    /* Character width and height */
00061    int w;
00062    int h;
00063    /* Font data; array of characters, one row after another.
00064       Easily included in code, also easily loaded from
00065       data files. */
00066    int *data;
00067 } gdFont;
00068 
00069 /* Text functions take these. */
00070 typedef gdFont *gdFontPtr;
00071 
00072 /* Fonts defined in mgd.c */
00073 extern gdFontPtr gdFontMediumBold;
00074 extern gdFontPtr gdFontGiant;
00075 extern gdFontPtr gdFontSmall;
00076 
00077 /* For backwards compatibility only. Use gdImageSetStyle()
00078         for MUCH more flexible line drawing. Also see
00079         gdImageSetBrush(). */
00080 #define gdDashSize 4
00081 
00082 /* Special colors. */
00083 
00084 #define gdStyled (-2)
00085 #define gdBrushed (-3)
00086 #define gdStyledBrushed (-4)
00087 #define gdTiled (-5)
00088 
00089 /* NOT the same as the transparent color index.
00090         This is used in line styles only. */
00091 #define gdTransparent (-6)
00092 
00093 /* Functions to manipulate images. */
00094 
00095 gdImagePtr gdImageCreate(int sx, int sy);
00096 gdImagePtr gdImageCreateFromGif(FILE * fd);
00097 void gdImageDestroy(gdImagePtr im);
00098 void gdImageSetPixel(gdImagePtr im, int x, int y, int color);
00099 int gdImageGetPixel(gdImagePtr im, int x, int y);
00100 void gdImageLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00101 /* For backwards compatibility only. Use gdImageSetStyle()
00102         for much more flexible line drawing. */
00103 void gdImageDashedLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00104 /* Corners specified (not width and height). Upper left first, lower right
00105         second. */
00106 void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00107 /* Solid bar. Upper left corner first, lower right corner second. */
00108 void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
00109 int gdImageBoundsSafe(gdImagePtr im, int x, int y);
00110 void gdImageChar(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
00111 void gdImageCharUp(gdImagePtr im, gdFontPtr f, int x, int y, char c, int color);
00112 void gdImageString(gdImagePtr im, gdFontPtr f, int x, int y, char *s, int color);
00113 void gdImageStringUp(gdImagePtr im, gdFontPtr f, int x, int y, char *s, int color);
00114 
00115 /* Point type for use in polygon drawing. */
00116 
00117 typedef struct {
00118    int x, y;
00119 } gdPoint, *gdPointPtr;
00120 
00121 void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c);
00122 void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c);
00123 
00124 int gdImageColorAllocate(gdImagePtr im, int r, int g, int b);
00125 int gdImageColorClosest(gdImagePtr im, int r, int g, int b);
00126 int gdImageColorExact(gdImagePtr im, int r, int g, int b);
00127 void gdImageColorDeallocate(gdImagePtr im, int color);
00128 void gdImageColorTransparent(gdImagePtr im, int color);
00129 void gdImageGif(gdImagePtr im, gdGifBuffer * buffer);
00130 void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color);
00131 void gdImageFill(gdImagePtr im, int x, int y, int color);
00132 void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY,
00133                  int w, int h);
00134 /* Stretches or shrinks to fit, as needed */
00135 void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX,
00136                         int srcY, int dstW, int dstH, int srcW, int srcH);
00137 void gdImageSetBrush(gdImagePtr im, gdImagePtr brush);
00138 void gdImageSetTile(gdImagePtr im, gdImagePtr tile);
00139 void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels);
00140 /* On or off (1 or 0) */
00141 void gdImageInterlace(gdImagePtr im, int interlaceArg);
00142 
00143 /* Macros to access information about images. READ ONLY. Changing
00144         these values will NOT have the desired result. */
00145 #define gdImageSX(im) ((im)->sx)
00146 #define gdImageSY(im) ((im)->sy)
00147 #define gdImageColorsTotal(im) ((im)->colorsTotal)
00148 #define gdImageRed(im, c) ((im)->red[(c)])
00149 #define gdImageGreen(im, c) ((im)->green[(c)])
00150 #define gdImageBlue(im, c) ((im)->blue[(c)])
00151 #define gdImageGetTransparent(im) ((im)->transparent)
00152 #define gdImageGetInterlaced(im) ((im)->interlace)
00153 #endif

Midas DOC Version 3.0.0 ---- PSI Stefan Ritt ----
Contributions: Pierre-Andre Amaudruz - Sergio Ballestrero - Suzannah Daviel - Doxygen - Peter Green - Qing Gu - Greg Hackman - Gertjan Hofman - Paul Knowles - Exaos Lee - Rudi Meier - Glenn Moloney - Dave Morris - John M O'Donnell - Konstantin Olchanski - Renee Poutissou - Tamsen Schurman - Andreas Suter - Jan M.Wouters - Piotr Adam Zolnierczuk