Einzelnen Beitrag anzeigen

Benutzerbild von softtouch
softtouch

Registriert seit: 13. Feb 2015
Ort: Kerpen
235 Beiträge
 
Delphi 12 Athens
 
#2

AW: FMX Imagelist PNG zufügen

  Alt 18. Feb 2023, 10:38
Vielleicht nicht 100%, aber so in etwa.

Code:
var
  si: TCustomSourceItem;
  d: TCustomDestinationItem;
  layer: TLayer;
  i,w,h:integer;
  st: TMemorystream;
begin
// favicons is the name of the image list
// st is a memorystream holding the image
// imagepath is a stringlist holding the filenames of the images

  favicons.ClearCache;
  favicons.Source.Clear;
  favicons.Destination.Clear;

  st:=TMemoryStream.create;

  for i:=0 to imagepath.count-1 do
  begin
    st.LoadFromFile(imagepath[i]);
    st.position:=0;
    si:=favicons.Source.Add;
    si.Name := 'image'+i.ToString;
    si.MultiResBitmap.LoadItemFromStream(st,1);
    si.MultiResBitmap.TransparentColor := TColorRec.Fuchsia;
    si.MultiResBitmap.SizeKind := TSizeKind.Custom;
    si.MultiResBitmap.Width := 16;
    si.MultiResBitmap.Height := 16;
    w:=si.MultiResBitmap.Bitmaps[1].Width;
    h:=si.MultiResBitmap.Bitmaps[1].Height;
    d:=favicons.Destination.Add;
    Layer := d.Layers.Add;
    Layer.SourceRect.Rect := TRectF.Create(0, 0, W , H);
    Layer.Name := si.name;
// Note: The index of the just added image can be retrieved with d.index here, to set for example the imageindex property in a listview item
  end;

  st.free;

end;
  Mit Zitat antworten Zitat