Last post Dec 13, 2010 08:16 AM by lionnnn
Dec 13, 2010 08:16 AM|lionnnn|LINK
Hello, I am drawing a bar graph at work. The diagrams must be storeable on a local drive. The graph is drawn on a page and this page is then displayed on my main page. When saving the image by right clicking, the page was saved, not the image, regardless
what I did. Thanks to google and other resources, and of course the ppl that wrote the guides, I did this:
Bitmap bmp = new Bitmap(TmpImage.ms);
Response.Buffer = true;
Response.ContentType = "image/Jpeg";
catch (Exception ex)
l_exception.Visible = true;
l_exception.Text = ex.Message.ToString();
The tiny tmpimage class, that stores the diagram temporarily, looks like this:
public class TmpImage
public static System.IO.MemoryStream ms = new System.IO.MemoryStream();
On the page where the graph is drawn, I save the image with:
bmp is a drawing.graphics.bitmap object.
When the graph is exported, the height of the bars change. Nothing else, the gridlines, that are also drawn dynamically, as well as the x-axis, remain the same. E.G. when the value of bar is 1600, both browsers I use, IE and FF, show it correctly, i.e.
the bar ends where the 1600 gridline is. When exported to a jpeg, the "same" bar is lower than the gridline.
I hope somebody could help me because searching with google ("gdi+ asp.net export graph" for example) did not solve the problem.
gdi+ memory bitmap sclaing drawimage resizing