// matrix2xpm converts a matrix of 0's and 1's to a black & white xpm file // filename is an extention #ifndef SCREEN_H #define SCREEN_H #include #include #include #include #include class Screen { private: int *pic; int imgwidth, imgheight; float xmin,ymin; float xsize,ysize; int xval(float x); // Calc X Coordinate in pic int yval(float y); // Calc Y coordinate in pic public: Screen(int width, int height); // Constructor ~Screen(); // Destructor void matrix2xpm(const char *filename); // Makes a XPM file with name filename void setrect(float, float, float, float); // sets the rectangle that the picture holds bool plotxy(float x,float y); //Assigns the value 1 to x,y void clear(); //Set the array to zeros }; Screen::Screen(int width, int height){ imgwidth=width; imgheight=height; pic=new int [imgwidth*imgheight]; clear(); } Screen::~Screen(){ delete [] pic; } void Screen::matrix2xpm(const char *filename){ ofstream out(filename); char filename2[30]; strcpy(filename2,filename); if (!out){ // on file open error cerr << "File could not be opened for output\n"; exit(1); } for (int i=0; i=0)&&(yc>=0)&&(xc