home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / activexcontrol / webimage / dibcls.h < prev    next >
C/C++ Source or Header  |  1997-10-09  |  2KB  |  80 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // DibCls.h
  3. /////////////////////////////////////////////////////////////////////////////
  4. // Copyright 1995 - 1997 Microsoft Corporation.  All Rights Reserved.
  5. //
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 
  7. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
  8. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
  9. // PARTICULAR PURPOSE.
  10. /////////////////////////////////////////////////////////////////////////////
  11. //
  12. // contains the prototypes for the CDibFIle and CDibSection classes
  13. //
  14.  
  15. #ifndef __DIBCLASSES_H
  16. #define __DIBCLASSES_H
  17.  
  18.  
  19. //
  20. //    class CDibFile
  21. //
  22. class CDibFile 
  23. {
  24. public:
  25.     CDibFile();
  26.     ~CDibFile();
  27.     
  28.     HRESULT    GetFileHeader(IStream *);
  29.     HRESULT    GetInfoHeader(IStream *);
  30.  
  31.     DWORD    HeaderSize()            { return(m_headerSize); }
  32.     DWORD    CalcImageSize();
  33.  
  34.     operator BITMAPINFO * ()        { return(m_bmi.p); }
  35.     operator BITMAPINFOHEADER * ()    { return(&m_bmi.p->bmiHeader); }
  36.     
  37. private:
  38.     
  39.     DWORD    m_headerSize;
  40.     union 
  41.     {
  42.         BITMAPINFO *    p;
  43.         unsigned char *    bytes;
  44.     } m_bmi;
  45. };
  46.  
  47. class CDibSection
  48. {
  49. public:
  50.     CDibSection();
  51.     ~CDibSection();
  52.     
  53.     HRESULT Create    ( CDibFile& );
  54.     HRESULT    Setup    ( HDC basedOnThisDC);
  55.     HRESULT ReadFrom( IStream * strm, DWORD amount );
  56.     HRESULT    PaintTo    ( HDC hdc, int x = 0, int y = 0 );
  57.     HRESULT    GetSize    ( SIZEL &sz);
  58.  
  59.     DWORD    ImageSize() { return(m_imageSize); }
  60.     void    ImageSize(DWORD dw) { m_imageSize = dw; }
  61.  
  62.     operator HANDLE() { return m_handle; }
  63.  
  64.     unsigned char * Base() { return(m_bitsBase); }
  65.  
  66. private:
  67.     unsigned char *        m_bitsBase;
  68.     unsigned char *        m_current;
  69.     HDC                    m_memDC;
  70.     HBITMAP                m_handle;
  71.     HBITMAP                m_oldBitmap;
  72.     LONG                m_h;
  73.     LONG                m_w;
  74.     DWORD                m_imageSize;
  75. };
  76.  
  77.  
  78.  
  79. #endif __DIBCLASSES_H
  80.