Last post May 02, 2013 09:59 AM by Rodrogue
Jul 12, 2011 02:28 PM|ahmd01|LINK
I have a weird thing going on. I'm trying to generate an image in the C# code like this:
Response.ContentType = "image/png";
bmp.Save(Response.OutputStream, ImageFormat.Png); //Exception happens here
One one computer with the same exact installation of VS2010 and ,net framework 4 it works fine, but on another one I get an exception with the following message: "A generic error occurred in GDI+."
How can I fix it?
Aug 15, 2011 10:09 PMemail@example.com|LINK
You can't save a PNG image to a non-seekable stream. You have to pipe it through a MemoryStream first. Take a look at the links in my signature, they're must-reads for you.
Aug 15, 2011 11:02 PM|ahmd01|LINK
Sorry, I don't know ASP NET well enough to know how to do it. Can you post a code sample or a direct link to what you're talking about?
Aug 15, 2011 11:32 PMfirstname.lastname@example.org|LINK
Ok, then download this library and add it to your project.
Then use this code to save the 'bmp' safely to the OutputStream.
ImageBuilder.Current.Build(bmp, Response.OutputStream, new ResizeSettings("format=png");
Also, could you paste the rest of your code dealing with the 'bmp'? I suspect you have a leak that will cause the server to crash, and I'd like to help you avoid it.
May 02, 2013 09:59 AM|Rodrogue|LINK
I know this is an old post, but I wanted to add this information as well, in case someone like me runs across this issue in the future..
I wasn't able to say .PNG images and it because the IIS App Pool Acount didn't have access to this, key.
Which is required when you use png graphics.