EnBitmap.h 2.2 KB

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