Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic GDI+ error when streaming png image to client (Read 2794 times)
AT
YaBB Newbies
*
Offline



Posts: 7
Joined: Dec 21st, 2012
GDI+ error when streaming png image to client
Jan 18th, 2013 at 5:42pm
Print Post  
When generating and streaming a PNG image on a x86 windows 2008 SP2 I encountered the following error: "ExternalException (0x80004005): A generic error occurred in GDI+."

This error occurs after call DiagramView.Diagram.CreateImage() and streaming the resultant image using the PNG format:

var diagramView = BuildDiagram(rootZone, zoneName);
var image = diagramView.Diagram.CreateImage();
var memStream = new MemoryStream();
image.Save(memStream, ImageFormat.Png);
memStream.WriteTo(response.OutputStream);


Here are a couple of useful pieces of debugging information:
* Error does not occur on x64 Windows 7 development machine
* Error does not occur when streaming as JPEG
* Error does not occur when generating image with this alternate CreateImage call: diagramView.Diagram.CreateImage(diagramView.Diagram.Bounds, 100);
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: GDI+ error when streaming png image to client
Reply #1 - Jan 20th, 2013 at 9:58am
Print Post  
Is it a large image? GDI+ can't handle images larger than about 3000 x 3000 pixels, and you might have to split it into multiple parts, and e.g. show them in a table. Also don't forget to call Dispose on processed images.

Quote:
Error does not occur when generating image with this alternate CreateImage call: diagramView.Diagram.CreateImage(diagramView.Diagram.Bounds, 100);


This shouldn't be possible, that code is exactly what the no-arguments method runs. Check if there weren't other differences between the calls, such as in the image size.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint