c# 保存picturebox图片
的有关信息介绍如下:你要想保存pictureBox1上的图片必须在pictureBox1的paint事件里绘制,然后再调用pictureBox1的DrawToBitmap方法保存在图片里,最后在把图片保存到硬盘上,不过这样太麻烦不如直接绘制在图片上,代码如下两种方法都有 //在pictureBox1的Paint事件里绘制 private void pictureBox1_Paint(object sender, PaintEventArgs e) { e.Graphics.DrawString("Hello World", this.Font, Brushes.Black, new PointF(10, 10)); } private void button1_Click(object sender, EventArgs e) { Bitmap bit = new Bitmap(pictureBox1.Width, pictureBox1.Height); pictureBox1.DrawToBitmap(bit, pictureBox1.ClientRectangle); bit.Save("C:\\Picture1.bmp", System.Drawing.Imaging.ImageFormat.Bmp); bit.Dispose(); } //直接绘制在Bitmap上并保存 private void button2_Click(object sender, EventArgs e) { Bitmap bit = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics g = Graphics.FromImage(bit); g.Clear(Color.White); g.DrawString("Hello World", this.Font, Brushes.Black, new PointF(10, 10)); g.Dispose(); bit.Save("C:\\Picture2.bmp", System.Drawing.Imaging.ImageFormat.Bmp); bit.Dispose(); }