2007년 4월 8일 일요일

GDI+ clipping region

void CGdiplusDemoView::OnDraw(CDC* pDC)
{
    Graphics g(pDC->m_hDC);

    // Create region
    Point points[] = {
        Point(10, 30), Point(200, 10), Point(150, 50), Point(170, 150)
    };
    GraphicsPath path;
    path.AddPolygon(points, 4);
    Region region(&path);

    // Draw region
    Pen pen(Color(255, 0, 0, 0));
    g.DrawPath(&pen, &path);

    // Clipping
    g.SetClip(®ion);

    // Display text
    FontFamily fontFamily(L"Arial");
    Font font(&fontFamily, 36, FontStyleBold, UnitPixel);
    SolidBrush brush(Color(255, 255, 0, 0));

    g.DrawString(L"Clipping", 20, &font, PointF(15, 25), &brush);
}


댓글 없음: