Lazarus

Programming => LCL => Topic started by: Raul_ES on April 16, 2020, 02:35:08 pm

Title: [SOLVED] TImageList with large resolutions
Post by: Raul_ES on April 16, 2020, 02:35:08 pm
Hello,

I am not really sure if I can do the following. I would like to create an imagelist with big files (i.e 640x480 pictures or whatever, not 16x16, 32x32...) to use them in a Timage:

Code: Pascal  [Select][+][-]
  1. loginForm.ImageList_Flags.GetBitmap(1,Image_caFlag.Picture.Bitmap);


This code works fine, but they are scaled down to 16x16 format and I want them to be stored in the ImageList with their original size.


thank you!
regards
Title: Re: TImageList with large resolutions
Post by: lucamar on April 16, 2020, 03:12:48 pm
You have to set the list's Height and Width to the required dimensions; otherwise it uses the default, which is 16x16, and the images are scaled down when loading to the image list.
Title: Re: TImageList with large resolutions
Post by: wp on April 16, 2020, 03:31:20 pm
I want them to be stored in the ImageList with their original size.
This is not possible. Store the images as resources. It is a simple script to create a res file from a file list with LazRes (see the .bat or .sh files in the images folder of your Lazarus installation).
Title: Re: TImageList with large resolutions
Post by: lucamar on April 16, 2020, 06:16:04 pm
I want them to be stored in the ImageList with their original size.
This is not possible. Store the images as resources. [...]

Yes, it is possible if all the images have the same dimensions. You just have to set the proper Width and Height in the TImageList; I just (re)tested with a set of 640x480 images and it works as it should. Of course, if the images are of different dimensions they will be cropped/scaled/whatever to the list dimensions, depending on how you add them and how several other properties of the list are set.

In fact, this is how you set-up a "normal" list for, say, 64x64 icons or whatever.

Only drawback is that if you load the images at design-time you may end up with a huge .lfm; in my test (just a form and an ImgeList with eight 640x480 images) it grew to a quite respectable 21,8 Mib :)
Title: Re: TImageList with large resolutions
Post by: wp on April 16, 2020, 06:27:07 pm
I want them to be stored in the ImageList with their original size.
This is not possible. Store the images as resources. [...]

Yes, it is possible if all the images have the same dimensions.
Right. But I was understanding the "or whatever" of the first post as hint that image size will vary.
Title: Re: TImageList with large resolutions
Post by: Raul_ES on April 18, 2020, 10:59:02 pm
Thank you, it works perfectly now. I did not know that we have width & height properties for TImagelist.


regards,
TinyPortal © 2005-2018