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.

80 lines
2.9 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: Cbitmap.h
  3. //
  4. // Desc: CBitmap class is an object that wraps around a Windows bitmap.
  5. //
  6. // Copyright (C) 1999-2000 Microsoft Corporation. All Rights Reserved.
  7. //-----------------------------------------------------------------------------
  8. #ifndef __CBITMAP_H__
  9. #define __CBITMAP_H__
  10. //@@BEGIN_MSINTERNAL
  11. //typedef WINGDIAPI BOOL (WINAPI* ALPHABLEND)( HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION);
  12. //extern ALPHABLEND g_AlphaBlend;
  13. //extern HMODULE g_MSImg32;
  14. //@@END_MSINTERNAL
  15. class CBitmap
  16. {
  17. private:
  18. CBitmap() :
  19. m_hbm(NULL),
  20. m_bSizeKnown(FALSE),
  21. m_hDCInto(NULL), m_hOldBitmap(NULL)
  22. {}
  23. public:
  24. ~CBitmap();
  25. static CBitmap *CreateViaD3DX(LPCTSTR tszFileName, LPDIRECT3DSURFACE8 pUISurf = NULL);
  26. static CBitmap *CreateViaLoadImage(HINSTANCE hInst, LPCTSTR tszName, UINT uType, int cx, int cy, UINT fuLoad);
  27. static CBitmap *CreateFromResource(HINSTANCE hInst, UINT uID) {return CreateFromResource(hInst, MAKEINTRESOURCE(uID));}
  28. static CBitmap *CreateFromResource(HINSTANCE hInst, LPCTSTR tszName);
  29. static CBitmap *CreateFromFile(LPCTSTR tszFileName);
  30. static CBitmap *StealToCreate(HBITMAP &refbm);
  31. static CBitmap *Create(int cx, int cy, HDC hDC = NULL) {SIZE size = {cx, cy}; return Create(size, hDC);}
  32. static CBitmap *Create(SIZE, HDC = NULL);
  33. static CBitmap *Create(SIZE, COLORREF, HDC = NULL);
  34. static CBitmap *CreateHorzGradient(const RECT &, COLORREF, COLORREF);
  35. BOOL GetSize(SIZE *psize);
  36. void AssumeSize(SIZE size);
  37. BOOL FigureSize();
  38. CBitmap *CreateResizedTo(SIZE size, HDC hDC = NULL, int iStretchMode = HALFTONE, BOOL bStretch = TRUE);
  39. CBitmap *Dup();
  40. BOOL Get(HDC hDC, POINT point, SIZE size);
  41. BOOL Get(HDC hDC, POINT point);
  42. BOOL Draw(HDC hDC) {return Draw(hDC, 0, 0);}
  43. BOOL Draw(HDC hDC, SIZE size) {return Draw(hDC, 0, 0, size);}
  44. BOOL Draw(HDC hDC, int x, int y, SIZE size) {POINT t = {x, y}; return Draw(hDC, t, size);}
  45. BOOL Draw(HDC hDC, int x, int y) {POINT t = {x, y}; return Draw(hDC, t);}
  46. BOOL Draw(HDC hDC, POINT origin) {SIZE t = {0, 0}; return Draw(hDC, origin, t, TRUE);}
  47. BOOL Draw(HDC hDC, POINT origin, SIZE size, BOOL bAll = FALSE);
  48. BOOL Blend(HDC hDC) {return Blend(hDC, 0, 0);}
  49. BOOL Blend(HDC hDC, SIZE size) {return Blend(hDC, 0, 0, size);}
  50. BOOL Blend(HDC hDC, int x, int y, SIZE size) {POINT t = {x, y}; return Blend(hDC, t, size);}
  51. BOOL Blend(HDC hDC, int x, int y) {POINT t = {x, y}; return Blend(hDC, t);}
  52. BOOL Blend(HDC hDC, POINT origin) {SIZE t = {0, 0}; return Blend(hDC, origin, t, TRUE);}
  53. BOOL Blend(HDC hDC, POINT origin, SIZE size, BOOL bAll = FALSE);
  54. HDC BeginPaintInto(HDC hCDC = NULL);
  55. void EndPaintInto(HDC &hDC);
  56. BOOL MapToDC(HDC hDCTo, HDC hDCMapFrom = NULL);
  57. private:
  58. HBITMAP m_hbm;
  59. SIZE m_size;
  60. BOOL m_bSizeKnown;
  61. HDC m_hDCInto;
  62. HGDIOBJ m_hOldBitmap;
  63. void PopOut();
  64. void PopIn();
  65. };
  66. #endif //__CBITMAP_H__