/******************************************************************************/
/*                                                                            */
/*  CLASSES - Headers for all classes                                         */
/*                                                                            */
/******************************************************************************/

class DIBimage ;

/*
--------------------------------------------------------------------------------

   Parameters specified by the user in dialog boxes
   These are global, declared in BLOCKS.CPP and appearing in EXTERN.H.
   This facilitates initializing them in the main program, setting them in
   the DLG_? routines, and using them where needed.

--------------------------------------------------------------------------------
*/

typedef struct BlocksParams {
   int nrows ;
   int ncols ;
   double height ;        // Percent of total image
   double width ;
   double depth ;
   double angle ;         // In degrees, usually about 15
   double front_tone ;    // 0-1
   double side_tone ;
   double top_tone ;
   } BLOCKS_PARAMS ;

typedef struct PrintParams {
   int fraction ;
   int vert_scaling ;
   } PRINT_PARAMS ;


/*
--------------------------------------------------------------------------------

   Image header

--------------------------------------------------------------------------------
*/

typedef struct {
   int type ;        // 1=TON; 2=BMP
   int nr ;          // Number of rows
   int nc ;          // Number of columns
   int nbytes ;      // Number of bytes per pixel
   char *dib ;       // DIB for BMP file (allocated/deallocated)
   char *dibdata ;   // Its data starts here
   int inverted ;    // If BMP, is it bottom-to-top?
   }  IMAGE_HEADER ;

/*
--------------------------------------------------------------------------------

   Image - Abstract base class for all image types

--------------------------------------------------------------------------------
*/

class Image {

public:

   Image () ;                // Pleases compiler; NEVER invoked
   Image ( char *name ) ;    // Called by derived constructors
   virtual ~Image() ;        // Needed so derived destructor called
   int valid () ;
   char *get_name () ;
   int getrows () ;
   int getcols () ;
   virtual int write_bmp ( char *filename ) = NULL ;
   virtual int draw ( HWND hwnd , int printing ) = NULL ;

   int nr, nc ;              // Its dimensions
   unsigned char *img ;      // The image is here
   DIBimage *dib_image ;     // Its DIB for display
   int nbytes ;              // Number of bytes per pixel

protected:
   char *name ;              // For identifying it in window title
} ;

/*
--------------------------------------------------------------------------------

   Image8 - 8 bit grayscale Image

--------------------------------------------------------------------------------
*/

class Image8: public Image {

public:

   Image8 () ;        // Default constructor, never called
   ~Image8 () ;
   Image8 ( BlocksParams *params ) ;
   int write_bmp ( char *filename ) ;
   int draw ( HWND hwnd , int printing ) ;
} ;

/*
--------------------------------------------------------------------------------

   Image24 - 24 bit true color Image

--------------------------------------------------------------------------------
*/

class Image24: public Image {

public:

   Image24 () ;        // Default constructor, never called
   ~Image24 () ;
   int write_bmp ( char *filename ) ;
   int draw ( HWND hwnd , int printing ) ;
} ;

/*
--------------------------------------------------------------------------------

   DIBimage - This is a DIB manipulation class

--------------------------------------------------------------------------------
*/

class DIBimage {

public:

   DIBimage () ;                       // Default constructor (never called)
   DIBimage ( int nrows , int ncols , int nbytes , unsigned char *image ) ;
   ~DIBimage () ;
   int draw ( HWND hwnd , int printing ) ;
   int valid () ;

private:
   int nr ;        // Number of rows
   int nc ;        // Number of columns
   int nb ;        // Bytes per pixel (1 or 3 now)
   int rgb_size ;  // Number of RGBQUAD entries in bit_map_info
   int row_bytes ; // nc * nb padded (if needed) to LONG boundary for img
   BITMAPINFO *bit_map_info ;
   BITMAPINFOHEADER *bit_map_info_header ;
   RGBQUAD *rgb_quad ;
   unsigned char *img ; // The image is here
} ;
