/** @file  psImageJpeg.h
 *
 * the functions to generate JPEG images from psImage
 */

#ifndef PS_IMAGE_JPEG_H
#define PS_IMAGE_JPEG_H

#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 */
