如题,
GetBounds求出来的不合要求。
想实现的是求出封闭曲线的外接矩形,然后实现左到右、上到下等的渐变。
求各位先进赐教。

解决方案 »

  1.   

    回复一楼,如一楼图,那是多边形的外接矩形,我要得到的是以这三点生成的封闭曲线ClosedCurve的外切矩形。
    回复二楼,计算量有点大,另这曲线是GDI+自动生成(DrawClosedCure)的,我不知道他的生成算法。
    难道GDI+没有现成的函数算法可用吗? 急用,谢谢大家
      

  2.   

    GetBounds和GetBoundsRect为什么不符合要求?
    你也说你不知道生成算法了,所以只能依靠这种来接口来实现了,估计楼住没处理好的结果
      

  3.   

    如一楼图所示,GetBounds生成的rect只是包含了3个控制点,封闭曲线包含的范围有很多是在多边形区域外面的
      

  4.   


    这才是我要的效果(这个不是我的程序画的)。
    我的图http://hi.csdn.net/attachment/201011/15/5702112_1289819950FSSM.jpg左边一段溢出,没有参加渐变
      

  5.   


    GraphicsPath path;
    PointF points[3];
    points[0].X = 100.f;
    points[0].Y = 100.f; points[1].X = 300.f;
    points[1].Y = 300.f; points[2].X = 500.f;
    points[2].Y = 100.f;
    int count = 3;
    path.AddClosedCurve(points,count);
    path.CloseAllFigures(); Graphics g(pDC->m_hDC);
    g.SetSmoothingMode(SmoothingModeHighQuality);
    g.DrawPath(&Pen(Color::Red),&path); g.FillPath(&SolidBrush(Color::Gray),&path);
      

  6.   

    [Quote=引用 7 楼 j8daxue 的回复:]
    g.FillPath(&SolidBrush(Color::Gray),&path);
    谢谢,但是不是我想要的
    我要的是得出外切的矩形,然后基于这个矩形做渐变等,或则按高度宽度按比例填充 ,不是只要填充灰色图就好了
    如图,按getbounds出来的矩形,按高度填充了0%下面还有溢出的大量蓝色填充
      

  7.   


    GraphicsPath path;
    PointF points[3];
    points[0].X = 50.f;
    points[0].Y = 50.f; points[1].X = 50.f;
    points[1].Y = 150.f; points[2].X = 250.f;
    points[2].Y = 100.f;
    int count = 3;
    path.AddClosedCurve(points,count);
    path.CloseAllFigures(); Graphics g(pDC->m_hDC);
    g.SetSmoothingMode(SmoothingModeHighQuality);
    RectF rcf;
    path.GetBounds(&rcf);
    g.FillPath(&LinearGradientBrush(rcf,Color::White,Color::Black,0),&path);
    g.DrawPath(&Pen(Color::Black),&path);
      

  8.   

    你试过9L的代码没?
    GDI+的填充会按照路径范围剪裁。
    GetBounds在某些地方效果很好,但对于这个曲线似乎有误差,MSDN的解释是为了容下外接矩形的pen的键帽
      

  9.   

    谢谢大家。 getbounds有用。是我错了
    结贴