2016-06-05 14 views
0

Ich zeichne einige Streudiagramme von SQL-Daten in einem C# -Programm. Ich möchte automatisch speichern diese Grafiken, wie sie bevölkern. Ich habe den folgenden Code, der die Jpeg-Dateien speichert, aber wenn ich sie öffne, sind sie leer. Ich zeichne mehrere Grafiken gleichzeitig auf.Speichern Streudiagramm als Bild in C#

Jede Hilfe wird geschätzt.

public partial class XYplotForm : Form 
    { 
     public XYplotForm() 
     { 
      InitializeComponent(); 

     } 
     public void Plot(Double[] freq, Double[] amp, Double[] bw, string name) 
     { 
      scatterGraph1.PlotXY(freq, amp); 
      tbName.Text = name; 

      Bitmap image = new Bitmap(scatterGraph1.Width, scatterGraph1.Height); 
      Rectangle target_bounds = default(Rectangle); 
      target_bounds.Width = scatterGraph1.Width; 
      target_bounds.Height = scatterGraph1.Height; 
      target_bounds.X = 0; 
      target_bounds.Y = 0; 
      scatterGraph1.DrawToBitmap(image, target_bounds); 
      string filename = "C:\\Graph\\" + name + ".Jpeg"; 
      image.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg); 



      } 


     } 


    } 
+0

Ich löste meine Frage –

Antwort

0
xyForm = new XYplotForm(); 
     xyForm.Plot(freqLC40, ampMaxLC40, "LC-40 Max Amplitude"); 
     xyForm.Show(); 

     Bitmap image = new Bitmap(xyForm.Width, xyForm.Height); 
     System.Drawing.Rectangle target_bounds = default(System.Drawing.Rectangle); 
     target_bounds.Width = xyForm.Width; 
     target_bounds.Height = xyForm.Height; 
     target_bounds.X = 0; 
     target_bounds.Y = 0; 
     xyForm.DrawToBitmap(image, target_bounds); 
     string filename = "C:\\Graph\\LC40_Max Amplitude.Png"; 
     image.Save(filename, System.Drawing.Imaging.ImageFormat.Png);