我有这个代码在“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");