[教学] Firemonkey TImageList 加入原寸图片

时间:2023-03-09 04:00:48
[教学] Firemonkey TImageList 加入原寸图片

下面示范 Firemonkey TImageList 加入一张原始尺寸图片的方法:

[教学] Firemonkey TImageList 加入原寸图片

使用代码加图

if Assigned(List) then
begin
MyList.Items.Clear;
for I := to List.Count- do
begin
// Create list view item
Item:= MyList.Items.Add;
Item.Text:= List[i]; // Load image
src:='http://www.w3schools.com/html/pic_mountain.jpg';
ms:= LoadWebImage(src); // Source
si:=ImageList.Source.Add;
si.Name:= 'Source'+inttostr(i); scale:=;
si.MultiResBitmap. LoadItemFromStream(ms,scale); W:=si.MultiResBitmap.Bitmaps[scale].Width; //Get width from scale
H:=si.MultiResBitmap.Bitmaps[scale].Height; //Get height from scale // Destination
d:=imageList.Destination.Add;
Layer := d.Layers.Add;
Layer.SourceRect.Rect := TRectF.Create(, , W , H); // Create rect W x H
Layer.Name := si.name; Item.ImageIndex := i; end;
end;

来源:https://*.com/questions/36013186/how-to-insert-images-to-timagelist-in-firemonkey-programmaticaly