请选择 进入手机版 | 继续访问电脑版
爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 2793|回复: 2

在使用wContour.dll 时总出错误,请王老师指导!

[复制链接]

新浪微博达人勋

发表于 2015-11-17 10:39:04 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 kmdqlb 于 2015-11-17 10:40 编辑

QQ截图20151117103300.png
王老师,您好!http://bbs.06climate.com/forum.php?mod=attachment&aid=NDAzODN8Y2ZlZWFlNDgyY2E4NDQ4YzYwYTFlMTgxNWQ1OGVjYzZ8MTcxMTcxNDQyNA%3D%3D&request=yes&_f=.pngattach://40383.pnghttp://bbs.06climate.com/forum.php?mod=attachment&aid=NDAzODN8Y2ZlZWFlNDgyY2E4NDQ4YzYwYTFlMTgxNWQ1OGVjYzZ8MTcxMTcxNDQyNA%3D%3D&request=yes&_f=.pngattach://40383.png
我在使用wContour.dll 时总提示出错误!请您帮我看看是哪出错了?
以下是我的代码(c#)
Bitmap b = new Bitmap(500, 500);
          Graphics g = Graphics.FromImage(b);
          //g.Clear(Color.White);
          ////
          CreateDiscreteData(20);
          InterpolateData(20, 20);
          double[] values = new double[] { 20, 30, 40, 50, 60, 70, 80, 90 };
          SetContourValues(values);
          TracingContourLines();
          SmoothLines();
          GetEcllipseClipping();
          ClipLines();
          TracingPolygons();
          ClipPolygons();
          SetCoordinate(-10, 50, -10, 50);
          int i = 0;
          int j = 0;
          wContour.PolyLine aline = default(wContour.PolyLine);
          List<PointD> newPList = new List<PointD>();
          double aValue = 0;
          Color aColor = default(Color);
          Pen aPen = default(Pen);
          wContour.PointD aPoint = default(wContour.PointD);
          Point[] Points = null;
          int sX = 0;
          int sY = 0;
          //Draw contour polygons
          List<Polygon> drawPolygons = _contourPolygons;
          drawPolygons = _clipContourPolygons;
          Color aBackcolor = Color.White;
          SolidBrush aBrush = default(SolidBrush);
          wContour.Polygon aPolygon = default(wContour.Polygon);
          //Region selRegion = new Region();
          GraphicsPath selPath = new GraphicsPath();
          for (i = 0; i <= drawPolygons.Count - 1; i++)
          {
              aPolygon = drawPolygons;
              aline = aPolygon.OutLine;
              aValue = aPolygon.LowValue;
              aColor = _colors[Array.IndexOf(_CValues, aValue) + 1];
              if (!aPolygon.IsHighCenter)
              {
                  for (j = 0; j <= _colors.Length - 1; j++)
                  {
                      if (aColor == _colors[j])
                      {
                          aColor = _colors[j - 1];
                      }
                  }
              }
              newPList = aline.PointList;
              //if (!Contour.IsClockwise(newPList))
              //    newPList.Reverse();
              Points = new Point[newPList.Count];
              for (j = 0; j <= newPList.Count - 1; j++)
              {
                  aPoint = newPList[j];
                  ToScreen(aPoint.X, aPoint.Y, ref sX, ref sY);
                  Points[j] = new Point(sX, sY);
              }
              GraphicsPath bPath = new GraphicsPath();
              GraphicsPath aPath = new GraphicsPath();
              aPath.AddPolygon(Points);
              bPath.AddLines(Points);
              //Region aRegion = new Region(aPath);
              if (aPolygon.HasHoles)
              {
                  for (int h = 0; h < aPolygon.HoleLines.Count; h++)
                  {
                      newPList = aPolygon.HoleLines[h].PointList;
                      //if (Contour.IsClockwise(newPList))
                      //    newPList.Reverse();
                      Points = new Point[newPList.Count];
                      for (j = 0; j <= newPList.Count - 1; j++)
                      {
                          aPoint = newPList[j];
                          ToScreen(aPoint.X, aPoint.Y, ref sX, ref sY);
                          Points[j] = new Point(sX, sY);
                      }
                      //aPath = new GraphicsPath();
                      aPath.AddPolygon(Points);
                      GraphicsPath cPath = new GraphicsPath();
                      cPath.AddLines(Points);
                      bPath.AddPath(cPath, false);
                      //aRegion.Xor(aPath);
                  }
              }
              aPen = new Pen(Color.Black);
              aPen.Color = aColor;
              aBrush = new SolidBrush(Color.Black);
              aBrush.Color = aColor;
              if (i == _highlightIdx)
                  selPath = aPath;
              //selRegion = aRegion;
              //g.FillRegion(aBrush, aRegion);
              g.FillPath(aBrush, aPath);
              //g.DrawPath(Pens.Gray, bPath);
              g.DrawPath(Pens.Black, bPath);
              //g.FillPolygon(aBrush, Points);
              //g.DrawLines(Pens.Gray, Points);
          }
          //Draw contour lines
          List<PolyLine> drawLines = _contourLines;
          drawLines = _clipContourLines;
          for (i = 0; i <= drawLines.Count - 1; i++)
          {
              aline = drawLines;
              aValue = aline.Value;
              aColor = _colors[Array.IndexOf(_CValues, aValue)];
              newPList = aline.PointList;
              Points = new Point[newPList.Count];
              for (j = 0; j <= newPList.Count - 1; j++)
              {
                  aPoint = (wContour.PointD)newPList[j];
                  ToScreen(aPoint.X, aPoint.Y, ref sX, ref sY);
                  Points[j] = new Point(sX, sY);
              }
              aPen = new Pen(Color.Black);
              aPen.Color = aColor;
              g.DrawLines(aPen, Points);
          }
         
          //Draw map lines
          if (_mapLines.Count > 0)
          {
              for (i = 0; i < _mapLines.Count; i++)
              {
                  newPList = _mapLines;
                  Points = new Point[newPList.Count];
                  for (j = 0; j <= newPList.Count - 1; j++)
                  {
                      aPoint = newPList[j];
                      ToScreen(aPoint.X, aPoint.Y, ref sX, ref sY);
                      Points[j] = new Point(sX, sY);
                  }
                  aPen = new Pen(Color.Black);
                  aPen.Color = Color.Black;
                  g.DrawLines(aPen, Points);
                  //g.DrawString("0", new Font("Arial", 8), new SolidBrush(Color.Black), Points[0]);
              }
          }

           /////
          MemoryStream ms = new MemoryStream();
          b.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
QQ截图20151117103300.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-11-17 10:58:25 | 显示全部楼层
错误信息已经很清楚了,这种问题需要你自己调试。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-11-17 11:11:23 | 显示全部楼层
后来我加了个try catch ,图片变成了这样,不知道正常吗?王老师,谢谢! QQ截图.png
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表