views:

53

answers:

1

Hi, I'm using a set of around 100 icons in my application, these are accessed using fixed refrence numbers and these numbers are also made available for the user to choose an icon. The three resolutions that are required are 16x16, 32x32 and 48x48. Each of these resolutions are held in a TPngImageList and I've created an 'icon library' using a TDataModule than contains these three image lists (TArtImageLibraryImageLists). A simple 'create on first use' method instantiates this TDataModule when any of its Image Lists are required. The LargeImages or somesuch property of any controls that require access to an image list are simply set by calling the required resolution function.

The problem is the load time when the program starts, which is about 1s on a fast machine. Obviously the worst culprit is the 48x48 image list but I'm wondering if there is a better load mechanism (eg using a resource file?) that will speed up things. Or is there a way I can reformat the image lists? I will still need a TImageList at runtime, e.g for my TreeView's etc.

Thanks, Brian.

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;
A: 
  1. You say "A simple 'create on first use' method instantiates this TDataModule", but then say the problem is the startup time. When the datamodule is created actually?
  2. Did you profile the application to ensure is the image list loading the problem?
  3. If the problem is actually the image list, did you need pngs? If they are stored as such, they need to be decoded and added to the imagelist bitmap. ImageList_LoadImage() can load a bitmap in one step.
ldsandon
@ldsandon: 1 -Yes, it is created the first time a reference to an image list is assigned. 2 - Yes. It is the loading of the DFM resource of the data module containing my 3 image lists that is slow. 3. PNG's - I'm using for transparency but that's a good point, maybe I will look at other formats. THanks.
Brian Frost