EnBitmap.h 2.4 KB

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