Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 Generic GDI+ error when using PNG format
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

King Kong Keuter

13 Posts

Posted - 27 Mar 2004 :  11:38:43  Show Profile  Reply with Quote
When saving the chart to the Response.OutputStream a 'Generic GDI+ error' occurs if you use the PNG format.

A simple workaround for this problem is saving the image to a memorystream and then writing the memorystream to the Response.OutputStream.

So this is not really a bug in the charting library but when the PNG format is specified (via BufferedImage( chartView, System.Drawing.Imaging.ImageFormat.Png )) it would be a nice feature that the SaveImage method of a BufferedImage saves the image to a memorystream internally automatically when the PNG format is set so nobody will run into this problem again when using this charting library.

.Netters do it better... ;-)

quinncurtis

1164 Posts

Posted - 27 Mar 2004 :  13:12:21  Show Profile  Reply with Quote
Thanks for the information. That error is a well discussed problem with trying to stream a PNG format directly to the Page.Response stream in .Net program. Just google ".Net PNG OutputStream" for a list of references.

For those interested in the code for an actual workaround, the following code can be used to replace the response code in the Page_Load methods of our ASP.Net examples


// Put user code to initialize the page here
ChartView chartVu = GetInitializeChart(keystring, imagewidth, imageheight);
if (chartVu != null)
{
MemoryStream memstream = new MemoryStream();
BufferedImage chartimage = new BufferedImage(chartVu, ImageFormat.Png);
Response.ContentType = "image/png";
chartimage.SaveImage(memstream);
memstream.WriteTo(Response.OutputStream) ;
}


We will take your advise and make this automatic for PNG files internal to our BufferedImage class.


Go to Top of Page

King Kong Keuter

13 Posts

Posted - 30 Mar 2004 :  01:40:03  Show Profile  Reply with Quote
Great, I'm looking forward to the new version so I can scrap those extra two lines of code... Cause I'm a clean code freak!

.Netters do it better... ;-)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07