MFC中GDI之CRgn类

CRgn类(区域)
新建对话框类,修改OnPaint(),

MFC中GDI之CRgn类
void CCRgnDlg::OnPaint()
{
    CPaintDC dc(this);
    CBitmap bmp;
    bmp.LoadBitmap(IDB_BITMAP1);
    BITMAP bm;
    bmp.GetBitmap(&bm);
    int cx = bm.bmWidth;
    int cy = bm.bmHeight;
    CDC mdc;
    mdc.CreateCompatibleDC(&dc);
    mdc.SelectObject(&bmp);
    POINT pts[] = {
        { 120, 10 }, { 10, 190 }, { 230, 190 },
        { 10, 70 }, { 230, 70 }, { 120, 240 },
    };
    CRgn rg1;
    rg1.CreatePolygonRgn(pts, 3, WINDING);//创建多边形1
    CRgn rg2;
    rg2.CreatePolygonRgn(pts+3, 3, WINDING);//创建多边形2
    rg2.CombineRgn(&rg1, &rg2, RGN_OR);//联合多边形1,2
    dc.SelectObject(&rg2);
    dc.BitBlt(0, 0, cx, cy, &mdc, 0, 0, SRCCOPY);
}
View Code

MFC中GDI之CRgn类

 

上一篇:BM求线性递推式(板子整理)


下一篇:代码演示简单的BMP文件操作