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.

89 lines
3.3 KiB

  1. /*************************************************************************/
  2. /* Copyright (C) 1999 Microsoft Corporation */
  3. /* File: CBitmap.h */
  4. /* Description: Bitmap control which supports drawing bitmaps for */
  5. /* buttons, images, etc. phillu 11/16/99 */
  6. /*************************************************************************/
  7. #ifndef _INC_CBITMAP
  8. #define _INC_CBITMAP
  9. #include "MSMFCnt.h" // for definitions of the blit types
  10. #define RECTWIDTH(lpRect) ((lpRect)->right - (lpRect)->left)
  11. #define RECTHEIGHT(lpRect) ((lpRect)->bottom - (lpRect)->top)
  12. class CBitmap {
  13. public:
  14. /* Function prototypes */
  15. CBitmap(){ Init();}
  16. virtual ~CBitmap() {CleanUp();}
  17. void Init();
  18. void CleanUp();
  19. bool IsEmpty();
  20. HPALETTE GetPal() { return NULL == m_hPal? m_hMosaicPAL : m_hPal;}
  21. static HPALETTE GetSuperPal() { return m_hMosaicPAL;}
  22. RECT GetDIBRect() {return m_rc;}
  23. BOOL CreateMemDC(HDC, LPRECT);
  24. BOOL DeleteMemDC();
  25. BOOL CreateSrcDC(HDC hDC);
  26. BOOL LookupBitmapRect(LPTSTR, LPRECT);
  27. BOOL CustomContainerStretch(HDC hDc, LPRECT lpRect);
  28. BOOL StretchKeepAspectRatio(HDC hDC, LPRECT lpRect);
  29. BOOL StretchPaint(HDC, LPRECT, COLORREF);
  30. COLORREF GetTransparentColor();
  31. BOOL PaintTransparentDIB(HDC, LPRECT, LPRECT);
  32. HRESULT PutImage(BSTR strFilename, HINSTANCE hRes = NULL, BOOL bFromMosaic = FALSE, TransparentBlitType=DISABLE, StretchType=NORMAL);
  33. void LoadPalette(bool fLoadPalette){m_fLoadPalette = fLoadPalette;};
  34. HRESULT LoadPalette(TCHAR* strFilename, HINSTANCE hRes);
  35. void OnDispChange(long cBitsPerPixel, long cxScreen, long cyScreen);
  36. static HRESULT SelectRelizePalette(HDC hdc, HPALETTE hPal, HPALETTE *hPalOld = NULL);
  37. static void FinalRelease();
  38. static void DeleteMosaicDC();
  39. protected:
  40. HRESULT LoadPalette(TCHAR* strFilename, HINSTANCE hRes, HPALETTE *phPal);
  41. HANDLE LoadImage(HINSTANCE hInst, LPCTSTR lpszName, UINT uType,
  42. int cxDesired, int cyDesired, UINT fuLoad,HPALETTE *phPal = NULL);
  43. HRESULT InitilizeMosaic(HINSTANCE hRes);
  44. HRESULT LoadImageFromRes(BSTR strFileName, HINSTANCE hRes);
  45. protected:
  46. static HBITMAP m_hMosaicBMP;
  47. static HBITMAP m_hMosaicBMPOld;
  48. static HPALETTE m_hMosaicPAL;
  49. static HPALETTE m_hMosaicPALOld;
  50. static HDC m_hMosaicDC;
  51. static bool m_fLoadMosaic; // flag to see if we should try to reload mosaic
  52. static long m_cBitsPerPixel;
  53. static long m_cxScreen;
  54. static long m_cyScreen;
  55. BOOL m_bUseMosaicBitmap;
  56. HBITMAP m_hBitmap;
  57. HBITMAP m_hBitmapOld;
  58. HDC m_hSrcDC;
  59. HPALETTE m_hPal;
  60. HPALETTE m_hPalOld;
  61. RECT m_rc;
  62. HDC m_hMemDC;
  63. HBITMAP m_hMemBMP;
  64. HBITMAP m_hMemBMPOld;
  65. HPALETTE m_hMemPALOld;
  66. LONG m_iMemDCWidth;
  67. LONG m_iMemDCHeight;
  68. bool m_fLoadPalette;
  69. TransparentBlitType m_blitType;
  70. StretchType m_stretchType;
  71. HINSTANCE m_hInstanceRes;
  72. CComBSTR m_strFileName;
  73. };
  74. #endif //!_INC_CBITMAP
  75. /*************************************************************************/
  76. /* End of file: CBitmap.h */
  77. /*************************************************************************/