Skip to main content

Posts

Showing posts from February, 2008

在 C# 的 Bitmap 上畫線的時候,避免線條、連接處有缺角或破碎的方法

public void BitmapDrawLine(Bitmap bM, Point sPoint, Point ePoint, Color lineColor,float lineThickness) {     Graphics g = Graphics.FromImage(bM);     Pen myPen = new Pen(lineColor, lineThickness);         myPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;     // 設定線條的端點及連接樣式     myPen.SetLineCap(System.Drawing.Drawing2D.LineCap.Round,     System.Drawing.Drawing2D.LineCap.Round,     System.Drawing.Drawing2D.DashCap.Round);     g.DrawLine(myPen, sPoint, ePoint); }