我有这个代码抛出异常“pictureBox2.Image.Save(st +”patch1.jpg“);”我认为没有什么保存在pictureBox2.Image上,但我已经创建了图形g。 如何保存pictureBox2.Image的图像?保存从图片框中的图像,图像是由图形对象绘制
Bitmap sourceBitmap = new Bitmap(pictureBox1.Image, pictureBox1.Width, pictureBox1.Height);
Graphics g = pictureBox2.CreateGraphics();
g.DrawImage(sourceBitmap, new Rectangle(0, 0, pictureBox2.Width, pictureBox2.Height),rectCropArea, GraphicsUnit.Pixel);
sourceBitmap.Dispose();
g.Dispose();
path = Directory.GetCurrentDirectory();
//MessageBox.Show(path);
string st = path + "/Debug";
MessageBox.Show(st);
pictureBox2.Image.Save(st + "patch1.jpg");
我可能会在OP后3年,但感谢您给我一个需要几个小时才能找到的答案。 – James