Hmmm… I’m working on an HTTP handler that is returning an image as its end result. The image generation works fine and a generic routine returns a Bitmap image as a result. Finally I write out the image like this:

 

Bitmap bmp = wwWebUtils.CornerImage(backcolor, color, c, Radius, Height, Width);

 

// *** Works:

//bmp.Save(@"c:\projects2005\wwStore\corner.png", ImageFormat.Png);

       

// *** Doesn’t work

Response.ContentType = "image/png";

bmp.Save(Response.OutputStream,ImageFormat.Png);

 

This fails with a generic exception on the page:

 

System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.

 

If I save the image as a Jpg file (ImageFormat.Jpeg) all works fine. It appears there’s some problem with the PNG image streaming.

 

Anybody seen this before? Why would there be a problem streaming a PNG file? The output seems OK – I can write the PNG file to disk no problem, so it looks like the data in the image file is fine.

 

I suppose I can grab the image as bytes and write out the raw binary string, but it seems odd that this shouldn’t work.