Note that there are some explanatory texts on larger screens.

plurals
  1. POGeneric GDI+ Error on image.save
    text
    copied!<p>I've been fighting this for over an hour. I have read this error is generally because the MemoryStream gets closed before the bitmap gets disposed, but in here I'm not disposing of anything. Any help would be appretiated. </p> <pre><code> public Image GetImageFromBytes(byte[] imageBytes) { var ms = new MemoryStream(imageBytes); return Image.FromStream(ms); } public void ExportImage(byte[] imageBytes, String fileName) { var image = GetImageFromBytes(imageBytes); // var resizedImg = GeneralHelper.ResizeImage(image,ImageWidth, ImageHeight) ; // OverlayContactDetails(resizedImg); var path = Path.GetDirectoryName(fileName); if (!Directory.Exists(path)) Directory.CreateDirectory(path); image.Save(fileName, ImageFormat.Jpeg); } </code></pre> <p>The exception is thrown while .Save()-ing (as the title suggests). Below is the stack trace</p> <pre><code> at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) at System.Drawing.Image.Save(String filename, ImageFormat format) at AdCreator.ImageExport.ExportImage(Byte[] imageBytes, String fileName) in c:\Users\Paavum Ex Machina\Documents\Visual Studio 2012\Projects\AdCreator\AdCreator\ImageExport.cs:line 70 at AdCreator.ExportController.ExportImage(Byte[] image, String filePath, String agentText) in c:\Users\Paavum Ex Machina\Documents\Visual Studio 2012\Projects\AdCreator\AdCreator\ExportController.cs:line 69 at AdCreator.ExportController.Export(String outputFilename) in c:\Users\Paavum Ex Machina\Documents\Visual Studio 2012\Projects\AdCreator\AdCreator\ExportController.cs:line 44 at AdCreator.Controller.ExportAds(Ad[] ads, String[] templates, String outputFileName) in c:\Users\Paavum Ex Machina\Documents\Visual Studio 2012\Projects\AdCreator\AdCreator\Controller.cs:line 104 at AdCreator.Create.&lt;&gt;c__DisplayClass3.&lt;button2_Click&gt;b__1() in c:\Users\Paavum Ex Machina\Documents\Visual Studio 2012\Projects\AdCreator\AdCreator\Create.cs:line 173 at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.Tasks.Task.Execute() </code></pre>
 

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