【问题标题】:Coordinates drawing on pictureBox Image在图片框图像上绘制坐标
【发布时间】:2014-06-13 01:14:23
【问题描述】:

我正在尝试在图片框上绘图,我的代码如下:

List<IntPoint> edgePoints;
List<IntPoint> corners;

AForge.Imaging.Blob[] blobs = blobCounter.GetObjectsInformation();
Graphics g = Graphics.FromImage(pictureBox2.Image);
Pen bluePen = new Pen(Color.Blue, 5);

double[] blobAdjustedSize = new double[blobs.Length];
for (int i = 0, n = blobs.Length; i < n; i++)
{
    edgePoints = blobCounter.GetBlobsEdgePoints(blobs[i]);
    corners = PointsCloud.FindQuadrilateralCorners(edgePoints);

    g.DrawPolygon(bluePen, corners); // **UNDERLINE**
}        

我得到一个错误。 g.DrawPolygon(bluePen, corners) 有下划线。

错误是:

System.Drawing.Graphics.DrawPolygon(System.Drawing.Pen, System.Drawing.Point[])" 的最佳重载方法匹配有一些无效参数

【问题讨论】:

  • 错误提到了它。您没有提供正确的参数。

标签: c# system.drawing aforge


【解决方案1】:

它需要Array of Points 而不是列表,将角定义为Array 或添加

using System.Linq;

到文件的顶部,并将行更改为

g.DrawPolygon( bluePen, corners.ToArray());

【讨论】:

  • 您需要将一个 CLR Point 对象数组传递给该方法,它可能不喜欢 aForge IntPoint,您需要将其类强制转换为 .NET 点类
  • 这是合乎逻辑的@Rich。可能你是对的。但是当我改变时,edgePoints = blobCounter.GetBlobsEdgePoints(blobs[i]);角 = PointsCloud.FindQuadrilateralCorners(edgePoints);行出错。 :) 我只计算值,而不是绘制屏幕。 :) 现在解决了。感谢您的帮助。
猜你喜欢
  • 2023-01-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-21
  • 1970-01-01
  • 1970-01-01
  • 2014-06-01
  • 2018-01-31
相关资源
最近更新 更多