/* Spectroscopic Toolkit version 1.76 by Pieter Suurmond, september 24, 2004. 'gt' is a minimal graphic toolkit in C by Pieter Suurmond. It can create 24 bit RGB images in memory, set and get individual pixels, draw lines, texts, translate monochrome frequencies to RGB and it can save images in JPEG-format to file or the standard output. All sourcefiles that start with 'j' come from the Independent JPEG Group. This file just includes the minimum amount of compression-sources from the library source code and the cjpeg-example that came with version 6b, 27-Mar-1998. Notice it is NOT applied as a proper library here, so please do not bother Tom Lane, Philip Gladstone, Jim Boucher, Lee Crocker, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, Guido Vollbeding, Ge' Weijers, and other members of the Independent JPEG Group with this application of their library sources. See file gtDemo.c and makefile in this directory for an example how to use gt. */ /*-------------------------------------------------------------------------------------*/ typedef struct RGBPIC* RGBPIC; /* Forward declaration (private implementation). */ /* Object that holds 24 bit RGB space (in memory). */ /* Create RGBPIC objects with gtCreateMemRGB(), */ /* Release them after use with gtDestroyMemRGB(). */ /*-------------------------------------------------------------------------------------*/ /* Creates a 24 bit RGB space in memory with dimensions specified by arguments width and height, and background color specified by arguments R, G and B. Argument handle must point to a valid address, there a pointer to the newly created RGBPIC object will be stored, or NULL will be written there. Returns zero (and *handle receives a pointer to the newly created RGBPIC object) when it succeeds. Returns a nonzero (and *handle receives a NULL pointer) in case of memory-failures or when width and/or height are smaller than one pixel. */ int gtCreateMemRGB(RGBPIC* handle, int width, int height, unsigned char R, unsigned char G, unsigned char B); /*-------------------------------------------------------------------------------------*/ /* Releases all memory allocated by gtCreateMemRGB() and also sets pointer to NULL. Argument handle must always point to a valid address, that address may however contain a NULL pointer (in which case the object is assumed to be already gone). */ void gtDestroyMemRGB(RGBPIC* handle); /*-------------------------------------------------------------------------------------*/ /* Sets all pixels in the image to given RGB color. */ void gtErase(RGBPIC pic, unsigned char R, unsigned char G, unsigned char B); /*-------------------------------------------------------------------------------------*/ /* To save the image to disk. */ short gtSaveMemRGB(RGBPIC pic, const char* filename, unsigned int Q); /*-------------------------------------------------------------------------------------*/ /* Sets pixel if x and y are inside picture, it then returns 0. Returns 1 if x and y are outside the picture. */ int gtSetPixel(RGBPIC pic, int x, int y, unsigned char R, unsigned char G, unsigned char B); /*-------------------------------------------------------------------------------------*/ /* Receives pixel color if x and y are inside picture, it then returns 0. Returns 1 if x and y are outside the picture. */ int gtGetPixel(RGBPIC pic, int x, int y, unsigned char* R, unsigned char* G, unsigned char* B); /*-------------------------------------------------------------------------------------*/ /* Draws a solid line between point x1,y1 to point x2,y2, with the color specified by R, G and B (0..255). */ void gtDrawLine(RGBPIC pic, int x1, int y1, int x2, int y2, unsigned char R, unsigned char G, unsigned char B); /*-------------------------------------------------------------------------------------*/ /* Prints string s, which must be null terminated. Argument x and y specify the upper left corner of first character in s. Argument T for transparency: 0=transparent, 1=on white background. */ void gtDrawString(RGBPIC pic, int x, int y, unsigned char R, unsigned char G, unsigned char B, short T, const char* s); /*-------------------------------------------------------------------------------------*/ void gtInitHertzToRGBtables(void); /* Freq -> RGB. */ void gtHertzToRGB(float hz, float intensity, float* C);