home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / bitmap2.zip / BITMAP.HPP < prev    next >
Text File  |  1994-12-01  |  3KB  |  77 lines

  1. /* Bitmap.hpp
  2.  
  3.    Bitmap Class Header
  4.    Copyright 1994, Bill Leonard
  5.  
  6.    The author will not be liable for any bug, error, omission,
  7.    defect, deficiency, or nonconformity in this software. The author
  8.    also disclaims all implied warranties, including without limitation
  9.    warranties of merchantability, performance, and fitness for a
  10.    particular purpose. This software is provided "as is" and the user
  11.    assumes the entire risk as to its quality and performance.
  12.  
  13. */
  14.  
  15. #ifndef BITMAP_HPP
  16. #define BITMAP_HPP
  17.  
  18. #include <os2def.h>
  19. #include <pmbitmap.h>
  20. #include <ihandle.hpp>
  21. #include <irect.hpp>
  22. #include <ipoint.hpp>
  23. #include <fstream.h>
  24.  
  25. class Bitmap {
  26. private:
  27.    PBITMAPINFO2 _pbmi2 ;          // bitmap info2
  28.    PBYTE      _pbmb ;             // bitmap bits
  29.    ULONG      _ulScanlineSize ;   // size of scan line
  30.    IHandle          _hdc ;        // associated DC handle
  31.    IPresSpaceHandle _hps ;        // associated PS handle
  32.    IHandle          _hpal ;       // associated palette handle
  33.    IBitmapHandle    _hbm ;        // associated Gpi bitmap handle
  34.  
  35. public:
  36.    // constructors & destructor
  37.    Bitmap(IString const& fname) ;      // construct from (unopened) BMP file
  38.    Bitmap(IBitmapHandle const& hbmp) ;   // construct from GPI bitmap
  39.    Bitmap(BITMAPINFOHEADER2 const* pbmp) ;  // construct from BITMAPINFOHEADER2
  40.    ~Bitmap() ;                         // destructor
  41.                       
  42.    // Bitmap Component accessors
  43.    PBITMAPINFOHEADER2 bmp() const ;          // BITMAPINFOHEADER2 accessor
  44.    PBITMAPINFO2 bmi() const ;                // BITMAPINFO2 accessor
  45.    PRGB2 rgb(USHORT index=0) const ;       // RGB2 color table accessor
  46.    PRGB2 rgb(USHORT row, USHORT col) const ; // bitmap pel color accessor
  47.    PBYTE bmb(USHORT row=0, USHORT col=0) const ; // bitmap bits image accessor
  48.    USHORT index(USHORT row, USHORT col) const ; // bitmap pel color index accessor
  49.    ULONG scanLineSize() const ;               // returns scan line size
  50.  
  51.    void setIndex(USHORT indx, USHORT row, USHORT col) const ; // set pel
  52.  
  53.    // Gpi Bitmap stuff
  54.    IBitmapHandle createGpiBitmap(Boolean createPal=0) ; // create gpi bitmap (plus DC & PS)
  55.    void blitTo(IPresSpaceHandle hps=0) const ;    // blit from image data to hps (default = _hps)
  56.    void blitTo(IPresSpaceHandle hps, IPoint const& dest,
  57.                IRectangle const& sourceRect) const ;
  58.    void blitFrom(IPresSpaceHandle hps=0) const ;  // blit from hps (default = _hps) to image data
  59.    void blitFrom(IPresSpaceHandle hps, IPoint const& source,
  60.                  IRectangle const& destRect) const ;
  61.    void disassociate() ;             // remove association with Gpi bitmap
  62.    void deleteGpiBitmap() ;          // delete Gpi bitmap (DC & PS, etc)
  63.    IBitmapHandle hbm() const ;    // returns associated Gpi Bitmap Handle
  64.    IHandle hdc() const ;          // returns associated device context handle
  65.    IPresSpaceHandle hps() const ; // returns associated presentation space handle
  66.    IHandle hpal() const ;         // returns palette handle
  67.  
  68.    // BMP file i/o (file is opened & positioned)
  69.    void load(ifstream& BMPfile) ;    // load a bitmap (OS/2 or Win format)
  70.    void save1x(ofstream& BMPfile) const ;  // save a bitmap (OS/2 V1.x format)
  71.    void save2x(ofstream& BMPfile) const ;  // save a bitmap (OS/2 V2.x format)
  72.  
  73. };
  74.  
  75. #endif
  76.  
  77.