private void SaveGraphButton_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = "Save graphs as images"; sfd.Filter = "PNG (*.png)|*.png"; sfd.InitialDirectory = DRAMSimPath; if (sfd.ShowDialog() == DialogResult.OK) { string filename = sfd.FileName.Substring(0, sfd.FileName.Length - 4); ResetZoom(); Bitmap bandwidthImage = new Bitmap(gBandwidth.canvas.Width, gBandwidth.canvas.Height); Grapher.SetBitmapBackground(bandwidthImage, Color.White); gBandwidth.canvas.DrawToBitmap(bandwidthImage, gBandwidth.canvas.Bounds); bandwidthImage.Save(filename + "_bandwidth.png", System.Drawing.Imaging.ImageFormat.Png); Bitmap latencyImage = new Bitmap(gLatency.canvas.Width, gLatency.canvas.Height); Grapher.SetBitmapBackground(latencyImage, Color.White); gLatency.canvas.DrawToBitmap(latencyImage, gLatency.canvas.Bounds); latencyImage.Save(filename + "_latency.png", System.Drawing.Imaging.ImageFormat.Png); /* Bitmap histogramImage = gHistogram.GetBitmap(); * histogramImage.Save(filename+"_histogram.png",System.Drawing.Imaging.ImageFormat.Png);*/ Bitmap powerImage = gPower.GetBitmap(); powerImage.Save(filename + "_power.png", System.Drawing.Imaging.ImageFormat.Png); } }
public Bitmap GetBitmap() { //for whatever reason, trying to just call drawtobitmap on the tablelayoutpanel doesn't work Bitmap b = new Bitmap(control.Width, control.Height); Grapher.SetBitmapBackground(b, Color.White); foreach (Control c in t.Controls) { c.DrawToBitmap(b, c.Bounds); // p("Drawing "+c.Name+"("+control.Width+","+control.Height+") "+c.Bounds); } return(b); }