Recent

Author Topic: About TImageList (v2.0...)  (Read 6619 times)

polpero

  • Full Member
  • ***
  • Posts: 116
About TImageList (v2.0...)
« on: November 03, 2018, 02:07:34 pm »
Hi

If i understand correctly, the method of aligning all icons in a single image file
to be 'auto-sliced' by the TImageList component subsequently
won't work in the latest versions?

If opened in Lazarus 2,
the old TImageList will show the file adequately sliced
but it won't be possible to reload the old image file in a new TImageList ?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: About TImageList (v2.0...)
« Reply #1 on: November 03, 2018, 02:13:55 pm »
Does this help: http://wiki.lazarus.freepascal.org/Lazarus_2.0.0_release_notes#TCustomImageList.Add_method

Or is this about using object inspector / property editor?

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: About TImageList (v2.0...)
« Reply #2 on: November 03, 2018, 02:28:22 pm »
At runtime, you must call the method AddSliced:
Code: Pascal  [Select][+][-]
  1.     function AddSliced(Image: TCustomBitmap; AHorizontalCount, AVerticalCount: Integer): Integer;
At designtime, it does not work any more. Maybe I should try to add a button "Add sliced".

polpero

  • Full Member
  • ***
  • Posts: 116
Re: About TImageList (v2.0...)
« Reply #3 on: November 03, 2018, 02:41:04 pm »
@Martin
   
   i did find the link...
  although it identifies the situation
  the solution is maybe not clearly exposed...

@wp

  a button "Add sliced" could be welcomed.
  (although there already are a bunch of buttons there...
   could it not be detected at file opening as before?)

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: About TImageList (v2.0...)
« Reply #4 on: November 03, 2018, 02:44:41 pm »
@wp
  a button "Add sliced" could be welcomed.
  (although there already are a bunch of buttons there...
   could it not be detected at file opening as before?)
I think there is no way to distinguish a single image from mulitple images now because the ImageList now accepts any size (the old one insisted on the Width and Height properties). And the many buttons: Well, you'll get used to it...

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: About TImageList (v2.0...)
« Reply #5 on: November 03, 2018, 06:04:10 pm »
What happens, if an image list loads a "slice-able" image from an older lfm?

polpero

  • Full Member
  • ***
  • Posts: 116
Re: About TImageList (v2.0...)
« Reply #6 on: November 03, 2018, 06:13:09 pm »
to me it seems that

Quote

If opened in Lazarus 2,
the old TImageList will show the file adequately sliced
but it won't be possible to reload the original image file in a new TImageList


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: About TImageList (v2.0...)
« Reply #7 on: November 03, 2018, 06:42:34 pm »
So image list works (as long as code use AddSlice, as documented), but the property editor no longer has the feature.

Please report on the bugtracker. Imho it should be reported as regression

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: About TImageList (v2.0...)
« Reply #8 on: November 03, 2018, 10:24:07 pm »
No more need for a bug report: I added a button "Add Sliced" to the ImageListEditor of trunk.

It is assumed that the size of the individual images is given by the values of the Width and Height properties of the ImageList; the number of rows and columns is calculated from these values and the size of the original combined image. The division must not leave a remainder, otherwise the image is rejected. So, if you have 10 images, each 16x16, then the dimension of the original image must be 160x16, or 80x32 or similar, and the ImageList.Width and .Height must be set to 16 each. This is like in Delphi and in the old version. The concept, however, can lead to misunderstandings because the new image list also accepts individual images of different sizes.

Although some kind of regression I'd prefer to keep this modification in trunk and avoid backporting to fixes because the release of the new version is so close. Martin, do you agree?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: About TImageList (v2.0...)
« Reply #9 on: November 03, 2018, 10:46:03 pm »
Although some kind of regression I'd prefer to keep this modification in trunk and avoid backporting to fixes because the release of the new version is so close. Martin, do you agree?
I had a quick look, all code is in new methods (except 2 unused vars), not called by existing code. So it can't cause regressions to existing code. Therefore it should be fine.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: About TImageList (v2.0...)
« Reply #10 on: November 03, 2018, 10:58:45 pm »
OK, I put it on the merge list. Thanks for spotting the unused variables...

ase

  • New member
  • *
  • Posts: 8
Re: About TImageList (v2.0...)
« Reply #11 on: January 03, 2019, 04:46:29 pm »
Is it normal that the imagelist clears when a new value for Width or Height is set in the property editor? To reproduce:
  • open examples/imagelist_highdpi_designtime
  • click on ImageList1
  • set Height to 32
The imagelist gets cleared and all icons are removed from the form. This behaviour is the same at runtime. 2.0.0RC3

HeavyUser

  • Sr. Member
  • ****
  • Posts: 397
Re: About TImageList (v2.0...)
« Reply #12 on: January 03, 2019, 07:39:43 pm »
Is it normal that the imagelist clears when a new value for Width or Height is set in the property editor? To reproduce:
yes. An image list is not a list of bitmaps it is a a huge bitmap with size of image height x image width * number of images in the list. By changing the the size the image list does not know how to handle the existing images ee center them in the new size? resize them? some other way? so it simple clears its results and forces you to reload the images so you can decide how to be handle on per image bases.

ase

  • New member
  • *
  • Posts: 8
Re: About TImageList (v2.0...)
« Reply #13 on: January 04, 2019, 08:23:26 am »
Thank you for your help. When we look at a toolbar for instance, I confused the imagelist's width property (images.Width) with ImagesWidth of the toolbar itself.

http://wiki.freepascal.org/TImageList:
Quote
Every LCL control that supports ImageList has now a new [Images]Width property to decide what custom width at 96 PPI (100% scale) is to be used. Example: TToolBar.Images/ImageWidth, TListView.LargeImages/LargeImagesWidth.

Set the Scaled property to True and the image list will automatically pick up the scaled image in your High-DPI aware LCL application.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: About TImageList (v2.0...)
« Reply #14 on: January 04, 2019, 09:33:29 am »
The ImageList of Laz v2.0+ can contain several image sizes. Depending on the resolution of the monitor the correct size is selected automatically or interpolated (when the property "Scaled" is set to true).

ImageList.Width is the default size which is automatically provided; even if you add images having different sizes they will be scaled to the default size. Using the button "New resolution" in the ImageList editor defines another unscaled image size. Say, you want the ImageList to contain both unscaled 16x16 and 32x32 images then you set ImageList.Width to 16 and add "32" as another "resolution".

(SomeControl).ImagesWidth is the size used by the control for the standard monitor resolution of 96 ppi (100%), by default (i.e. when 0) the ImageList.Width; at higher resolutions the images are automatically magnified, either by using a stretch-draw method or by selecting from other image sizes stored within the ImageList. The property ImageWidth is mainly needed for controls such as TListView when has properties SmallImages and LargeImages. Before Laz 2.0 (and in Delphi) you had to assign different image lists to these properties. But now you can attach the same imagelist to both properties; set ListView.SmallImagesWidth to 16 and ListView.LargeImagesWidth to 32 (or some other values) in order to make the ImageList deliver images of the correct size.

Returning to your original question: Suppose you have populated an ImageList with images of 16x16, but notice that you should have set ImageList.Width to 32. When you set ImageList.Width to 32 the images already entered will be erased like before. But you could set (SomeControl).ImageWidth to 32 - this would keep the images already entered; the image list would upscale the images to 32x32. On the other hand, upscaling of images usually has a quality problem, and you'd prefer to erase the imagelist and enter the images again at 32x32 size. So,  no change in practice...

You already found the short chapter on the new imagelist in the wiki, I am linking to it again for reference: http://wiki.lazarus.freepascal.org/TImageList#Multiple-resolution_TImageList_in_Lazarus_1.9_and_newer
« Last Edit: January 04, 2019, 10:12:51 am by wp »

 

TinyPortal © 2005-2018