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


下面示范 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;

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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM