我已经编写了这段代码,但它会引发一般错误
“你调用的对象是空的。”
我相信这是因为我试图在pictureBox.Image
没有实际设置图像的情况下保存。如何保存 中的图像pictureBox
?
// Left Arm Rear
bmp = new Bitmap(4, 12);
g3 = Graphics.FromImage(bmp);
g3.DrawImageUnscaled(pictureBoxSkin.Image, -52, -20, bmp.Width, bmp.Height);
g2 = pictureBoxLabel.CreateGraphics();
bmp.RotateFlip(RotateFlipType.RotateNoneFlipX);
g2.DrawImageUnscaled(bmp, 28, 20, bmp.Width, bmp.Height);
// Back
bmp = new Bitmap(8, 12);
g3 = Graphics.FromImage(bmp);
g3.DrawImageUnscaled(pictureBoxSkin.Image, -32, -20, bmp.Width, bmp.Height);
g2 = pictureBoxLabel.CreateGraphics();
bmp.RotateFlip(RotateFlipType.RotateNoneFlipX);
g2.DrawImageUnscaled(bmp, 32, 20, bmp.Width, bmp.Height);
pictureBoxLabel.Image.Save(openFileDialog1.InitialDirectory + Path.GetFileNameWithoutExtension(openFileDialog1.FileName) + "_label.Png");