Page 1 of 1

export image size regenerates plot

Posted: Thu Jan 16, 2014 10:56 pm
by 15666411
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?

Re: export image size regenerates plot

Posted: Fri Jan 17, 2014 11:31 am
by Christopher
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;
    }