Saving chart as metafile

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
UserLS
Advanced
Posts: 247
Joined: Wed May 23, 2007 12:00 am

Saving chart as metafile

Post by UserLS » Tue Jan 27, 2009 9:07 am

I finally can demonstrate my problem! Here is the code. When you run it a form will pop up. Just close it. 3 different metafiles will be saved on the c: drive. Compare them.

Code: Select all

        private void button_Click(object sender, EventArgs e)
        {
            var chart = new TChart();
            var pie = new Pie();
            chart.Series.Add(pie);
            pie.BevelPercent = 25;
            pie.Brush.Color = Color.FromArgb(178, 29, 123, 99);
            pie.Color = Color.FromArgb(68, 102, 163);
            pie.EdgeStyle = Steema.TeeChart.Drawing.EdgeStyles.Curved;
            pie.LabelMember = "Labels";
            pie.Marks.ArrowLength = 21;
            pie.Marks.Bevel.ColorOne = Color.FromArgb(255, 224, 192);
            pie.Marks.Bevel.ColorTwo = Color.FromArgb(255, 128, 0);
            pie.Marks.Bevel.Inner = Steema.TeeChart.Drawing.BevelStyles.Raised;
            pie.Marks.Bevel.Outer = Steema.TeeChart.Drawing.BevelStyles.Lowered;
            pie.Marks.Bevel.Width = 2;
            pie.Marks.Callout.ArrowHead = ArrowHeadStyles.Solid;
            pie.Marks.Callout.ArrowHeadSize = 10;
            pie.Marks.Callout.Brush.Color = Color.Black;
            pie.Marks.Callout.Distance = 1;
            pie.Marks.Callout.Draw3D = false;
            pie.Marks.Callout.Length = 21;
            pie.Marks.Callout.Style = PointerStyles.Rectangle;
            pie.Marks.Callout.Visible = false;
            pie.Marks.Shadow.Height = 3;
            pie.Marks.Shadow.Smooth = true;
            pie.Marks.Shadow.Width = 3;
            pie.MarksPie.LegSize = 0;
            pie.MarksPie.VertCenter = false;
            pie.Title = "pie";
            pie.Transparency = 30;

            pie.FillSampleValues(10);

            var FImage = new PictureBox();
            FImage.SizeMode = PictureBoxSizeMode.StretchImage;

            FImage.Height = 300;
            FImage.Width = 640;

            chart.Height = FImage.Height;
            chart.Width = FImage.Width;
            FImage.Image = chart.Chart.Metafile(new MemoryStream(), chart.Chart, chart.Width, chart.Height, EmfType.EmfPlusOnly);
            FImage.Image.Save(@"c:\image before chart is shown.emf");

            using (var form = new Form())
            {
                form.Height = FImage.Height;
                form.Width = FImage.Width;
                form.Controls.Add(chart);
                chart.Dock = DockStyle.Fill;
                form.ShowDialog();
                form.Controls.Remove(chart);
            }
            FImage.Image = chart.Chart.Metafile(new MemoryStream(), chart.Chart, chart.Width, chart.Height, EmfType.EmfPlusOnly);
            FImage.Image.Save(@"c:\image after chart was shown.emf");

            chart.Height = FImage.Height;
            chart.Width = FImage.Width;
            FImage.Image = chart.Chart.Metafile(new MemoryStream(), chart.Chart, chart.Width, chart.Height, EmfType.EmfPlusOnly);
            FImage.Image.Save(@"c:\image after chart was shown and resized afterwards.emf");
        }
In our application we are trying to place image (which would be the first one) in a PDF file and the quality is awful! Now I know why. Unfortunately, there is no way I can show it before saving into emf. What should I do?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Jan 27, 2009 12:09 pm

Hi UserLS,

Thanks for the example code. We could reproduce the issue here and added it to the wish-list (TF02013790) to be investigated and see if there are improvement possibilities on this field.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply