MouseTester.MousePlot.Export C# (CSharp) Method

Export() public static method

public static Export ( OxyPlot.PlotModel model, string fileName, int width, int height, Brush background = null ) : void
model OxyPlot.PlotModel
fileName string
width int
height int
background System.Drawing.Brush
return void
        public static void Export(PlotModel model, string fileName, int width, int height, Brush background = null)
        {
            using (var bm = new Bitmap(width, height))
            {
                using (Graphics g = Graphics.FromImage(bm))
                {
                    if (background != null)
                        g.FillRectangle(background, 0, 0, width, height);

                    var rc = new GraphicsRenderContext { RendersToScreen = false };
                    rc.SetGraphicsTarget(g);
                    model.Update();
                    model.Render(rc, width, height);
                    bm.Save(fileName, ImageFormat.Png);
                }
            }
        }

Usage Example

Esempio n. 1
0
        private void buttonSavePNG_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter      = "PNG Files (*.png)|*.png";
            saveFileDialog1.FilterIndex = 1;
            if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                MousePlot.Export(this.plot1.Model, saveFileDialog1.FileName, 800, 600);
            }
        }
All Usage Examples Of MouseTester.MousePlot::Export