Recent

Author Topic: [solved] Version 2.0.0 problem with TImageList  (Read 1387 times)

bobonwhidbey

  • Hero Member
  • *****
  • Posts: 590
    • Double Dummy Solver - free download
[solved] Version 2.0.0 problem with TImageList
« on: March 20, 2019, 05:14:56 pm »
I recently upgraded from version 1.8 to 2.0 and so far, all has gone well except for a TImageList.

What I've tried to do is read in a long, skinny BMP (91 high x 5025 wide) into MyBMP. Then I want to be able to pluck from the ImageList a smaller, 67 x 91 size BMP based on an index number. This approach worked flawlessly in all earlier versions of Pascal.

Code: Pascal  [Select][+][-]
  1.   MyBMP := tbitmap.Create;
  2.   MyBMP.LoadFromResourceName(HInstance, 'carddeck'); // verified with the debugger as being 91 X 5025
  3.   MyBMP.PixelFormat := pf32bit;
  4.   w := 67; // each card image width
  5.   h := 91;
  6.   MyList := timagelist.CreateSize(w, h);
  7.   w :=  MyList.Add(MyBMP, nil);
I expected w to be 75, but it's 0, and all my images are blank. Is this an easy fix for Lazarus or do I need to roll my own? More likely I've done something I shouldn't have.

When I upgraded from 1.8 to 2.0 I also switched from 32-bit to 64-bit. In the past I ran a 32-bit version of Lazarus on my 64 bit Windows PC. Now I've installed the 64-bit version of Lazarus, but I still want to create 32-bit apps. Could this be the source of my problems?
« Last Edit: March 20, 2019, 06:03:30 pm by bobonwhidbey »
Lazarus 3.0RC2, FPC 3.2.2 x86_64-win64-win32/win64

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: Version 2.0.0 problem with TImageList
« Reply #1 on: March 20, 2019, 05:47:32 pm »
Use AddSliced instead of Add (http://wiki.lazarus.freepascal.org/TImageList#Add_method):

Code: Pascal  [Select][+][-]
  1.     function AddSliced(Image: TCustomBitmap; AHorizontalCount, AVerticalCount: Integer): Integer;

The change was necessary because the new ImageList can contain images at different sizes to support different resolutions.

bobonwhidbey

  • Hero Member
  • *****
  • Posts: 590
    • Double Dummy Solver - free download
Re: Version 2.0.0 problem with TImageList
« Reply #2 on: March 20, 2019, 06:03:16 pm »
Thank you - worked perfectly. I'm sure others may benefit from this thread.
Lazarus 3.0RC2, FPC 3.2.2 x86_64-win64-win32/win64

 

TinyPortal © 2005-2018