Recent

Author Topic: [SOLVED] ImageList - Sliced image  (Read 332 times)

pcurtis

  • Sr. Member
  • ****
  • Posts: 310
[SOLVED] ImageList - Sliced image
« on: October 01, 2020, 08:51:50 pm »
Hi All,

I have a png of flags. The individual flags are 16x12.

Does  anyone know how I can slice this resolution into an ImageList?

« Last Edit: October 02, 2020, 12:43:47 pm by pcurtis »
Windows 10 / Linux Mint 20
Laz 2.10.0
FPC 3.2.0

Handoko

  • Hero Member
  • *****
  • Posts: 3868
  • My goal: build my own game engine using Lazarus
Re: ImageList - Sliced image
« Reply #1 on: October 01, 2020, 09:11:20 pm »
« Last Edit: October 01, 2020, 09:25:39 pm by Handoko »

wp

  • Hero Member
  • *****
  • Posts: 7636
Re: ImageList - Sliced image
« Reply #2 on: October 01, 2020, 10:10:16 pm »
The easiest way is to use a TImageList because it has built-in slicing capabilities: use the method AddSliced which requires a TCustomBitmap and the number of columns and rows:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. const
  3.   COL_COUNT = 17;
  4.   ROW_COUNT = 16;
  5. var
  6.   png: TCustomBitmap;
  7. begin
  8.   ImageList1.Width := 16;
  9.   ImageList1.Height := 11;
  10.   png := TPortableNetworkGraphic.Create;
  11.   try
  12.     png.LoadFromFile('flags.png');
  13.     ImageList1.AddSliced(png, COL_COUNT, ROW_COUNT);
  14.   finally
  15.     png.Free;
  16.   end;
  17. end;
« Last Edit: October 01, 2020, 10:15:11 pm by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

jamie

  • Hero Member
  • *****
  • Posts: 3664
Re: ImageList - Sliced image
« Reply #3 on: October 01, 2020, 11:06:00 pm »
Hi All,

I have a png of flags. The individual flags are 16x12.

Does  anyone know how I can slice this resolution into an ImageList?

If anything, thanks for the Image, I can integrate that into an app I have where that would come in handy..

Is the order of the flags related to any country code index by any chance ?  :D
The only true wisdom is knowing you know nothing

pcurtis

  • Sr. Member
  • ****
  • Posts: 310
Re: ImageList - Sliced image
« Reply #4 on: October 01, 2020, 11:33:16 pm »
Not sure. I ripped it from online-radio.eu

Thanks all.
Windows 10 / Linux Mint 20
Laz 2.10.0
FPC 3.2.0

sstvmaster

  • Full Member
  • ***
  • Posts: 172
Re: ImageList - Sliced image
« Reply #5 on: October 01, 2020, 11:54:24 pm »
Windows 10 (64 bit)
Lazarus: 2.0.10 / Trunk x32

winni

  • Hero Member
  • *****
  • Posts: 1907
Re: ImageList - Sliced image
« Reply #6 on: October 02, 2020, 12:11:07 am »
Hi

Anybody interested in waving flags?

120 x 100 px PNG,

232 flags

Winni

 

TinyPortal © 2005-2018