Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.3 KiB

  1. // CBitmap.h
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (c) 1992 - 1999 Microsoft Corporation. All Rights Reserved.
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12. #ifndef _INC_CBITMAP
  13. #define _INC_CBITMAP
  14. #include "MSMFCnt.h" // for definitions of the blit types
  15. /* Handle to a DIB */
  16. DECLARE_HANDLE(HDIB);
  17. /* DIB constants */
  18. #define PALVERSION 0x300
  19. /* DIB Macros*/
  20. #define IS_WIN30_DIB(lpbi) ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER))
  21. #define RECTWIDTH(lpRect) ((lpRect)->right - (lpRect)->left)
  22. #define RECTHEIGHT(lpRect) ((lpRect)->bottom - (lpRect)->top)
  23. // WIDTHBYTES performs DWORD-aligning of DIB scanlines. The "bits"
  24. // parameter is the bit count for the scanline (biWidth * biBitCount),
  25. // and this macro returns the number of DWORD-aligned bytes needed
  26. // to hold those bits.
  27. #define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4)
  28. // Some helper functions
  29. inline DWORD WINAPI DIBSize(LPSTR lpDIB);
  30. inline DWORD WINAPI DIBWidth (LPSTR lpDIB);
  31. inline DWORD WINAPI DIBHeight (LPSTR lpDIB);
  32. inline BYTE RGBtoL(BYTE R, BYTE G, BYTE B);
  33. HGLOBAL WINAPI CopyHandle (HGLOBAL h);
  34. class CBitmap {
  35. public:
  36. /* Function prototypes */
  37. CBitmap(){ Init();}
  38. virtual ~CBitmap() {CleanUp();}
  39. void Init();
  40. void CleanUp();
  41. HPALETTE GetPal() { return m_hPal;}
  42. RECT GetDIBRect() {return m_rc;}
  43. BOOL CreateMemDC(HDC, LPRECT);
  44. BOOL DeleteMemDC();
  45. BOOL CreateTransDC(HDC, LPRECT);
  46. BOOL DeleteTransDC();
  47. BOOL BlitMemDC(HDC hDc, LPRECT lpDCRect, LPRECT lpDIBRect);
  48. HRESULT WINAPI SetImage(TCHAR* strFilename, HINSTANCE hRes);
  49. BOOL WINAPI PaintDIB (HDC, LPRECT, LPRECT, LPRECT, bool complex=false);
  50. BOOL WINAPI PaintTransparentDIB(HDC, LPRECT, LPRECT, TransparentBlitType, bool complex=false, HWND hWnd=NULL);
  51. BOOL WINAPI CreateDIBPalette();
  52. BOOL WINAPI ConvertColorTableGray();
  53. BOOL WINAPI ConvertDIBGray(TransparentBlitType blitType);
  54. LPSTR WINAPI FindDIBBits (LPSTR lpbi);
  55. WORD WINAPI PaletteSize (LPSTR lpbi);
  56. WORD WINAPI DIBNumColors (LPSTR lpbi);
  57. HGLOBAL WINAPI CopyHandle (HGLOBAL h);
  58. bool IsEmpty(){return(NULL == m_hDIB);};
  59. bool IsPaletteLoaded(){return(m_fLoadPalette);}
  60. void LoadPalette(bool fLoadPalette){m_fLoadPalette = fLoadPalette;};
  61. HDIB WINAPI ReadDIBFile(LPCTSTR pszFileName, HINSTANCE hRes);
  62. HRESULT PutImage(BSTR strFilename, HINSTANCE hRes = NULL, IUnknown* pUnk = NULL, bool fGrayOut=false, TransparentBlitType=DISABLE);
  63. HRESULT XORRegion(HRGN *phRgn, HRGN hRgn, const RECT &rc) const;
  64. HRESULT GetRegion(HDC hDC, HRGN *phRgn, RECT* pRect, COLORREF, bool fInvert=FALSE) const;
  65. protected:
  66. HDIB m_hDIB;
  67. HPALETTE m_hPal;
  68. RECT m_rc;
  69. HDC m_hMemDC;
  70. HBITMAP m_hMemBMP;
  71. LONG m_iMemDCWidth;
  72. LONG m_iMemDCHeight;
  73. HDC m_hTransDC;
  74. HBITMAP m_hTransBMP;
  75. LONG m_iTransDCWidth;
  76. LONG m_iTransDCHeight;
  77. HRGN m_hRgn;
  78. bool m_fLoadPalette;
  79. };
  80. #endif //!_INC_CBITMAP