BitmapEx.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // BitmapEx.h: interface for the CBitmapEx class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_BitmapEx_H__73EF928E_90A7_461A_B879_7E3007684679__INCLUDED_)
  5. #define AFX_BitmapEx_H__73EF928E_90A7_461A_B879_7E3007684679__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. //#include "include\Picture.h"
  10. //#include "EnBitmap.h"
  11. class CBitmapEx : public CBitmap
  12. {
  13. public:
  14. BOOL Draw(CDC *pDC, LPRECT r, int pos);
  15. void TransParentDraw(CDC *pDC, CRect rc, COLORREF col);
  16. BOOL LoadImage(LPCTSTR szImagePath, COLORREF crBack = 0);
  17. BOOL LoadImage(UINT uIDRes, LPCTSTR szResourceType, HMODULE hInst = NULL, COLORREF crBack = 0);
  18. // helpers
  19. static BOOL GetResource(LPCTSTR lpName, LPCTSTR lpType, HMODULE hInst, void* pResource, int& nBufSize);
  20. static IPicture* LoadFromBuffer(BYTE* pBuff, int nSize);
  21. BOOL Draw( CDC *pDC, LPRECT r);
  22. //draw sub bmp to special point
  23. BOOL Draw( CDC *pDC, int x, int y, LPRECT sr );
  24. BOOL Draw( CDC *pDC, int x, int y, LPRECT sr, COLORREF colTrans, BOOL bTrans );
  25. BOOL StretchDraw(CDC *pDC, LPRECT tr, LPRECT sr );
  26. BOOL StretchDraw(CDC *pDC, LPRECT r);
  27. BOOL StretchDraw2(CDC *pDC, LPRECT r);
  28. int Width()
  29. {
  30. return GetWidth();
  31. }
  32. int GetWidth()
  33. {
  34. BITMAP bm;
  35. memset( &bm, 0, sizeof(bm) );
  36. GetBitmap(&bm);
  37. return bm.bmWidth;
  38. }
  39. int Height()
  40. {
  41. return GetHeight();
  42. }
  43. int GetHeight()
  44. {
  45. BITMAP bm;
  46. memset( &bm, 0, sizeof(bm) );
  47. GetBitmap(&bm);
  48. return bm.bmHeight;
  49. }
  50. CBitmapEx();
  51. virtual ~CBitmapEx();
  52. BOOL Attach(IPicture* pPicture, COLORREF crBack);
  53. BOOL Attach( HBITMAP hbmp )
  54. {
  55. return CBitmap::Attach( hbmp );
  56. }
  57. /*
  58. HBITMAP hBitmap = NULL;
  59. hBitmap = (HBITMAP)LoadImage(NULL, szFilename, IMAGE_BITMAP, 0, 0,
  60. LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
  61. */
  62. /* BOOL LoadBitmap(LPCTSTR szFilename)
  63. {
  64. ASSERT(szFilename);
  65. DeleteObject();*/
  66. /*
  67. CClientDC dc(NULL);
  68. CPicture pic;
  69. if ( !pic.LoadPicture( szFilename ) )
  70. return FALSE;
  71. HBITMAP hBitmap = pic.CreateDDB(&dc);
  72. pic.DeleteObject();
  73. return Attach(hBitmap);
  74. */
  75. // return LoadImage( szFilename );
  76. // }
  77. BOOL DrawTransparent(CDC * pDC, int x, int y, COLORREF crColour);
  78. HRGN CreateRgnFromFile( COLORREF color );
  79. };
  80. #endif // !defined(AFX_BitmapEx_H__73EF928E_90A7_461A_B879_7E3007684679__INCLUDED_)