/* @file  psImageJpeg.h
 * @brief functions to generate JPEG images from psImage
 * 
 * @author EAM
 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
 * @date $Date: 2007-01-23 22:47:23 $
 */

#ifndef PS_IMAGE_JPEG_H
#define PS_IMAGE_JPEG_H

/// @addtogroup FileIO Input/Output
/// @{

#include "psImage.h"

typedef struct
{
    psVector *red;                      // Red colormap
    psVector *green;                    // Green colormap
    psVector *blue;                     // Blue colormap
}
psImageJpegColormap;

#define PS_JPEG_RANGELIM(A)(PS_MAX(0,PS_MIN(255,(A))))

#define PS_JPEG_SCALEVALUE(VALUE,ZERO,SCALE)(PS_MAX(0,PS_MIN(255,(SCALE*(VALUE-ZERO)))))

// allocate a colormap (does not define the map values)
psImageJpegColormap *psImageJpegColormapAlloc();

// set the colormap values using the supplied name
psImageJpegColormap *psImageJpegColormapSet(psImageJpegColormap *map, // Colormap to set
        const char *name // Name of colormap
                                           );

// write out a JPEG file using the supplied image and colormap
// output goes to the specified filename
bool psImageJpeg(const psImageJpegColormap *map, // Color map
                 const psImage *image,  // Image to write
                 const char *filename,  // Filename of JPEG
                 float min, float max   // Minimum and maximum values
                );

/// @}
#endif /* PS_IMAGE_JPEG_H */
