回答
,因爲根據這些座標,你申請某種形式擴展到圖像的你沒有表現出任何代碼。
使用PictureBox的Paint事件,這裏是一個在屏幕上使用這些座標的例子。它填補了多邊形,然後繪製邊框,然後它遍歷所有的點來繪製紅色圓圈:
void pictureBox1_Paint(object sender, PaintEventArgs e) {
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.Clear(Color.White);
// draw the shading background:
List<Point> shadePoints = new List<Point>();
shadePoints.Add(new Point(0, pictureBox1.ClientSize.Height));
shadePoints.Add(new Point(pictureBox1.ClientSize.Width, 0));
shadePoints.Add(new Point(pictureBox1.ClientSize.Width,
pictureBox1.ClientSize.Height));
e.Graphics.FillPolygon(Brushes.LightGray, shadePoints.ToArray());
// scale the drawing larger:
using (Matrix m = new Matrix()) {
m.Scale(4, 4);
e.Graphics.Transform = m;
List<Point> polyPoints = new List<Point>();
polyPoints.Add(new Point(10, 10));
polyPoints.Add(new Point(12, 35));
polyPoints.Add(new Point(22, 35));
polyPoints.Add(new Point(24, 22));
// use a semi-transparent background brush:
using (SolidBrush br = new SolidBrush(Color.FromArgb(100, Color.Yellow))) {
e.Graphics.FillPolygon(br, polyPoints.ToArray());
}
e.Graphics.DrawPolygon(Pens.DarkBlue, polyPoints.ToArray());
foreach (Point p in polyPoints) {
e.Graphics.FillEllipse(Brushes.Red,
new Rectangle(p.X - 2, p.Y - 2, 4, 4));
}
}
}
謝謝你是如此偉大的人:) – Mehmet
您可以使用Graphics.DrawPolygon。您可以將座標存儲在Point數組中,然後將其傳遞給DrawPolygon方法。你可能想看看:
Drawing with Graphics in WinForms using C#
private System.Drawing.Graphics g;
System.Drawing.Point[] p = new System.Drawing.Point[6];
p[0].X = 0;
p[0].Y = 0;
p[1].X = 53;
p[1].Y = 111;
p[2].X = 114;
p[2].Y = 86;
p[3].X = 34;
p[3].Y = 34;
p[4].X = 165;
p[4].Y = 7;
g = PictureBox1.CreateGraphics();
g.DrawPolygon(pen1, p);
在WinForms中,控件座標從左上角開始,因此您需要將它們轉換爲左下角。 – JoanComasFdz
感謝您的回答,但我想看到我的多邊形的角點不同的形狀或顏色..而這個代碼是沒有用的。我有角點,我試圖繪製像角點不同的多邊形。我希望我能告訴我的問題..([鏈接](http://stackoverflow.com/questions/12081978/how-can-i-draw-in-picturebox-a-polygon-which-is-marked-on-邊緣)這是我的祕密問題..) – Mehmet
@Mehmet,因爲你必須爲數組中的每個點繪製一個圓。你可以使用'DrawEllipse'方法 – Habib
- 1. 繪製多邊形(Google地圖)並在MySQL上插入座標
- 2. 繪製組件不根據預期的座標打印多邊形
- 3. 排序多邊形座標繪圖
- 4. 多邊形座標
- 5. 根據中心和邊長計算正多邊形的座標
- 6. 繪製多邊形的OpenLayers與WGS84座標
- 7. 怎麼看座標從繪製多邊形
- 8. 如何在地圖上繪製填充多邊形的座標
- 9. 如何在Nutiteq上的交點座標上繪製多邊形?
- 10. 如何從給定座標繪製多邊形
- 11. 繪製多邊形
- 12. 繪製多邊形
- 13. 繪製多邊形
- 14. 根據矩陣座標繪製直線
- 15. 從座標繪製矩形
- 16. 座標點爲多邊形
- 17. Java輸入座標和繪製線
- 18. 繪製多邊形,當鼠標點擊
- 19. 如何根據簡單的多邊形繪製圖像?
- 20. SVG座標數組多邊形形狀
- 21. glDrawElements繪製多邊形
- 22. 繪製多邊形PyQt的
- 23. d3 Javascript - 繪製多邊形
- 24. 如何根據GeoJSON返回的座標創建多邊形形狀
- 25. 從用戶輸入的頂點繪製多邊形google maps api
- 26. 繪製在x,y座標的左邊
- 27. 從mysql數據庫中選擇一行,根據lat,多邊形的長座標
- 28. 根據輸入時間繪製圓弧
- 29. 閃亮:根據輸入從源文件繪製圖形
- 30. 如何將kml多邊形幾何數據轉換爲Google多邊形座標
什麼應用程序的類型? winform wpf – Habib
@Habib,看着他的截圖,那是winforms – Terry
[你試過什麼](http://whathaveyoutried.com)?你卡在哪裏? – Oded