星期一, 10月 01, 2007

在圖片上畫圖

範例:在圖上畫路徑
/*
* 在圖片上畫路徑,最後利用pictureBox存檔
*/
1.先設定繪畫
String pictureFileName=@"C:\picture.jpg";
String saveFileName=@"C:\test.jpg";

//set grapthic tool on specific image
Graphics graphics = Graphics.FromImage(pictureFileName);

//set a path
GraphicsPath path;
path = new GraphicsPath(new Point[]{ new Point(285, 315),new Point(190, 150),new Point(85, 120), new Point(80, 60),new Point(95, 80)},
new byte[] {(byte)PathPointType.Start,(byte)PathPointType.Line,(byte)PathPointType.Line,(byte)PathPointType.Line,(byte)PathPointType.Line });
graphics.DrawPath(Pens.Blue, path);

//save the grpahic
graphics.Save(saveFileName);

沒有留言: