123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- /************************************************************************/
- /* Copyright (C), 2016-2020, [IT], 保留所有权利;
- /* 模 块 名:;
- /* 描 述:;
- /*
- /* 版 本:[V];
- /* 作 者:[IT];
- /* 日 期:[8/19/2016];
- /*
- /*
- /* 注 意:;
- /*
- /* 修改记录:[IT];
- /* 修改日期:;
- /* 修改版本:;
- /* 修改内容:;
- /************************************************************************/
- #ifndef __ENBITMAP_20160823__
- #define __ENBITMAP_20160823__
- #pragma once
- class CEnBitmap : public CBitmap
- {
- public:
- HBITMAP SetBitmap(HBITMAP hBitmap);
- CRect GetRect();
- void AlphaDisplay(CDC *pDC, BYTE bAlpha);
- CEnBitmap();
- virtual ~CEnBitmap();
- BOOL ExtendDraw(IN CDC *pDC, IN CRect rc, IN int nX, IN int nY, IN BOOL bTran = FALSE, IN UINT colorTransparent = RGB(255, 0, 255));
- BOOL ExtendDrawImage(OUT CEnBitmap &bmp, IN CRect rc, IN int nX, IN int nY);
- BOOL LoadImage(LPCTSTR szImagePath, COLORREF crBack = 0);
- BOOL LoadImage(UINT uIDRes, LPCTSTR szResourceType, HMODULE hInst = NULL, COLORREF crBack = 0);
- // helpers
- static HBITMAP LoadImageFile(LPCTSTR szImagePath, COLORREF crBack = 0);
- static HBITMAP LoadImageResource(UINT uIDRes, LPCTSTR szResourceType, HMODULE hInst = NULL, COLORREF crBack = 0);
- static BOOL GetResource(LPCTSTR lpName, LPCTSTR lpType, HMODULE hInst, void* pResource, int& nBufSize);
- static IPicture* LoadFromBuffer(BYTE* pBuff, int nSize);
- HRGN BitmapToRegion(COLORREF cTransparentColor = 0, COLORREF cTolerance = 0x101010);
- BOOL Draw(CDC *pDC, LPRECT r);
- BOOL DrawImage(CEnBitmap &bmp, int nX, int nY, int nCol, int nRow);
- void TransparentBlt(IN CDC &dc, IN CRect rc, IN UINT colorTransparent);
- int Width()
- {
- return GetWidth();
- }
- int GetWidth()
- {
- BITMAP bm;
- memset(&bm, 0, sizeof(bm));
- GetBitmap(&bm);
- return bm.bmWidth;
- }
- int Height()
- {
- return GetHeight();
- }
- int GetHeight()
- {
- BITMAP bm;
- memset(&bm, 0, sizeof(bm));
- GetBitmap(&bm);
- return bm.bmHeight;
- }
- int CEnBitmap::Grey(int r, int g, int b)
- {
- return (((b * 11) + (g * 59) + (r * 30)) / 100);
- }
- void DrawGreyScale(CDC *pDC);
- void DitherBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth,
- int nHeight, HBITMAP hbm, int nXSrc, int nYSrc);
- HPALETTE CreateReservedPalette(CDC *pDC);
- void FadeColorToGrayScale(CDC *pDC, int xDest, int yDest, int nLoops,
- int nDelay);
- HRGN InflateRegion(HRGN hRgn, int nXInflate, int nYInflate);
- HRGN CreateRegionExt(DWORD nCount, CONST RGNDATA *pRgnData);
- BOOL StretchDraw(CDC *pDC, LPRECT r, LPRECT sr);
- protected:
- static HBITMAP ExtractBitmap(IPicture* pPicture, COLORREF crBack);
- static int GetFileType(LPCTSTR szImagePath);
- };
- #endif // __ENBITMAP_20160823__
|