TImagelist for large images

1.5k views Asked by At

I want to display from a set of e.g. 30 bitmaps a small number on a form. I placed several TImage components on this form and loaded the images at design time. Now I want to exchange the image during the start of my form while loading the bitmap from a TImagelist into the Timage component. I fail because Timagelist can only hold Images up to 128 x 128 Pixels.

q: how to make a imagelist for large images ?

no option for me :

  1. load the images from the file during start up .....
  2. place 40 Timages on my form and display the correct one with TImage[i].visible := true;
1

There are 1 answers

3
SilverWarior On

So you want to be able to show any of these 30 bitmaps on demand but you don't want to load them from an external file when they are needed. I guess the reason for this is that you are concerned about HDD performance preventing you from showing of these images fast enough.

I see several options:

First option is to have these images in separate files and then at application start you load them into multiple TBitmap classes (one TBitmap for each image). Then when you need to show specific image on your form you simply assign the specific bitmap as a picture source for your desired TImage component on which you want that image to be shown.


If you don't want to distribute 30+ file for your application you could put all those images into a single archive and then at application start load them into separate bitmap classes as I have described above.


If you want to only have a single file for your application then you could put those images into a resource file and then build that resource file into your executable. Once you have done that you can then access al those images as resources. I think there was a question about working with resources posted not long time ago here on SO.


Now if you don't know how to work with resources and are not willing to learn you could use some image editing software to put all those images into one big image. You can then have one TImage control on your form with that large image set at design time.

This will integrate image data directly into your from DFM which could cause a bit slower form creation due to large image data in the DFM.

You show your desired images now by copying part of your big image canvas onto the canvas of your desired TImage component. Infact you no longer have to use TImage components for these. Any component with canvas would do.

This last option is similar to working with Atlas Bitmap-ses or sometimes as working with Sprite images.

The component from Graphics32 library that Arioch suggested internally uses quite similar approach.