home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vos2-121.zip / v / iconed / imageio.h < prev    next >
C/C++ Source or Header  |  1998-07-03  |  3KB  |  94 lines

  1. //===============================================================
  2. // imageio.h - IO library to read/write various image bitmap formats
  3. //
  4. // Copyright (C) 1996 Philip Eckenroth, Mike Tipping, Marilee Padilla,
  5. //                    John Fredric Jr. Masciantoni, and Bruce E. Wampler.
  6. //
  7. // This file is part of the V Icon Editor, and is covered
  8. // under the terms of the GNU General Public License,
  9. // Version 2. This program has NO WARRANTY. See the source file
  10. // viedapp.cpp for more complete information about license terms.
  11. //===============================================================
  12.  
  13. #ifndef IMAGEIO_H
  14. #define IMAGEIO_H
  15. #include <fstream.h>
  16.  
  17.   class imageIO
  18.   {
  19.     public:     //-----------------------------------------------
  20.     imageIO(int maxW = 150, int maxH = 150);
  21.     ~imageIO();
  22.  
  23.     int ReadVBM(char* name);
  24.     int WriteVBM(char* fname, char* iname = "icon");
  25.  
  26.     int ReadBMP(char* name);
  27.     int WriteBMP(char* fname, char* iname);
  28.  
  29.     int ReadXBM(char* name);
  30.     int ReadXPM(char* name);
  31.     int WriteXPM(char* fname, char* iname);
  32.     int WriteXBM(char* fname, char* iname);
  33.  
  34.     int Height() { return _height; }
  35.     int Width() { return _width; }
  36.     int Depth() { return _depth; }
  37.     int Colors() { return _colors; }
  38.  
  39.     void SetHeight(int h) { _height = h; }
  40.     void SetWidth(int w) { _width = w; }
  41.     void SetDepth(int d) { _depth = d; }
  42.     void SetColors(int c) { _colors = c; }
  43.  
  44.     unsigned char* Pixels() { return _pixels; }
  45.     unsigned char* RedMap() { return _r; }
  46.     unsigned char* GreenMap() { return _g; }
  47.     unsigned char* BlueMap() { return _b; }
  48.  
  49.       unsigned char* CreatePixels(long size);
  50.      void CreateColorMap(int size);
  51.  
  52.      void OptimizeColorMap();
  53.     void ResetMemory();
  54.  
  55.     protected:  //-----------------------------------------------
  56.  
  57.     private:    //-----------------------------------------------
  58.     int RdLine(char* buff, ifstream& ifs);
  59.     int RdStr(char* buff, ifstream& ifs);
  60.     int RdIntComma(ifstream& ifs);
  61.     int RdInt(ifstream& ifs);
  62.     int RdToEOL(char* buff, ifstream& ifs);
  63.     int RdRestOfXBM(ifstream& ifs);
  64.     int WriteRestOfXBM(ofstream& ofs, char* iname, int isVBM = 0);
  65.  
  66.     void ByteToStr(unsigned char intg, char* str);
  67.     int Hex_to_Bin(char digit);
  68.     int Hex_to_Bin_Convert(char * hexnumber);
  69.  
  70.     int rdBMP1(ifstream& fileIn, unsigned char* rev,
  71.         unsigned int w, unsigned int h);
  72.     int rdBMP4(ifstream& fileIn, unsigned char*rev,
  73.         unsigned int w, unsigned int h, unsigned int comp);
  74.     int rdBMP8(ifstream& fileIn, unsigned char* rev,
  75.         unsigned int w, unsigned int h, unsigned int comp);
  76.     unsigned int rdInt16(ifstream& fileIn);
  77.     unsigned int rdInt32(ifstream& fileIn);
  78.     void putint(ofstream& fp, int i);
  79.     void putshort(ofstream& fp, int i);
  80.  
  81.     int _maxH, _maxW;
  82.     int _height, _width;
  83.     int _colors;
  84.     int _depth;
  85.  
  86.     unsigned char* _pixels;
  87.  
  88.     unsigned char* _r;
  89.     unsigned char* _g;
  90.     unsigned char* _b;
  91.   };
  92.  
  93. #endif
  94.