Support for transparent series in exports

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
mpv
Newbie
Newbie
Posts: 6
Joined: Thu Sep 24, 2009 12:00 am

Support for transparent series in exports

Post by mpv » Tue May 25, 2010 7:54 am

Hi,

I have read some conflicting posts on the status of exporting transparant series in TeeChart.
In my experience, only bmp export works OK now. As this is not a very useful format, I was hoping that png would work as well, and some messages in your forum state that it works for png exports (in 8.03 to be specific). In my experience, it does however NOT work in 8.06 and 8.07
I worked around the problem by exporting to bmp and then using the built in png support in Delphi 2009 to convert to png, but this should not be necessary.

Any ideas ?

Regards, Matt

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

Re: Support for transparent series in exports

Post by Yeray » Tue May 25, 2010 4:20 pm

Hi Matt,

This can be done in a similar way than the descibed here. For PNG:

Code: Select all

uses Series, TeePNG, TeeBMPOptions;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i:=0 to 2 do
    with Chart1.AddSeries(TAreaSeries.Create(self)) as TAreaSeries do
    begin
      FillSampleValues();
      MultiArea:=maStacked;
      Transparency:=50;
      AreaLinesPen.Visible:=false;
    end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  tmpPNG: TPNGExportFormat;
  MetaCanvas: TMetafileCanvas;
  Bitmap: TBMPExportFormat;
begin
  tmpPNG := TPNGExportFormat.Create;
  tmpPNG.Panel:=Chart1;

  try
    Bitmap:= TBMPExportFormat.Create;
    Bitmap.Panel:=Chart1;

    try
      tmpPNG.Height := Bitmap.Height;
      tmpPNG.Width  := Bitmap.Width;
      tmpPNG.Bitmap.Canvas.Draw(0,0,Bitmap.Bitmap(TBMPOptions.Create(self)));
      tmpPNG.SaveToFile('C:\tmp\test.png');
    finally
      Bitmap.Free;
    end;
  finally
    tmpPNG.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

mpv
Newbie
Newbie
Posts: 6
Joined: Thu Sep 24, 2009 12:00 am

Re: Support for transparent series in exports

Post by mpv » Wed May 26, 2010 10:07 am

Thanks Yeray,

That works fine! (after losing the (TBMPOptions.Create(self)) part, no problem)
This allows me to use older versions of Delphi as well, as I still use Delphi 6 for our main project.
Also saves handling another temporary file.

Regards, Matt

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

Re: Support for transparent series in exports

Post by Yeray » Wed May 26, 2010 1:09 pm

Hi Matt,

I'm glad to head that!
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