下面示范 Firemonkey TImageList 加入一张原始尺寸图片的方法:
使用代码加图
if Assigned(List) then begin MyList.Items.Clear; for I := 0 to List.Count-1 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:=1; 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(0, 0, W , H); // Create rect W x H Layer.Name := si.name; Item.ImageIndex := i; end; end;