我现在想在panel中用DrawLine()方法画两条直线,然后用什么办法能把刚才画的直线变成图片格式,方便以后调用。希望各位能给我点思路。
谢谢
3 个解决方案
#1
直接在panel上放个bmp,画在bmp上面,然后保存
#2
panel.CreateGraghics
#3
附代码:
Bitmap bm = new Bitmap(this.Width, this.Height);
Pen arrowPen = new Pen(Color.Black);
arrowPen.Width = 1;
System.Drawing.Drawing2D.AdjustableArrowCap lineCap =
new System.Drawing.Drawing2D.AdjustableArrowCap(3, 3, true);
arrowPen.CustomEndCap = lineCap;
Graphics gfx = Graphics.FromImage(bm);
gfx.DrawLine(arrowPen, pointX, pointY);
gfx.Save();
this.BackgroundImage = bm;
#1
直接在panel上放个bmp,画在bmp上面,然后保存
#2
panel.CreateGraghics
#3
附代码:
Bitmap bm = new Bitmap(this.Width, this.Height);
Pen arrowPen = new Pen(Color.Black);
arrowPen.Width = 1;
System.Drawing.Drawing2D.AdjustableArrowCap lineCap =
new System.Drawing.Drawing2D.AdjustableArrowCap(3, 3, true);
arrowPen.CustomEndCap = lineCap;
Graphics gfx = Graphics.FromImage(bm);
gfx.DrawLine(arrowPen, pointX, pointY);
gfx.Save();
this.BackgroundImage = bm;