我有PictureBox
Image
,我使用Paint
事件在其上绘制一条线,但是当我保存图像时,我得到的图像没有绘制线条
private void PicBox_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawLine(pen, end, start);
e.Graphics.Flush();
e.Graphics.Save();
}
//and I save it like this
picBox.Image.Save("directory");
这里缺少什么?
答案 0 :(得分:2)
您需要DrawToBitmap()方法:
private void button1_Click(object sender, EventArgs e)
{
Bitmap bmp = new Bitmap(picBox.ClientSize.Width, picBox.ClientSize.Height);
picBox.DrawToBitmap(bmp, picBox.ClientRectangle);
bmp.Save("...fileName Here...");
}