Generally encountered this problem friend is basically in the call Image.Save method, encountered, bitmap similar, then the cause of this problem is what?
Needless to say, apart from the normal parameter errors, permission issues, the rest of the WinForm in the case, is basically the official interpretation of the error:
Bitmap object or an Image object from a file, constructed with the file remaining locked for the object's lifetime. Therefore, you cannot change the image and save it back to produce the same file
This is the official words, then the solution is simple, since this image or when the object locked, can not complete this operation
We can take a detour, copy this object, generate a copy, and then manipulate the copy to solve the problem.
Because in GDI +, therefore, we choose graphic to do this operation:
if (picturebox_sreen.image!= null)
{
Bitmap b=new Bitmap (picturebox_sreen.image.width,picturebox_ Sreen.Image.Height); Create an image file of an ideal size
Graphics g = graphics.fromimage (B);//Instance an object of an artboard, using the artboard g.drawimage of the image above
(picturebox_ Sreen.image, 0, 0);//Draw the target image on the artboard of this image file
b.save (sfd. FileName, System.Drawing.Imaging.ImageFormat.Jpeg);//through this image to save
}
In this way, when saving, there will be no error, where Picturebox_screen is the PictureBox control, SFD is the File Save dialog box is resolved