MFC基础--怎样贴一张圆型的位图

来源:百度知道 编辑:UC知道 时间:2024/06/22 08:58:55
//To invoke this function with the position
BOOL IsBlack = TRUE;//set the black stone defautly
CBitMap m_bStoneB;
CBitMap m_bStoneW;
//load bmp from resource
m_bStoneB.LoadBitmap(IDB_BLACKSTONE);
m_bStoneW.LoadBitmap(IDB_WHITESTONE);
void CxxDlg::OnPutStone(CPoint point)
{
CDC *pDC = GetDC(); //Get Device Context
CBitmap *pOldBitmap;
CBrush *pOldBrush;
CPen *pOldPen;
if(pDC == NULL)
return;
CDC dcimage;
if (!dcimage.CreateCompatibleDC(pDC)) //Create MemDC
return;
CRect rect; //Get the rectangle of stone;
rect.left = point.x - 25/3;
rect.right = point.x + 25/3;
rect.top = point.y - 25/3;
rect.bottom = point.y + 25/3;
if(IsBlack) //judge whether stone is black
{
//Select blackstone in memory and select out oldbitmap
pOldBitmap = dcimage.SelectObject(&m_bStoneB);
CBrush br(RGB

//To invoke this function with the position
BOOL IsBlack = TRUE;//set the black stone defautly 默认设置成黑色
CBitMap m_bStoneB;
CBitMap m_bStoneW;
//load bmp from resource
m_bStoneB.LoadBitmap(IDB_BLACKSTONE); 载入位图资源
m_bStoneW.LoadBitmap(IDB_WHITESTONE);
void CxxDlg::OnPutStone(CPoint point)
{
CDC *pDC = GetDC(); //Get Device Context 得到设备环境
CBitmap *pOldBitmap;
CBrush *pOldBrush;
CPen *pOldPen;
if(pDC == NULL)
return;
CDC dcimage;
if (!dcimage.CreateCompatibleDC(pDC)) //Create MemDC 创建内存设备环境
return;
CRect rect; //Get the rectangle of stone;
rect.left = point.x - 25/3;
rect.right = point.x + 25/3;
rect.top = point.y - 25/3;
rect.bottom = point.y + 25/3;
if(IsBlack) //judge whether stone is black 判断是否为黑色,若是则执行
{
//Select blackstone in memory and select out oldbitmap
pOldBitmap = dcimage.SelectObject(&m_bStoneB); 选入设备环境
CBrush br(RG