Annotation Cut Off When Saving to PNG Format

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Walt
Newbie
Newbie
Posts: 35
Joined: Wed Aug 17, 2005 4:00 am
Location: San Jose, CA
Contact:

Annotation Cut Off When Saving to PNG Format

Post by Walt » Fri Jun 01, 2007 1:06 am

I have a web-service-like application (no GUI) that creates a WinForms TeeChart.NET v2 chart (latest build), populates it with data -- including an annotation in the bottom left corner, then saves the chart to PNG format.

The problem is that the annotation is positioned too low and it is cut off with only the top part visible. This bug seems to have started occurring within the last few builds of TeeChart.NET version 2, because my code didn't change (for this chart). If I save to TEN format instead, then open the TEN file in another program, everything looks ok, and I can manually export to PNG using the chart editor GUI without any problem.

The really odd thing is the workaround that I found. I just need to export to PNG twice in a row, and then it works ok. How weird is that?!

Code: Select all

teeChart.Export.Image.PNG.Width = 780;
teeChart.Export.Image.PNG.Height = 500;
teeChart.Export.Image.PNG.Save(fileName);
teeChart.Export.Image.PNG.Save(fileName);  // Save twice to fix annotation bug
Please fix this bug and please be on the lookout for similar bugs. I am very curious about the cause of this bug.

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Fri Jun 01, 2007 9:05 am

Hi Walt

We couldn't reproduce the issue here, could you please send us a simple example project we can run "as-is" to reproduce the issue here?
You can post your files either at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup or at our upload page

Please let us know when you have posted the sample project.

Thanks in advance
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

Walt
Newbie
Newbie
Posts: 35
Joined: Wed Aug 17, 2005 4:00 am
Location: San Jose, CA
Contact:

Post by Walt » Thu Jun 07, 2007 1:24 am

9348258 wrote:We couldn't reproduce the issue here, could you please send us a simple example project we can run "as-is" to reproduce the issue here?
I wish you guys had tried harder, because it really wasn't that hard to duplicate. Create a new C# WinForms app named "TeeChartAnnotationExportBug" and replace Form1.cs with the following code:

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Steema.TeeChart;
using Steema.TeeChart.Tools;

namespace TeeChartAnnotationExportBug
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
      TChart chart = new TChart();
      chart.Header.Text = "TeeChart v" + typeof(TChart).Assembly.GetName().Version + " Test at " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();

      Annotation annotation = new Annotation();
      annotation.Text = "Multi-line\ntext\ngoes here";
      annotation.Position = AnnotationPositions.LeftBottom;
      //annotation.Shape.Brush.Transparency = 50;
      //annotation.Shape.Pen.Visible = false;
      //annotation.Shape.Shadow.Visible = false;
      annotation.Active = true;
      chart.Tools.Add( annotation );

      chart.Export.Image.PNG.Width  = 780;
      chart.Export.Image.PNG.Height = 500;
      chart.Export.Image.PNG.Save("Chart_Export_1.png");
      chart.Export.Image.PNG.Save("Chart_Export_2.png");

      pictureBox1.Image = new System.Drawing.Bitmap("Chart_Export_1.png");
      pictureBox2.Image = new System.Drawing.Bitmap("Chart_Export_2.png");
    }
  }
}
And replace Form1.designer.cs with the following code:

Code: Select all

namespace TeeChartAnnotationExportBug
{
  partial class Form1
  {
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected override void Dispose(bool disposing)
    {
      if (disposing && (components != null))
      {
        components.Dispose();
      }
      base.Dispose(disposing);
    }

    #region Windows Form Designer generated code

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
      this.pictureBox1 = new System.Windows.Forms.PictureBox();
      this.pictureBox2 = new System.Windows.Forms.PictureBox();
      ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
      this.SuspendLayout();
      // 
      // pictureBox1
      // 
      this.pictureBox1.Location = new System.Drawing.Point(13, 13);
      this.pictureBox1.Name = "pictureBox1";
      this.pictureBox1.Size = new System.Drawing.Size(780, 500);
      this.pictureBox1.TabIndex = 0;
      this.pictureBox1.TabStop = false;
      // 
      // pictureBox2
      // 
      this.pictureBox2.Location = new System.Drawing.Point(12, 519);
      this.pictureBox2.Name = "pictureBox2";
      this.pictureBox2.Size = new System.Drawing.Size(780, 500);
      this.pictureBox2.TabIndex = 0;
      this.pictureBox2.TabStop = false;
      // 
      // Form1
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.AutoScroll = true;
      this.ClientSize = new System.Drawing.Size(873, 737);
      this.Controls.Add(this.pictureBox2);
      this.Controls.Add(this.pictureBox1);
      this.Name = "Form1";
      this.Text = "Form1";
      this.Load += new System.EventHandler(this.Form1_Load);
      ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
      this.ResumeLayout(false);

    }

    #endregion

    private System.Windows.Forms.PictureBox pictureBox1;
    private System.Windows.Forms.PictureBox pictureBox2;

  }
}

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Thu Jun 07, 2007 8:32 am

Hi Walt

Thanks for letting us know, I could reproduce the issue here and this seems to be a bug. I've added it (TF02012242) to our defect list to be fixed for future releases to version 2. It works fine with version 3.
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

Post Reply