/* 
 * A simple library for PPM read and write functions...
 *
 * $Date$
 * $Revision$
 *
 */

#ifndef PPMLIB_H__
#define PPMLIB_H__

/** @ingroup WImage */

#include "WImage/miscdefs.h"
#include <stdio.h>

/** Read a PPM file from the filesystem.
 * @param fname
 * the filename
 * @param height
 * the number of pixel rows, returned by the function
 * @param width
 * the number of pixel cols, returned by the function
 * @param cmax
 * the maximal color value, returned by the function
 * @return an array containing the pixels as RGB triples  if successful 
 * else NULL */
pixel *ppm_read (const char *fname, int *height, int *width, int *cmax);

/** Write a PPM file to the filesystem
 * @param fname
 * the filename
 * @param pic
 * the image as an array of RGB triples 
 * @param height
 * the number of pixel rows
 * @param width 
 * the number of pixel cols
 * @param cmax
 * the maximum color value 
 * @return 0 if successful else -1 */
int ppm_write (const char *fname, pixel *pic, int height, int width, int cmax);

/** Read a PPM file from an open stream.
 * @param in
 * the open input stream
 * @param height
 * the number of pixel rows, returned by the function
 * @param width
 * the number of pixel cols, returned by the function
 * @param cmax
 * the number of colors, returned by the function
 * @return an array containing the pixels as RGB triples  if successful 
 * else NULL */
pixel *ppm_fromStream (FILE *in, int *height, int *width, int *cmax);
/** Write a PPM file to an open stream
 * @param out
 * the open output stream
 * @param pic
 * the image as an array of RGB triples 
 * @param height
 * the number of pixel rows
 * @param width 
 * the number of pixel cols
 * @param cmax
 * the maximum color value 
 * @return 0 if successful else -1 */
int ppm_toStream (FILE *out, pixel *pic, int height, int width, int cmax);

#endif /* PPMLIB_H__ */
