Page 1 of 1

Support for transparent series in exports

Posted: Tue May 25, 2010 7:54 am
by 10554308
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

Re: Support for transparent series in exports

Posted: Tue May 25, 2010 4:20 pm
by yeray
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;

Re: Support for transparent series in exports

Posted: Wed May 26, 2010 10:07 am
by 10554308
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

Re: Support for transparent series in exports

Posted: Wed May 26, 2010 1:09 pm
by yeray
Hi Matt,

I'm glad to head that!