2016-06-05 1 views
0

Je suis en train de tracer des diagrammes de dispersion à partir de Données SQL dans un C# programme. Je voudrais automatiquement enregistrer ces graphiques comme ils peuplent. J'ai le code suivant qui enregistre les fichiers Jpeg, mais quand je les ouvre, ils sont vide. Je suis en train de tracer plusieurs graphiques à la fois.Enregistrement du graphe de dispersion sous forme d'image en C#

Toute aide est appréciée.

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

Je résolu ma question –

Répondre

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);