[英]How to assign a picture from a TImageList to an TImage?
I am just using the trial version of AppMethod 1.17 aka Delphi 10 Seattle. 我只是使用AppMethod 1.17(又名Delphi 10 Seattle)的试用版。 Therefore I cannot look into the source code.
因此,我无法查看源代码。
In VCL I used TImageList.Draw()
, but with the new TMultiResBitmap class I don't know how to use it. 在VCL中,我使用了
TImageList.Draw()
,但是对于新的TMultiResBitmap类,我不知道如何使用它。
I found a solution but don't know if that is the prefered way. 我找到了解决方案,但不知道这是否是首选方法。
var
s: TSizeF;
begin
s.Create(32, 32); //Image size
myImage.Bitmap := myImageList.Bitmap(s,imageIndex);
end;
Another approach would be to add the bitmap into the MultiResBitmap of the TImage: 另一种方法是将位图添加到TImage的MultiResBitmap中:
var
sz: TSize;
bmpSrc, bmpTgt: TBitmap;
...
// Obtain the bitmap (e.g. from ImageList in data-module)
sz := TSize.Create(MaxInt, MaxInt); // Pick best size
DataModule1.ImageList1.BestSize(3, sz);
bmpSrc := DataModule1.ImageList1.Bitmap(sz, 3);
// Assign to Image1, to desired scale
bmpTgt := Image1.MultiResBitmap.Bitmaps[1.0];
bmpTgt.SetSize(bmpSrc.Size);
bmpTgt.Assign(bmpSrc);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.