/*****************************************************************************
* Copyright (c) 1990-99 Digi International Inc., All Rights Reserved
* 
* This software contains proprietary and confidential information of Digi
* International Inc.  By accepting transfer of this copy, Recipient agrees
* to retain this software in confidence, to prevent disclosure to others,
* and to make no use of this software other than that for which it was
* delivered.  This is an unpublished copyrighted work of Digi International
* Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
* prohibited.
* 
* Restricted Rights Legend
*
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
* Technical Data and Computer Software clause at DFARS 252.227-7031 or
* subparagraphs (c)(1) and (2) of the Commercial Computer Software -
* Restricted Rights at 48 CFR 52.227-19, as applicable.
*
* Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
*
*****************************************************************************/

// NOTE: The original source code for the CDib class was horked from
//       MSJ June, 1997.
//
//       The transparent background code was horked from an MSDN article
//       entitled "MFC Tips for Copying, Pasting, Blting, and Creating
//       Owner-Drawn List Boxes" by Nigel Thompson.


////////////////////////////////////////////////////////////////
// Copyright 1996 Microsoft Systems Journal. 
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// See dib.cpp

#if !defined(DIB_H)
#define DIB_H

// global functions for ordinary CBitmap too
//
extern CSize GetBitmapSize(CBitmap * pBitmap);

extern BOOL DrawBitmap(CDC& dc, CBitmap* pBitmap,
                       const CRect* rcDst = NULL, const CRect* rcSrc = NULL,
                       CPalette * pPal = NULL, BOOL fForeground = FALSE);

extern BOOL DrawTransBitmap(CDC& dc, CBitmap* pBitmap,
                            const CRect* rcDst = NULL, const CRect* rcSrc = NULL,
                            CPalette * pPal = NULL, BOOL fForeground = FALSE);

////////////////
// CDib implements Device Independent Bitmaps as a form of CBitmap. 
//
class CDib : public CBitmap
{
   DECLARE_DYNAMIC(CDib)

protected:
   BITMAP   m_bm;    // stored for speed
   CPalette m_pal;   // palette

   BOOL m_fTransBackground;

public:
   CDib();
   ~CDib();

   CSize GetSize() { return CSize(m_bm.bmWidth, m_bm.bmHeight); }

   BOOL Attach(HGDIOBJ hbm);

   BOOL Load(LPCTSTR szPathName, BOOL fTransBackground = FALSE);
   BOOL Load(HINSTANCE hInst, LPCTSTR lpResourceName, BOOL fTransBackground = FALSE);
   BOOL Load(HINSTANCE hInst, UINT uID, BOOL fTransBackground = FALSE)
      { return Load(hInst, MAKEINTRESOURCE(uID), fTransBackground); }

   // Universal Draw function
   BOOL Draw(CDC& dc, const CRect* rcDst = NULL, const CRect* rcSrc = NULL, 
	          CPalette* pPal = NULL, BOOL fForeground = FALSE);

   BOOL DeleteObject();
   BOOL CreatePalette(CPalette& pal);
   CPalette* GetPalette()  { return &m_pal; }

   UINT GetColorTable(RGBQUAD* colorTab, UINT nColors);
};

#endif // !defined(DIB_H)
