TGDIPPictureContainer -> TPictureContainer

need to copy on runtime GDIPPictureContainer to TPictureContaine (500+ images so I dont want to create it manually)
I do it like this but I don't get any images displayed. Can you see what I am doing wrong?

  stream := TMemoryStream.Create;
  try
  //copy images from GDIPlist to List
  for i := 0 to data.pcListImages.Items.Count-1 do
    begin
      stream.Clear;
      pic := pc1.Items.Add;
      pic.Name := data.pcListImages.Items.Name;
      pic.Tag := data.pcListImages.Items.Tag;
      pic.DisplayName := data.pcListImages.Items.DisplayName;
      data.pcListImages.Items.Picture.SaveToStream(stream);
      stream.Position := 0;
      pic.Picture.LoadFromStream(stream);
    end;
  finally
   stream.Free;
  end;

somehow the indexes in square brackets were removed from post...

but they are in the code

I cannot see a problem.


This was retested with a GDIPPictureContainer, PictureContainer and HTMLabel on the form with the GDIPPictureContainer containing one image and PictureContainer zero images:

var
 ms: TMemoryStream;
begin
 ms := TMemoryStream.Create;

 GDIPPictureContainer1.Items[0].Picture.SaveToStream(ms);
 ms.Position := 0;

 PictureContainer1.Items.Add;

 PictureContainer1.Items[0].Picture.LoadFromStream(ms);
 PictureContainer1.Items[0].Name := 'TEST';

 HTMLabel1.PictureContainer := PictureContainer1;
 HTMLabel1.HTMLText.Text := 'This is the picturecontainer based image <IMG src="TEST">';
end;

and the added PictureContainer picture is displayed in the HTMLabel.

yes, thank you, I found my mistake.

The problem is that I also clean picture list from dynamically loaded pictures and there I had wrong comparison (using PictureItem tag).