绘图后保存图片从PictureBox



我有PictureBoxImage,我使用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");

这里缺少什么?

你想要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...");
    }

最新更新