Page 1 of 1

Problem Exporting Charts as Metafiles...

Posted: Thu Jul 18, 2013 1:07 pm
by 16556683
Hi,

I'm having problems exporting Charts as Metafiles. See video below:

http://screencast.com/t/uEkKdiSz2M

I've attached the small problematic code. This will not compile on my system. In other code I get an AV when I set the Enhanced property to FALSE.

Thanks,

Steve

P.S. I'm running Delphi XE4 under Windows 8 64 bit.

Re: Problem Exporting Charts as Metafiles...

Posted: Thu Jul 18, 2013 7:46 pm
by 16556683
I've spent some more time trying to find the problem. In doing so I've come up with another error.

In the attached code a chart is created, set to a specific size and copied to the clipboard as a enhanced metafile. Here is the code:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  tmp:  TEMFExportFormat;
  c: TChart;
begin
  c := TChart.Create(nil);
  c.Width := 1000;  //    <=== Height and width of new chart are not respected!
  c.Height := 500;
  CopyChart(Chart1, c);
  c.Refresh;
  tmp:= TEMFExportFormat.Create;
  try
    tmp.Enhanced := True; //    <== ERROR if set to false
    tmp.Panel := c;
    tmp.Width := c.Width;
    tmp.Height := c.Height;
    Clipboard.Clear;
    tmp.CopyToClipboard;
  finally
    tmp.Free;
    c.Free;
  end;
end;
Similar code has worked with previous versions.

The errors are as follows:

- If tmp.Enhanced is set to False there is an AV
- The Enhanced Metafile which is copies to the clipboard does not have the right weight and width

I'd appreciate your comments, and if there is a bug, which I believe there is, also a fix!

Thanks,

Steve

P.S. The code now compiles on my machine. I needed to add a "vcltee." before a unit.

Re: Problem Exporting Charts as Metafiles...

Posted: Fri Jul 19, 2013 11:55 am
by yeray
Hi Steve,
Steve Maughan wrote:Hi,

I'm having problems exporting Charts as Metafiles. See video below:

http://screencast.com/t/uEkKdiSz2M

I've attached the small problematic code. This will not compile on my system. In other code I get an AV when I set the Enhanced property to FALSE.

Thanks,

Steve

P.S. I'm running Delphi XE4 under Windows 8 64 bit.
Set the Panel before changing the Enhanced property:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  tmp:  TEMFExportFormat;
begin
  tmp:= TEMFExportFormat.Create;
  try
    tmp.Panel := Chart1;
    tmp.Enhanced := False; //    <== ERROR!
    tmp.SaveToFile('Chart1EMF.' + tmp.FileExtension);
  finally
    tmp.Free;
  end;
end;

Re: Problem Exporting Charts as Metafiles...

Posted: Fri Jul 19, 2013 12:00 pm
by yeray
Hi again Steve,
Steve Maughan wrote:I've spent some more time trying to find the problem. In doing so I've come up with another error.

In the attached code a chart is created, set to a specific size and copied to the clipboard as a enhanced metafile. Here is the code:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  tmp:  TEMFExportFormat;
  c: TChart;
begin
  c := TChart.Create(nil);
  c.Width := 1000;  //    <=== Height and width of new chart are not respected!
  c.Height := 500;
  CopyChart(Chart1, c);
  c.Refresh;
  tmp:= TEMFExportFormat.Create;
  try
    tmp.Enhanced := True; //    <== ERROR if set to false
    tmp.Panel := c;
    tmp.Width := c.Width;
    tmp.Height := c.Height;
    Clipboard.Clear;
    tmp.CopyToClipboard;
  finally
    tmp.Free;
    c.Free;
  end;
end;
Similar code has worked with previous versions.

The errors are as follows:

- If tmp.Enhanced is set to False there is an AV
- The Enhanced Metafile which is copies to the clipboard does not have the right weight and width

I'd appreciate your comments, and if there is a bug, which I believe there is, also a fix!

Thanks,

Steve

P.S. The code now compiles on my machine. I needed to add a "vcltee." before a unit.
I see you also set the Enhanced property before setting the Panel in this code, but I can't reproduce the problem with it. Note I had comment out the CopyChart call, since I don't know what it exactly does.

Re: Problem Exporting Charts as Metafiles...

Posted: Fri Jul 19, 2013 1:45 pm
by 16556683
Hi Yeray,

By setting the panel first the AV doesn't occur. Thanks!

The "CopyChart" function simply copies the chart. I think CloneChart does the same. My problem is the size of the image copied to the clipboard. It isn't the size of the chart. In the example given in the code I set the chart size to 1000 x 500. The image which is copied to the clipboard is 641 x 319. This is a bug. In previous versions the image copied was the same as the Chart.

Thanks,

Steve

Re: Problem Exporting Charts as Metafiles...

Posted: Mon Jul 22, 2013 2:40 pm
by yeray
Hi Steve,
Steve Maughan wrote:My problem is the size of the image copied to the clipboard. It isn't the size of the chart. In the example given in the code I set the chart size to 1000 x 500. The image which is copied to the clipboard is 641 x 319. This is a bug. In previous versions the image copied was the same as the Chart.
I see it. I tried the following code and it seems the size you set to the chart isn't respected. I've added it to the wish list to be revised for further releases (TV52016657).

Code: Select all

uses TeeEmfOptions, ClipBrd;

procedure TForm1.Button1Click(Sender: TObject);
var
  tmp:  TEMFExportFormat;
begin
  Chart1.Width:=1000;
  Chart1.Height:=500;
  tmp:= TEMFExportFormat.Create;
  try
    tmp.Panel := Chart1;
    tmp.Enhanced := false;
    Clipboard.Clear;
    tmp.CopyToClipboard;
  finally
    tmp.Free;
  end;
end;

Re: Problem Exporting Charts as Metafiles...

Posted: Mon Jul 22, 2013 8:31 pm
by 16556683
Thanks Yeray,

I think this a breaking change - it certainly is for my application. Previous versions have respected the size. I hope it's an easy fix.

Many thanks,

Steve

Re: Problem Exporting Charts as Metafiles...

Posted: Tue Jul 23, 2013 7:54 am
by yeray
Hi Steve,

I see the same behaviour in v8 and v2012.06. Could you please tell us in what version did you see it working as you expect?

Re: Problem Exporting Charts as Metafiles...

Posted: Tue Jul 23, 2013 5:53 pm
by 16556683
My application has exported chart of the correct size using XE3 and TChart 2012. I think we used Enhanced Matafile not Metafiles but we definitely exported charts with the perfect dimensions.

Thanks,

Steve

Re: Problem Exporting Charts as Metafiles...

Posted: Wed Jul 24, 2013 11:04 am
by yeray
Hi Steve,
Steve Maughan wrote:My application has exported chart of the correct size using XE3 and TChart 2012
Could you please precise what exact TeeChart version were you using? TeeChart Standard v2012 shipped with the IDE, TeeChart Pro 2012.07.121026 PreRelease binary for XE3, TeeChart Pro 2012.07.121105 binary for XE3, TeeChart Pro SourceCode 2012.07.120914, TeeChart Pro SourceCode 2012.07.121026, TeeChart Pro SourceCode 2012.07.121031 or TeeChart Pro SourceCode 2012.07.121105?

Re: Problem Exporting Charts as Metafiles...

Posted: Thu Aug 08, 2013 1:05 pm
by 16556683
Hi Yeray,

Sorry I missed this reply.

I could have sworn previous versions gave a chart of the exact dimensions. However, I cannot find a version which does this. Apologies for saying it did!

So I can only resort to asking it to be added to future versions. It's the only logical behavior.

Thanks,

Steve

Re: Problem Exporting Charts as Metafiles...

Posted: Thu Aug 08, 2013 2:46 pm
by yeray
Hi Steve,
Steve Maughan wrote: I could have sworn previous versions gave a chart of the exact dimensions. However, I cannot find a version which does this. Apologies for saying it did!

So I can only resort to asking it to be added to future versions. It's the only logical behavior.
No problem, don't worry. It's just that, if it worked as desired in a previous version, we could "attack" the issue from a different angle, looking for the changes between working and not working versions.