Problem Exporting Charts as Metafiles...

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Steve Maughan
Newbie
Newbie
Posts: 48
Joined: Tue Aug 03, 2010 12:00 am

Problem Exporting Charts as Metafiles...

Post by Steve Maughan » Thu Jul 18, 2013 1:07 pm

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.
Attachments
TChart Metafiles.zip
(5.49 KiB) Downloaded 760 times

Steve Maughan
Newbie
Newbie
Posts: 48
Joined: Tue Aug 03, 2010 12:00 am

Re: Problem Exporting Charts as Metafiles...

Post by Steve Maughan » Thu Jul 18, 2013 7:46 pm

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.
Attachments
TChart Metafiles 2.zip
(5.5 KiB) Downloaded 695 times

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Problem Exporting Charts as Metafiles...

Post by Yeray » Fri Jul 19, 2013 11:55 am

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Problem Exporting Charts as Metafiles...

Post by Yeray » Fri Jul 19, 2013 12:00 pm

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Steve Maughan
Newbie
Newbie
Posts: 48
Joined: Tue Aug 03, 2010 12:00 am

Re: Problem Exporting Charts as Metafiles...

Post by Steve Maughan » Fri Jul 19, 2013 1:45 pm

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

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Problem Exporting Charts as Metafiles...

Post by Yeray » Mon Jul 22, 2013 2:40 pm

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Steve Maughan
Newbie
Newbie
Posts: 48
Joined: Tue Aug 03, 2010 12:00 am

Re: Problem Exporting Charts as Metafiles...

Post by Steve Maughan » Mon Jul 22, 2013 8:31 pm

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

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Problem Exporting Charts as Metafiles...

Post by Yeray » Tue Jul 23, 2013 7:54 am

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?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Steve Maughan
Newbie
Newbie
Posts: 48
Joined: Tue Aug 03, 2010 12:00 am

Re: Problem Exporting Charts as Metafiles...

Post by Steve Maughan » Tue Jul 23, 2013 5:53 pm

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

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Problem Exporting Charts as Metafiles...

Post by Yeray » Wed Jul 24, 2013 11:04 am

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?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Steve Maughan
Newbie
Newbie
Posts: 48
Joined: Tue Aug 03, 2010 12:00 am

Re: Problem Exporting Charts as Metafiles...

Post by Steve Maughan » Thu Aug 08, 2013 1:05 pm

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

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Problem Exporting Charts as Metafiles...

Post by Yeray » Thu Aug 08, 2013 2:46 pm

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply