home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / newprt10.zip / GRAFFILE.HPP < prev    next >
C/C++ Source or Header  |  1991-12-13  |  2KB  |  82 lines

  1.  
  2. //file classes for the different formats
  3. //main class is a virtual class since it contains stuff
  4. //common to all file formats
  5.  
  6.  
  7. class graphics_file
  8. {
  9. public:
  10.  
  11.     //constructor
  12.     graphics_file(char *filename);
  13.  
  14.     virtual void print_file(void){}  //different print files for different
  15.                                     //file types
  16.  
  17. protected:
  18.     FILE * file_ptr;   //file pointer
  19.     char * grey_buffer_ptr;  //the grey scale line to be passed to
  20.                             //the printer ob. same for any type file
  21.     int num_bytes_in_grey_buffer;  //length of the buffer
  22.  
  23.     graphics_printer *printer; //holds a pointer to the printer ob
  24. };
  25.  
  26.  
  27. //define the pcx header type struct
  28. typedef struct
  29. {
  30.     char manufacturer;
  31.     char version;
  32.     char encoding;
  33.     char bits_per_pixel;
  34.     int xmin,ymin;
  35.     int xmax, ymax;
  36.     int hres;
  37.     int vres;
  38.     unsigned char palette[48];
  39.     char reserved;
  40.     char color_planes;
  41.     int bytes_per_line;
  42.     int palette_type;
  43.     char filler[58];
  44. }PCX_HEAD;
  45.  
  46. //derived class from the above class, for PCX files rather
  47. //than screen images
  48. class pcx_graphics_file:public graphics_file
  49. {
  50. public:
  51.     //constructor
  52.     pcx_graphics_file(char *filename);
  53.  
  54.     //This time it's not virtual but real.
  55.     void print_file(void); //main entry
  56.  
  57. protected:
  58.     PCX_HEAD pcx_header;  //place for the file header info1
  59.     int pixels_per_line;
  60.  
  61.     //methods (protected)
  62.     void print_256_body(void);  //prints out the file
  63.     void print_16_body(void);  //prints out the file
  64.     unsigned char palette_256[256];  //the palette (in grey scale)
  65.     unsigned char palette_16[16];  //the palette (in grey scale)
  66.     int read_256_palette(void);  //reads the palette from the file
  67.     int read_16_palette(void);  //reads the palette from the file
  68.     int grey_convert_256(int convert_char); //converts a palette index
  69.                             //to a grey scale value
  70.     int grey_convert_16(char * temp_buffer[4]);
  71.                             //to a grey scale value
  72.  
  73. };
  74.  
  75.  
  76.  
  77.  
  78. //error handler stuff
  79. int error_message(char *message, int fatal_or_nonfatal);
  80. #define FATAL 0
  81. #define NONFATAL 1
  82.