我在我的应用程序中使用了一组约100个图标,这些都是使用固定参考号进行访问的,这些数字也可供用户选择图标。所需的三种分辨率是16x16,32x32和48x48。这些解决方案中的每一个都保存在TPngImageList中,并且使用TDataModule创建了一个“图标库”,而不是包含这三个图像列表(TArtImageLibraryImageLists)。当需要任何图像列表时,一个简单的“首次使用时创建”方法会实例化此TDataModule。任何需要访问图像列表的控件的LargeImages或somesuch属性都可以通过调用所需的分辨率函数来设置。如何提高德尔福TPngImageList(或TImageList)的加载时间
问题是程序启动时的加载时间,在快速机器上约为1秒。显然,最糟糕的罪魁祸首是48x48图像列表,但我想知道是否有更好的加载机制(例如使用资源文件?),这会加快速度。或者有什么方法可以重新格式化图像列表?我仍然需要在运行时TImageList,例如我的TreeView等。
谢谢, 布赖恩。
var
FInstance : TArtImageLibraryImageLists;
function ArtImageLibraryImageLists : TArtImageLibraryImageLists;
begin
If not Assigned(FInstance) then
FInstance := TArtImageLibraryImageLists.Create(nil);
Result := FInstance;
end;
function ArtIconLibraryImageList16 : TImageList;
begin
Result := ArtImageLibraryImageLists.ImageList16;
end;
function ArtIconLibraryImageList32 : TImageList;
begin
Result := ArtImageLibraryImageLists.ImageList32;
end;
function ArtIconLibraryImageList48 : TImageList;
begin
Result := ArtImageLibraryImageLists.ImageList48Shadow;
end;
您似乎在启动时需要数据模块,但启动时是否需要48x48映像? – 2010-10-28 09:56:25