在图片上画直线比画框更简单。线形的控制还是通过对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