#ifndef IMAGE
#define IMAGE

#include <iostream.h>
#include <fstream.h>
class Image{
  public:
        Image(int m, int n);    //Constructor for image m rows and n columns
        ~Image();               //destructor
        Image();                //default constructor
        int Tellrows() const;         //this access private: rows m
        int Tellcolumns() const;      //this will access private:columns n
        int Tellall(int i, int j) const;

  private:
        int rows;               //number of rows
        int columns;            //number of columns
        int **the_image;        //image stored here as integer values
        };
  
  Image::Image(int m, int n){
  
        rows=m;
        columns=n;


        the_image=new int*[m];          // This dynamically allocates the image
                for (int i=0; i<m; i++){
                        the_image[i]=new int[n];
			}


        //The following is an algorithm to read in an image from
        //binary format and cast it into integere and store it into
        // the_image[][]

        unsigned char thecharimage[m][n];  
        
	char filename[100];
	cout<<"enter the name of your original"<<endl;
	cin>>filename;
	ifstream r(filename,ios::binary|ios::in);
                r.read((char*) &thecharimage, rows*columns);
        	for (int j=0;j<m;j++){
        		for (int i=0;i<n;i++){
                	the_image[j][i]=(int)thecharimage[j][i];
                	}
        	}
        	r.close();

	}


  Image::~Image(){
        for (int i=0; i<rows; i++){
                delete[] the_image[i];}
                delete[] the_image;}
  
  
  int Image::Tellrows() const {
        return rows;}

  int Image::Tellcolumns() const {
        return columns;}


  int Image::Tellall(int i, int j) const {     //this will return a given pixel
        return the_image[i][j];}
  
  
  
  Image::Image(){
 	rows=0;
        columns=0;
        the_image=0;}

#endif
