EnBitmap.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /************************************************************************
  2. * 程序名: 精仿QQ主界面
  3. * 制作人: 李克平, 2011年04月11日
  4. * 版本号: 1.0
  5. ************************************************************************/
  6. // EnBitmap.h: interface for the CEnBitmap class.
  7. //
  8. //////////////////////////////////////////////////////////////////////
  9. #if !defined(AFX_ENBITMAP_H__1FDE0A4E_8AB4_11D6_95AD_EFA89432A428__INCLUDED_)
  10. #define AFX_ENBITMAP_H__1FDE0A4E_8AB4_11D6_95AD_EFA89432A428__INCLUDED_
  11. #if _MSC_VER > 1000
  12. #pragma once
  13. #endif // _MSC_VER > 1000
  14. class CEnBitmap : public CBitmap
  15. {
  16. public:
  17. HBITMAP SetBitmap(HBITMAP hBitmap);
  18. CRect GetRect();
  19. void AlphaDisplay(CDC *pDC,BYTE bAlpha);
  20. CEnBitmap();
  21. virtual ~CEnBitmap();
  22. BOOL ExtendDraw(CDC *pDC,CRect rc, int nX, int nY,BOOL bTran = FALSE,UINT colorTransparent = RGB(255,0,255));
  23. BOOL ExtendDrawImage(CEnBitmap &bmp,CRect rc, int nX, int nY);
  24. BOOL LoadImage(LPCTSTR szImagePath, COLORREF crBack = 0);
  25. BOOL LoadImage(UINT uIDRes, LPCTSTR szResourceType, HMODULE hInst = NULL, COLORREF crBack = 0);
  26. // helpers
  27. static HBITMAP LoadImageFile(LPCTSTR szImagePath, COLORREF crBack = 0);
  28. static HBITMAP LoadImageResource(UINT uIDRes, LPCTSTR szResourceType, HMODULE hInst = NULL, COLORREF crBack = 0);
  29. static BOOL GetResource(LPCTSTR lpName, LPCTSTR lpType, HMODULE hInst, void* pResource, int& nBufSize);
  30. static IPicture* LoadFromBuffer(BYTE* pBuff, int nSize);
  31. HRGN BitmapToRegion(COLORREF cTransparentColor = 0,
  32. COLORREF cTolerance = 0x101010);
  33. BOOL Draw(CDC *pDC, LPRECT r);
  34. BOOL DrawImage(CEnBitmap &bmp,int nX,int nY,int nCol,int nRow);
  35. void TransparentBlt(CDC &dc, CRect rc,UINT crTransparent );
  36. int Width()
  37. {
  38. return GetWidth();
  39. }
  40. int GetWidth()
  41. {
  42. BITMAP bm;
  43. memset( &bm, 0, sizeof(bm) );
  44. GetBitmap(&bm);
  45. return bm.bmWidth;
  46. }
  47. int Height()
  48. {
  49. return GetHeight();
  50. }
  51. int GetHeight()
  52. {
  53. BITMAP bm;
  54. memset( &bm, 0, sizeof(bm) );
  55. GetBitmap(&bm);
  56. return bm.bmHeight;
  57. }
  58. int CEnBitmap::Grey( int r, int g, int b )
  59. {
  60. return ((( b * 11 ) + ( g * 59 ) + ( r * 30 )) / 100 );
  61. }
  62. void DrawGreyScale( CDC *pDC);
  63. void DitherBlt (HDC hdcDest, int nXDest, int nYDest, int nWidth,
  64. int nHeight, HBITMAP hbm, int nXSrc, int nYSrc);
  65. HPALETTE CreateReservedPalette(CDC *pDC);
  66. void FadeColorToGrayScale( CDC *pDC, int xDest, int yDest, int nLoops,
  67. int nDelay ) ;
  68. HRGN InflateRegion(HRGN hRgn, int nXInflate, int nYInflate);
  69. HRGN CreateRegionExt(DWORD nCount, CONST RGNDATA *pRgnData );
  70. BOOL StretchDraw(CDC *pDC, LPRECT r, LPRECT sr);
  71. protected:
  72. static HBITMAP ExtractBitmap(IPicture* pPicture, COLORREF crBack);
  73. static int GetFileType(LPCTSTR szImagePath);
  74. };
  75. #endif // !defined(AFX_ENBITMAP_H__1FDE0A4E_8AB4_11D6_95AD_EFA89432A428__INCLUDED_)