1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
|
#ifndef CD_H
#define CD_H 1
// cd.h: declarations file for the cgmdraw module.
//
// Written by G. Edward Johnson <mailto:lorax@nist.gov>
// Date: April 1996
// Copyright: cd software produced by NIST, an agency of the
// U.S. government, is by statute not subject to copyright
// in the United States. Recipients of this software assume all
// responsibilities associated with its operation, modification
// and maintenance.
//
// Portions of this package are from the gd package written by
// Thomas Boutell and are copyright 1994, 1995, Quest Protein
// Database Center, Cold Spring Harbor Labs. They are marked in the
// source code.
//
//
// #include <prof.h>
// stdio is needed for file I/O.
#include <stdio.h>
#include "cddll.h"
// This can not be changed to a value larger than 256, though smaller
// values can be used.
//
#define cdMaxColors 256
// If you know you will be working with large pictures, increase the values
// of the next two constants.
//
// The initial size of the element list. When it fills up, we will just
// make it bigger. Starting with a larger number reduces the frequency of
// the list growing, but increases the memory needed for small pictures
//
#define CDSTARTLISTSIZE 4096
// How much the element list grows by. When the list fills up, we allocate
// a new larger list. This number is how much larger. using a larger number
// decreases the frequency of the list growing, but if only a small amount
// more is needed, it could waste memory
//
#define CDGROWLISTSIZE 2048
// Image type. See functions below; you will not need to change
// the elements directly. Use the provided macros to
// access sx, sy, the color table, and colorsTotal for
// read-only purposes.
#if defined ( __cplusplus ) || defined ( c_plusplus )
extern "C" {
#endif
typedef struct cdImageStruct
{
// Don't mess with these
unsigned char * elemlist;
short int state;
int red[cdMaxColors];
int green[cdMaxColors];
int blue[cdMaxColors];
int open[cdMaxColors];
int colorsTotal;
// You can have multiple pictures in the file, this keeps track
// of which one you are on
int picnum;
// these take effect only when the first picture is created.
// subsequent changes have no effect
unsigned char *desc;
unsigned char *fontlist;
short int numfonts;
FILE *outfile;
// these take effect when a new picture is opened. Subsequent
// changes are for the next picture
int linespec;
int edgespec;
int markerspec;
int sx;
int sy;
// these take effect immediately
// Linetype, line width, line color have a broader scope in CGM
int ltype;
int lwidth;
int lcolor;
// interior style [of filled objects] (for me) can be empty, hollow,
// solid, hatch [don't do pattern, geometric pattern, interpolated
int shapestyle;
// fill color, color used on inside of closed objects, significant
// if interior style is hollow, solid, hatch, or geometric pattern
int shapecolor;
// hatch index, which hatch style to use, 1=horizontal, 2=vertical,
// 3=pos.slope, 4=neg.slope, 5=hor/vert.crosshatch,
// 6=pos/neg.crosshatch
int shapehatch;
// The edges of filled shapes can have line styles too. They
// correspond to the ones for lines. These next few set them.
int edgetype;
int edgewidth;
int edgecolor;
int edgevis; // is the edge visible or invisible
// now for the TEXT related attributes, Text Color, Text Height,
// and Text font index
int textfont;
int textcolor;
int textheight;
int textpath;
// Marker type, Marker size, marker color
int mtype;
int msize;
int mcolor;
// the next three are used for maintaining the element list
long int bytestoend; // number of bytes to end of the element list
long int listlen; // the total length of the element list
unsigned char * curelemlist; // where we curently are in the list
} cdImage;
typedef cdImage * cdImagePtr;
// Point type for use in polygon drawing.
typedef struct cdPointStruct
{
int x, y, e;
} cdPoint, *cdPointPtr;
// Functions to manipulate images.
CDDLLIMPEXP cdImagePtr cdImageCreate( int sx, int sy );
CDDLLIMPEXP int cdCgmNewPic( cdImagePtr im, int sticky );
CDDLLIMPEXP int cdImageCgm( cdImagePtr im, FILE * );
CDDLLIMPEXP int cdImageDestroy( cdImagePtr im );
// Use cdLine, not cdImageLine
CDDLLIMPEXP int cdLine( cdImagePtr im, int x1, int y1, int x2, int y2 );
// Corners specified (not width and height). Upper left first, lower right
// second.
CDDLLIMPEXP int cdRectangle( cdImagePtr im, int x1, int y1, int x2, int y2 );
// center x, then center y, then radius of circle
CDDLLIMPEXP int cdCircle( cdImagePtr im, int cx, int cy, int r );
// start, middle and end of arc
CDDLLIMPEXP int cdArc3Pt( cdImagePtr im, int sx, int sy, int ix, int iy, int ex, int ey );
// cl is 0 for pie closure, 1 for cord closure
CDDLLIMPEXP int cdArc3PtClose( cdImagePtr im, int sx, int sy, int ix, int iy, int ex, int ey, int cl );
CDDLLIMPEXP int cdEllipse( cdImagePtr im, int cx, int cy, int d1x, int d1y, int d2x, int d2y );
CDDLLIMPEXP int cdMarker( cdImagePtr im, int x, int y );
// polyshapes
CDDLLIMPEXP int cdPolygon( cdImagePtr im, cdPointPtr p, int n );
CDDLLIMPEXP int cdPolygonSet( cdImagePtr im, cdPointPtr p, int n );
CDDLLIMPEXP int cdPolyLine( cdImagePtr im, cdPointPtr p, int n );
CDDLLIMPEXP int cdPolyMarker( cdImagePtr im, cdPointPtr p, int n );
// Functions for Compatibility with gd
CDDLLIMPEXP int cdImageLine( cdImagePtr im, int x1, int y1, int x2, int y2, int color );
CDDLLIMPEXP int cdImageRectangle( cdImagePtr im, int x1, int y1, int x2, int y2, int color );
CDDLLIMPEXP int cdImageBoundsSafe( cdImagePtr im, int x, int y );
// These put characters in the picture. CGM can handle fonts
// (x,y) is the lower left corner of where the text goes
CDDLLIMPEXP int cdText( cdImagePtr im, int x, int y, const char * );
// Functions for allocating colors
CDDLLIMPEXP int cdImageColorAllocate( cdImagePtr im, int r, int g, int b );
CDDLLIMPEXP int cdImageColorClosest( cdImagePtr im, int r, int g, int b );
CDDLLIMPEXP int cdImageColorExact( cdImagePtr im, int r, int g, int b );
CDDLLIMPEXP int cdImageColorDeallocate( cdImagePtr /* im */, int /* color */ );
// wogl: the parameter names are commented to avoid compiler warnings
CDDLLIMPEXP int cdImageColor16( cdImagePtr im );
// gej: functions that set style attributes
CDDLLIMPEXP int cdSetLineAttrib( cdImagePtr im, int lntype, int lnwidth, int lncolor );
CDDLLIMPEXP int cdSetShapeFillAttrib( cdImagePtr im, int instyle, int incolor, int inhatch );
CDDLLIMPEXP int cdSetShapeEdgeAttrib( cdImagePtr im, int edtype, int edwidth, int edcolor, int edvis );
CDDLLIMPEXP int cdSetTextAttrib( cdImagePtr im, int font, int color, int height );
CDDLLIMPEXP int cdSetMarkerAttrib( cdImagePtr im, int mtype, int msize, int mcolor );
// gej: or if you prefer, set the attributes individually
CDDLLIMPEXP int cdSetLineType( cdImagePtr im, int lntype );
CDDLLIMPEXP int cdSetLineWidth( cdImagePtr im, int lnwidth );
CDDLLIMPEXP int cdSetLineColor( cdImagePtr im, int lncolor );
CDDLLIMPEXP int cdSetFillStyle( cdImagePtr im, int instyle );
CDDLLIMPEXP int cdSetFillColor( cdImagePtr im, int incolor );
CDDLLIMPEXP int cdSetFillHatch( cdImagePtr im, int inhatch );
CDDLLIMPEXP int cdSetEdgeType( cdImagePtr im, int edtype );
CDDLLIMPEXP int cdSetEdgeWidth( cdImagePtr im, int edwidth );
CDDLLIMPEXP int cdSetEdgeColor( cdImagePtr im, int edcolor );
CDDLLIMPEXP int cdSetEdgeVis( cdImagePtr im, int edvis );
CDDLLIMPEXP int cdSetTextFont( cdImagePtr im, int font );
CDDLLIMPEXP int cdSetTextColor( cdImagePtr im, int color );
CDDLLIMPEXP int cdSetTextHeight( cdImagePtr im, int height );
// geJ: these individual attributes can't be set with a group function
CDDLLIMPEXP int cdSetTextPath( cdImagePtr im, int tpath );
CDDLLIMPEXP int cdSetTextOrient( cdImagePtr im, int xup, int yup, int xbase, int ybase );
CDDLLIMPEXP int cdSetMarkerType( cdImagePtr im, int mtype );
CDDLLIMPEXP int cdSetMarkerSize( cdImagePtr im, int msize );
CDDLLIMPEXP int cdSetMarkerColor( cdImagePtr im, int mcolor );
// EJ: Expert Functions, If you just need more control
CDDLLIMPEXP int cdImageSetSize( cdImagePtr im, int x, int y );
CDDLLIMPEXP int cdImageSetLineSpec( cdImagePtr im, int specmode );
CDDLLIMPEXP int cdImageSetMarkerSpec( cdImagePtr im, int specmode );
CDDLLIMPEXP int cdImageSetEdgeSpec( cdImagePtr im, int specmode );
CDDLLIMPEXP int cdImageSetOutput( cdImagePtr im, FILE *output );
CDDLLIMPEXP int cdImageAddFont( cdImagePtr im, const char *fontname );
CDDLLIMPEXP int cdImageClearFonts( cdImagePtr im );
CDDLLIMPEXP cdImagePtr cdImageStartCgm();
CDDLLIMPEXP int cdCgmHeader( cdImagePtr );
CDDLLIMPEXP int cdCgmPic( cdImagePtr, int );
CDDLLIMPEXP int cdImageSetDefaults( cdImagePtr im );
CDDLLIMPEXP int cdImageEndPic( cdImagePtr im );
CDDLLIMPEXP int cdImageEndCgm( cdImagePtr im );
// Macros to access information about images. READ ONLY. Changing
// these values will NOT have the desired result.
#define cdImageSX( im ) ( ( im )->sx )
#define cdImageSY( im ) ( ( im )->sy )
#define cdImageColorsTotal( im ) ( ( im )->colorsTotal )
#define cdImageRed( im, c ) ( ( im )->red[( c )] )
#define cdImageGreen( im, c ) ( ( im )->green[( c )] )
#define cdImageBlue( im, c ) ( ( im )->blue[( c )] )
// Source: Independent JPEG Group
// In ANSI C, and indeed any rational implementation, size_t is also the
// type returned by sizeof(). However, it seems there are some irrational
// implementations out there, in which sizeof() returns an int even though
// size_t is defined as long or unsigned long. To ensure consistent results
// we always use this SIZEOF() macro in place of using sizeof() directly.
//
#define SIZEOF( object ) ( (size_t) sizeof ( object ) )
// GeJ: these are helper functions I use in cd. That means DON'T call
// them from your program. Yes, that means you.
CDDLLIMPEXP int cdImageColorClear( cdImagePtr im );
#if defined ( __cplusplus ) || defined ( c_plusplus )
}
#endif
#endif
|