I know there have been many posts on this topic, and I have looked at them but I am still having problems.
I have a jpeg image which was retrieved from the database and needed to display it in a user control.
In the code below, im trying to save the image into a blank image file and display it in the application.
When I try to save the image back to disk, then the good old highly descriptive "Generic error occurred in GDI+" exception is thrown.
A code snippet is provided below, any help would be appreciated.
thanks!
Jermine
I have a jpeg image which was retrieved from the database and needed to display it in a user control.
In the code below, im trying to save the image into a blank image file and display it in the application.
When I try to save the image back to disk, then the good old highly descriptive "Generic error occurred in GDI+" exception is thrown.
A code snippet is provided below, any help would be appreciated.
thanks!
Jermine
Code:
byte[] imageBinary = GetImage();
System.IO.MemoryStream mstream = new System.IO.MemoryStream ();
mstream.Write (imageBinary, 0, imageBinary.Length);
Bitmap bitmap = new Bitmap (mstream);
Response.ContentType = "image/pjpeg";
bitmap.Save(Server.MapPath("image.jpeg"), System.Drawing.Imaging.ImageFormat.Jpeg);
mstream.Close();
this.Image1.ImageUrl = Server.MapPath("image.jpeg");