2

我需要用颜色填充封闭的贝西尔曲线......谁能帮我改进这段代码,因为它不起作用:

    COLORREF collor = RGB(100,50,150);
    CPen g(PS_INSIDEFRAME, 50, collor);
    pDC->SetBkColor(RGB(90, 100, 128));
    pDC->SelectObject(&g);
    CPoint Pt[10]=
{ 

    CPoint(400, 260),
    CPoint(480, 260),
    CPoint(500, 260),
    CPoint(470, 290),
    CPoint(450, 350),
    CPoint(470, 370),
    CPoint(430, 370),
    CPoint(420, 391),
    CPoint(405, 410),
    CPoint(400, 260),
};
    pDC->PolyBezier(Pt, 10);

谢谢!

4

1 回答 1

3

您需要选择一个已创建为纯色的画笔,并使用您要填充的颜色。

CBrush brush;
brush.CreateSolidBrush(collor);
CBrush * pOldBrush = (CBrush *) pDC->SelectObject(&brush);
...
pDC->SelectObject(pOldBrush);
于 2012-10-29T01:36:27.400 回答