export image size regenerates plot

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
MattG
Newbie
Newbie
Posts: 23
Joined: Thu Jun 27, 2013 12:00 am

export image size regenerates plot

Post by MattG » Thu Jan 16, 2014 10:56 pm

I've been using Tchart->Export->Image->PNG->Width and Height to control the size of exported images. When these are different than the displayed plot size, the exporter regenerates the plot, changing the number of gridlines, etc.

Is there a way to specify an export size that results in resampling the original plot instead, i.e., just changing the export resolution without changing the contents of the plot?
Matt Garrett
CRTech
Boulder, Colorado, USA

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: export image size regenerates plot

Post by Christopher » Fri Jan 17, 2014 11:31 am

Hello,
MattG wrote:Is there a way to specify an export size that results in resampling the original plot instead, i.e., just changing the export resolution without changing the contents of the plot?
Maybe the easiest way to do this would be to export to a Bitmap and then resize, e.g.

Code: Select all

    private void button1_Click(object sender, EventArgs e)
    {
      Bitmap bmp = ResizeImage(tChart1.Bitmap, new Size(1200, 900));
      bmp.Save(@"C:\tmp\MyPNG.png", System.Drawing.Imaging.ImageFormat.Png); 
    }

    public Bitmap ResizeImage(Bitmap imgToResize, Size size)
    {
      Bitmap b = new Bitmap(size.Width, size.Height);
      using (Graphics g = Graphics.FromImage((Image)b))
      {
        g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default;  //change this if necessary
        g.DrawImage(imgToResize, 0, 0, size.Width, size.Height);
      }
      return b;
    }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply