DIB.H
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:2k
源码类别:

DirextX编程

开发平台:

Visual C++

  1. // Copyright (C) 1999 DXGuide.  All Rights Reserved.
  2. // File: DIB.h
  3. #ifndef _DIB__H
  4. #define _DIB__H
  5. #if _MSC_VER >= 1000
  6. #pragma once
  7. #endif // _MSC_VER >= 1000
  8. class CPackFileManager;
  9. class CDIB: public  CObject
  10. {
  11. DECLARE_SERIAL(CDIB)
  12. public:
  13. // Defines for the different file types.
  14. enum DIBFileType
  15. {
  16. FT_BITMAP = 0,
  17. FT_ICON = 1,
  18. FT_CURSOR = 2,
  19. FT_PALETTE = 3,
  20. };
  21. public:
  22. CDIB(void);
  23. virtual ~CDIB();
  24. public:
  25. bool Load(CFile*  pFile, bool  bPackFile = false);
  26. bool Load(LPCTSTR  lpszFileName, CPackFileManager*  pPackFileManager = NULL);
  27. bool Create(HBITMAP  hBitmap, HPALETTE  hPal, HDC  hDC = NULL);
  28. bool Create(HDC  hDC);
  29. bool CreateFormCapture(HWND  hSourceWnd, bool  bClient);
  30. bool Save(LPCTSTR  lpszFileName) const;
  31. bool Save(CFile*  pFile) const;
  32. protected:
  33. virtual bool LoadFileHeader(CFile*  pFile,
  34. bool  bPackFile, DWORD&  dwDIBSize);
  35. public:
  36. bool Draw(HDC  hDC, int  nDestX, int  nDestY) const;
  37. bool Draw(HDC  hDC, LPRECT  lpDCRect, LPRECT  lpDIBRect) const;
  38. virtual int GetWidth(void) const;
  39. virtual int GetHeight(void) const;
  40. bool IsValid(void) const;
  41. int GetBitsPerPixel(void) const;
  42. void GetRect(RECT*  pRect) const;
  43. int GetNumClrEntries(void) const;
  44. RGBQUAD* GetClrTabAddress(void) const;
  45. DWORD GetPaletteSize(void) const;
  46. const BITMAPINFO* GetBitmapInfoAddress(void) const;
  47. static HBITMAP CaptureWindow(HWND  hSourceWnd, bool  bClient, HDC&  hDCSource);
  48. static int NumDIBColorEntries(BITMAPINFO const*  pBMI);
  49. public:
  50. virtual void Serialize(CArchive&  ar);
  51. public:
  52. // Clipboard support
  53. HGLOBAL CopyToHandle(void) const;
  54. bool LoadFromHandle(HGLOBAL  hGlobal);
  55. protected:
  56. LPBITMAPINFO m_pBMI;
  57. LPBYTE m_pBits;
  58. bool m_bMyBits;
  59. };
  60. #include "DIB.inl"
  61. #endif // _DIB__H