Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to solve this error A generic error occurred in GDI+ in vbnet
Posted
Comments
OriginalGriff 4-Jan-12 8:01am    
We would need to see the relevant code fragment, with some indication of where the error appears.
Use the "Improve question" widget to edit your question and provide better information.

Try a 'generic fix', like Google[^].
 
Share this answer
 
private void Form1_Load(object sender, EventArgs e)
{
string strFile = "C:\\1.jpg";
//Load original image
Image originalImage = Image.FromFile(strFile);
//Create empty bitmap image of original size
Bitmap tempBmp = new Bitmap(originalImage.Width, originalImage.Height);
Graphics g = Graphics.FromImage(tempBmp);
//draw the original image on tempBmp
g.DrawImage(originalImage, 0, 0, originalImage.Width, originalImage.Height);
//
//Do your work here
//
//dispose originalImage and Graphics so the file is now free
g.Dispose();
originalImage.Dispose();
//Save the image file to original location
tempBmp.Save(strFile,System.Drawing.Imaging.ImageFormat.Jpeg);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900