/////////////////////////////////////////////////////////////////////////////// // Image.h // // This image class contains the data required to represent a // graphics image. There are various routines for accessing the image // data, but you may not access the data directly. /////////////////////////////////////////////////////////////////////////////// // The following preprocessor directives makes sure this header // only gets included once. #ifndef IMAGE_HSPC #define IMAGE_HSPC // This class also depends on input and output streams. Include the header. #include // This image class depends on a pixel class. Include it here. #include "Pixel.h" // Define the Image class. class Image { public: // Default constructor -- creates a black 1 x 1 image. Image (); // Constructor -- creates a black image of size width x height. Image (int width, int height); // Copy Constructor -- creates a new image from an old one. Image (const Image & in); // Destructor -- frees up any memory used. ~Image (); // Assignment operator -- allows images to be assigned to each other. Image & operator = (const Image & in); // These routines are used for manipulating pixels in the image. Pixel & getPixel (int x, int y); void setPixel (int x, int y, const Pixel & p); // These routines are used for getting the dimensions of the image. int getWidth (); int getHeight (); // This routine is used for resizing the image area. Note that the // resized image area is set to black. void resize (int width, int height); // This routine writes the image to a file using Windows .bmp format. // It is written as a true-color image (24 bit). You may not // use this routine in your compressor class! // Error messages are written to errorout. bool writeBMP (char * filename, ostream & errorout); // This routine re-initializes the current object by reading an image // from a windows .bmp format file. You may not use this routine // in your compressor class! // Error messages are written to errorout. bool readBMP (char * filename, ostream & errorout); private: // The image is stored as a two-dimensional array of pixels. You must // use the above functions to access this data. int imageWidth; int imageHeight; Pixel ** data; // The following private helper routines are used for allocating memory. void allocateImage (int w, int h); void freeImage (); void copyImage (const Image & in); }; #endif // IMAGE_HSPC