/*
 * IM - Image I/O Library
 * Copyright (c) 1996 CENPES/Petrobras, TeCGraf/PUC-Rio.
 * Antonio E. Scuri - scuri@tecgraf.puc-rio.br
 * 
 * IMIO.H
 * 
 * Contains the definitions necessary to implement each file format.
 *
 * History:
 *          1997.04.05 - Finished inicial version.
 *
 */

#ifndef __IMIO_H
#define __IMIO_H

#if	defined(__cplusplus)
extern "C" {
#endif


/* contains each file information */
typedef struct _imFile
{
  void *file;  /* file handle, format dependent */
  int width,     /* image width */
      height,    /* image height */
      type,      /* image type */
      compress,  /* compression flag */
      pal_size,  /* color map size, number of colors */
      split,     /* if true image is plane R, then plane G, then plane B, else the planes are mixed in each line */
      pre_colors,/* the color map if before the image or not */
      planes[3], /* planes order when split is true, rgb is 012, but can be other combinations. */
      cur_line;  /* the line that will be readed or writed */
} imFile;


/* function table for each file format */
typedef struct _imFormat
{
  int format; /* the format id is initialized in the imAddFormat, so let it be 0 */
  int (*RegisterCallback)(imCallback cb, int id);
  imFile* (*ReadOpen)(char* filename, int *err);
  imFile* (*WriteOpen)(char* filename, int width, int height, int type, int compress, int pal_size, int *err);
  void (*Close)(imFile* ifile);
  int (*ReadColors)(imFile* ifile, long *colors);
  int (*WriteColors)(imFile* ifile, long *colors);
  int (*ReadLine)(imFile* ifile, unsigned char *map);
  int (*WriteLine)(imFile* ifile, unsigned char *map);
  int (*ReadLineRGB)(imFile* ifile, unsigned char *red, unsigned char *green, unsigned char *blue);
  int (*WriteLineRGB)(imFile* ifile, unsigned char *red, unsigned char *green, unsigned char *blue);
} imFormat;


/* Adds a new format to the format list */
/* if the list is not initialized, initialize it first */
/* returns the format identifier */
int imAddFormat(imFormat* iformat);


/* public global callbacks, to be used by the format drivers */
extern imResolutionCallback imResolutionCB;


#if defined(__cplusplus)
}
#endif

#endif  /* __IMIO_H */

/* IMIO.H */
