// file: $USFS/class/ppm/v1.0/ppm.h
//	

// make sure definitions are made only once
//
#ifndef __ISIP_PPM
#define __ISIP_PPM

// isip include files
//
#ifndef __ISIP_INTEGRAL
#include <integral.h>
#endif

// Ppm : a class meant to handle the portable pixel image file format (ppm)
//
class Ppm {

  //---------------------------------------------------------------------------
  //
  // protected members
  //
  //---------------------------------------------------------------------------
protected:

  // filename information
  //
  char_1* fname_d;
  FILE* fp_d;              // file pointer

  // information about the image (read from the ppm file)
  //
  char_1* magic_number_d;  // number which tells that the file is a .ppm 
  int_4 width_d;           // gives the width of the image
  int_4 height_d;          // gives the height of the image
  int_4 max_colors_d;      // gives the maximum color level in the image

  // file positioning information
  //
  int_4 beg_d;		   // beginning of file

  //---------------------------------------------------------------------------
  //
  // public methods
  //
  //---------------------------------------------------------------------------
public:

  // required methods
  //
  char_1* name_cc();
  volatile void error_handler_cc(char_1* method_name, char_1* message);
  logical_1 debug_cc(FILE* fp, char_1* message);

  // destructor/constructor
  //
  ~Ppm();
  Ppm();

  // open/close methods
  //
  logical_1 expand_cc(char_1* o_name, char_1* i_name);
  logical_1 open_cc(char_1* filename, int_4 mode);
  logical_1 close_cc();
  logical_1 is_ppm_cc(char_1* filename);
  
  // read/write methods
  //
  logical_1 read_header_cc();

  logical_1 read_header_cc(FILE* fp);
  
  logical_1 read_cc(uint_1* b_red, uint_1* b_green, uint_1* b_blue,
		    int_4 offset_w, int_4 offset_h, int_4 width, int_4 height);

  logical_1 write_header_cc(int_4 width, int_4 height, int_4 max_colors);

  logical_1 write_cc(uint_1* b_red, uint_1* b_green, uint_1* b_blue,
		     int_4 offset_w, int_4 offset_h,
		     int_4 width, int_4 height);
  
  // assignment methods
  //
  logical_1 assign_cc(int_4 width, int_4 height, int_4 max_colors);

  // comparison methods
  //
  logical_1 diff_cc(float_4 alpha, float_4 beta,
		    int_4 width, int_4 height,
		    uint_1* b_red, uint_1* b_green, uint_1* b_blue,
		    uint_1* b_red_0, uint_1* b_green_0, uint_1* b_blue_0,
		    uint_1* b_red_1, uint_1* b_green_1, uint_1* b_blue_1);

  // get information methods
  //
  int_4 get_width_cc();
  int_4 get_height_cc();
  int_4 get_max_colors_cc();

  //---------------------------------------------------------------------------
  //
  // private methods
  //
  //---------------------------------------------------------------------------
private:
};

// end of file
//
#endif
