Note that there are some explanatory texts on larger screens.

plurals
  1. POA generic error occurred in GDI+. when trying to save picturebox image on the disk
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/8295766/gdi-generic-error">GDI+ Generic Error</a> </p> </blockquote> <p>i am writing a db application and use "sdf" file as a database. i save the image on the DB by converting it to a byte array by this code :</p> <pre><code>byte[] ReadFile(string sPath) { //Initialize byte array with a null value initially. byte[] data = null; //Use FileInfo object to get file size. FileInfo fInfo = new FileInfo(sPath); long numBytes = fInfo.Length; //Open FileStream to read file FileStream fStream = new FileStream(sPath, FileMode.Open, FileAccess.Read); //Use BinaryReader to read file stream into byte array. BinaryReader br = new BinaryReader(fStream); //When you use BinaryReader, you need to supply number of bytes to read from file. //In this case we want to read entire file. So supplying total number of bytes. data = br.ReadBytes((int)numBytes); return data; } </code></pre> <p>and insert it into database.</p> <p>i retrive the image via this code:</p> <pre><code>public static Image CreateImage(byte[] imageData) { Image image=null; if(imageData !=null) { using (MemoryStream inStream = new MemoryStream()) { inStream.Write(imageData, 0, imageData.Length); image = Bitmap.FromStream(inStream); } } return image; } </code></pre> <p>and assign the pictureBox Image to CreateImage return value.</p> <p>until here every thing is fine but when i want to store pictureBox image on the disk</p> <pre><code> Bpicture.Image.Save(@"pic1.jpeg", ImageFormat.Jpeg); </code></pre> <p>this error occurs :</p> <pre><code>An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll Additional information: A generic error occurred in GDI+. </code></pre> <p>also this error doesn't happen when i load image from disk instead of database</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload