* * *

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

polpero

  • Jr. Member
  • **
  • Posts: 66
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: 4880
    • 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: 5034
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".
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

polpero

  • Jr. Member
  • **
  • Posts: 66
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: 5034
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...
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4880
    • 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

  • Jr. Member
  • **
  • Posts: 66
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: 4880
    • 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: 5034
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?
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4880
    • 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: 5034
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...
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus