Hi,
i understand that in the WPF version we cannot export the chart to metafile.
we had some problems at the past with other formats(most of them were related to the aspect of the picture).
which options i have in WPF teechart and which one is the most close to metafile?
p.s,
it should be a type that can be shown later on on a picturebox.
WPF export chart to Metafile
Re: WPF export chart to Metafile
Hello MVuser2,
My only suggestion to work with metafiles in wpf is export as a bitmap as explain in this link to achieve work with a metafile.
I hope will helps.
Thanks,
My only suggestion to work with metafiles in wpf is export as a bitmap as explain in this link to achieve work with a metafile.
I hope will helps.
Thanks,
Best Regards,
Sandra Pazos / 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 |
Re: WPF export chart to Metafile
Hi,
the problem persist.
with WPF bitmap(and other image formats) there is Pixelization of the picture. it doesn't matter that afterwards i'm converting it to a metafile, because it already Pixelizated.
the problem persist.
with WPF bitmap(and other image formats) there is Pixelization of the picture. it doesn't matter that afterwards i'm converting it to a metafile, because it already Pixelizated.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: WPF export chart to Metafile
Hi MVUser6,
I'm using the code snippet below which produces the attached bitmap and copies it in metafile format in the clipboard. I don't think any of the resultant images suffers from aliasing. Could you please give us more detailed information about the problem you are experiencing and modify the code below so that we can reproduce the problem here?
Thanks in advance.
I'm using the code snippet below which produces the attached bitmap and copies it in metafile format in the clipboard. I don't think any of the resultant images suffers from aliasing. Could you please give us more detailed information about the problem you are experiencing and modify the code below so that we can reproduce the problem here?
Code: Select all
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Series.Add(new Steema.TeeChart.WPF.Styles.Line()).FillSampleValues();
string fileName = @"c:\temp\wpf.bmp";
tChart1.Export.Image.Bitmap.Width = 800;
tChart1.Export.Image.Bitmap.Height = 600;
tChart1.Export.Image.Bitmap.Save(fileName);
System.Drawing.Bitmap gdiBitmap = null;
System.IO.MemoryStream metafileStream = null;
try
{
gdiBitmap = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromFile(fileName);
metafileStream = MakeMetafileStream(gdiBitmap);
var dataObj = new DataObject();
dataObj.SetData(DataFormats.Bitmap, gdiBitmap);
dataObj.SetData(DataFormats.EnhancedMetafile, metafileStream);
Clipboard.SetDataObject(dataObj, true);
}
catch
{ }
finally
{
if (gdiBitmap != null)
{ gdiBitmap.Dispose(); }
if (metafileStream != null)
{ metafileStream.Dispose(); }
}
}
private static System.IO.MemoryStream MakeMetafileStream(System.Drawing.Bitmap image)
{
System.Drawing.Graphics graphics = null;
System.Drawing.Imaging.Metafile metafile = null;
var stream = new System.IO.MemoryStream();
try
{
using (graphics = System.Drawing.Graphics.FromImage(image))
{
var hdc = graphics.GetHdc();
metafile = new System.Drawing.Imaging.Metafile(stream, hdc);
graphics.ReleaseHdc(hdc);
}
using (graphics = System.Drawing.Graphics.FromImage(metafile))
{ graphics.DrawImage(image, 0, 0); }
}
finally
{
if (graphics != null)
{ graphics.Dispose(); }
if (metafile != null)
{ metafile.Dispose(); }
}
return stream;
}
}
- Attachments
-
- wpf.zip
- (73.68 KiB) Downloaded 470 times
Best Regards,
Narcís Calvet / 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 |