![]() |
FMX Imagelist PNG zufügen
Moin Moin.
Wie aus VCL gewohnt möchte ich eine Ladung PNG's (432 Stück) in eine ImageList schrauben, wobei diese Imagelist in einer ListView dann die Bilder via ImageIndex anzeigen soll. Schön. Ich habe keinen Dunst wie ich die Bilder programmatisch in FMX da reinbekomme. Zu Fuß geht ja, aber bei 432 Stück..... :wall: creehawk |
AW: FMX Imagelist PNG zufügen
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; |
AW: FMX Imagelist PNG zufügen
|
AW: FMX Imagelist PNG zufügen
Prima. vielen Dank, dann wollen wir sehen ....
creehawk |
AW: FMX Imagelist PNG zufügen
Jupp, klappt. Wobei es erstmal um das eigentliche Verständnis geht, ausgehend von der TImageCollection in VCL.
Jetzt hätte ich aber noch eine Frage: in besagter IMageCollection kann ich via GetIndexByName sehr einfach den Index der Grafik in der Collection bekommen. In den Properties zur FMX ImageList finde ich da nichts .... creehawk P.S. Ich muss ein kleines Programm nach FMX portieren, sonst verwende ich FMX nicht. |
AW: FMX Imagelist PNG zufügen
Hallo,
so sollte es funktionieren -
Delphi-Quellcode:
Gruß
var
myBitmap:TCustomBitmapitem; mysize:Tsize; indx:Integer; begin myBitmap:=TCustomBitmapitem.Create(nil); try ImageList1.BitmapItemByName('Image',myBitmap,mysize); indx:=mybitmap.Index; finally myBitmap.Free; end; end; |
AW: FMX Imagelist PNG zufügen
Nee, er gibt nur immer eine 0 zurück.
Aber:
Delphi-Quellcode:
das geht anstandslos. Ha!
Index := MainForm.ImageList.source.Indexof(Bild);
Danke dir trotzdem natürlich. creehawk |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:38 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz