在圖片上畫直線比畫框更簡單。線形的控制還是通過對Pen的設置來實現的。 /**////
/// 在圖片上畫線 /// ///
原始圖 ///
起始點 ///
終止點 ///
線的顏色 ///
線寬 ///
線條樣式 ///
輸出圖
public static Bitmap DrawLineInPicture(Bitmap bmp, Point p0, Point p1, Color LineColor, int LineWidth, DashStyle ds) ...{ if (bmp == null) return null; if (p0.X == p1.X || p0.Y == p1.Y) return bmp; Graphics g = Graphics.FromImage(bmp); Brush brush = new SolidBrush(LineColor); Pen pen = new Pen(brush, LineWidth); //pen.Alignment = PenAlignment.Inset; pen.DashStyle = ds; g.DrawLine(pen,p0,p1); g.Dispose(); return bmp; } 本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/ki1381/archive/2007/08/16/1746255.aspx