SaveToStream and Transparency

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
mendelo
Newbie
Newbie
Posts: 11
Joined: Wed Sep 26, 2007 12:00 am

SaveToStream and Transparency

Post by mendelo » Sun Feb 17, 2008 1:55 am

I can add a TTreeNode Shape
TTreeNodeShape.Image.Assign(SomeBitmap);
TTreeNodeShape.Image.Transparent:= true;
TTreeNodeShape.ImageAlignment:= iaCenter;

All is good , the image shows the background.
However if I

SaveTreeToStream(MyTree,strm)

or

SaveTreeToFile(MyTree,'C:\mytree')

and then reload the file or load it into a different TTree, the images loses the transparency and I see a white background around the images.

Any ideas?

tom
Advanced
Posts: 211
Joined: Mon Dec 01, 2003 5:00 am
Contact:

Post by tom » Wed Feb 20, 2008 12:58 am

Mmm, this looks like a bug. The only way to solve this issue at the moment is to set the transparent property back to true after loading the tree.

e.g. you could iterate the tree and set the transparent property of all nodes which have an image assigned to transparent = true;

as in :

Code: Select all

Procedure TForm2.SetTransparentToTrue(Sender:TTreeNodeShape);
begin
  if Assigned(sender.Image) and (Sender.ImageAlignment = iaCenter) then
    Sender.Image.Transparent := True;
end;


procedure TForm2.LoadTreeStreamClick(Sender: TObject);
var s: TFileStream;
begin
  Tree1.Clear;
  s := TFileStream.Create('c:\test.tree', fmOpenRead);
  try
    s.Position := 0;
    LoadTreeFromStream(TCustomTree(Tree1), s);
    Tree1.Roots.ForEach(SetTransparentToTrue);
    Tree1.Invalidate;
  finally
    FreeAndNil(s);
  end;
  Tree1.Color := clGreen;
end;

Post Reply