/* graphics.h Chris Nevison June 24, 1997 This file contains the specifications for some routines for converting doubles or matrices of doubles to pixels or matrices of pixels of Blue, Green, Red values. It also includes specifications for a function for writing a tga format header, to set up a tga graphics file. */ #include typedef struct{ unsigned char blue; unsigned char green; unsigned char red; } Pixel; void DblToPixel(double val, double minval, double maxval, Pixel * p); /* pre: minval <= val <= maxval */ /* post: p is a color (RGB values) pixel representing */ /* val, where colors range from blue for minval */ /* to green for a middle value to red for maxval. */ void DMatToPMap(double * * mat, double minval, double maxval, int numrows, int numcols, Pixel * * pmap); /* pre: mat is a numrows x numcols matrix of double values, */ /* each value between minval and maxval. */ /* pmap is a numrows x numcols array of pixels, */ /* possibly uninitialized. */ /* post: Each values in pmap has been set to the color */ /* for the corresponding entry in mat. */ void CreatePixelMap(int numrows, int numcols, Pixel * * * pmap); /* pre: pmap is an unitialized or NULL pointer */ /* post: pmap is initialized to a numrows x numcols array of */ /* pixels. */ void StorePixelBlock(FILE * outfile, int numrows, int numcols, Pixel * * pmap); /* pre: outfile is open ready to append a block of Pixels. */ /* post: The values of pixels in pmap have been written to */ /* outfile in row-major order, in the order */ /* blue-green-red. */ void StoreTGAHeader(FILE * outfile, int height, int width); /* pre: outfile is open, empty and ready to write */ /* post: A standard header file for targa (tga) format for */ /* 24 bit color has been written to outfile. */