GIS制图与GDI+

1. 支持 直线、弧线、曲线首尾相连多边形填充。
代码片段:
    Rect rct(25, 25, 20, 20);
    Color clr1    = Color.Gray;
    Color clr2    = Color.Yellow;
    Color clr3    = Color.Black;
    Pen   p(clr3, 3);

    GraphicsPath gPath1;
    gPath1.AddLine(150, 50, 300, 50);
    gPath1.AddLine(370, 270, 280, 340);
    gPath1.AddLine(260, 280, 170, 400);
    gPath1.AddArc(102, 230, 120, 120, 70, 180);
    gPath1.CloseFigure();
    LinearGradientBrush    lBrh(rct, clr1, clr2, 30);
    gp.FillPath(&lBrh, &gPath1);
    gp.DrawPath(&p, &gPath1);
效果图:
 
2.晕线绘制问题

在地图制作中经常会遇到晕线绘制的问题,本以为GDI+PenPen::SetAlignment()(数可以传递一下五种枚举值:PenAlignmentCenter= 0, PenAlignmentInset= 1, PenAlignmentOutset= 2, PenAlignmentLeft= 3, PenAlignmentRigh= 4)调用可以解决晕线绘制问题,但是让我失望了。

首先,Pen::SetAlignment()函数调用后,只在Graphics.DrawPath()Graphics.DrawRectangle()等绘制函数看到效果,也就是说只有在绘制闭合曲线时才能绘制内线或外线;

另外,调用Pen::SetAlignment(PenAlignmentOutset)不起作用,绘制的线没有偏移到外部,依然绘制在中部。

一下为一段测试代码:

   Graphics gp(pDC->m_hDC);

      gp.SetSmoothingMode(SmoothingModeHighQuality);

      Pen p1(Color(Color.Silver), 30);

      Pen p2(Color(Color.Red), 5);

      Pen p3(Color(Color.Green), 15);

      p1.SetLineJoin(LineJoinRound);

      p2.SetLineJoin(LineJoinRound);

      p3.SetLineJoin(LineJoinRound);

      p1.SetAlignment(PenAlignmentOutset);

      p2.SetAlignment(PenAlignmentCenter);

      p3.SetAlignment(PenAlignmentInset);

      Point pt[5] = {Point(100, 20), Point(170, 140), Point(250, 80),

                                  Point(350, 200), Point(450, 30)};

      GraphicsPath gPath;

      gPath.AddPolygon(pt, 5);

      gp.DrawPath(&p1, &gPath);

      gp.DrawPath(&p2, &gPath);

      gp.DrawPath(&p3, &gPath);

绘制 效果如下:


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值