Recent

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

pcurtis

  • Hero Member
  • *****
  • Posts: 951
[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 20H2
Laz 2.2.0
FPC 3.2.2

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • 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: 11858
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 »

jamie

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

  • Hero Member
  • *****
  • Posts: 951
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 20H2
Laz 2.2.0
FPC 3.2.2

sstvmaster

  • Sr. Member
  • ****
  • Posts: 299
Re: ImageList - Sliced image
« Reply #5 on: October 01, 2020, 11:54:24 pm »
greetings Maik

Windows 10,
- Lazarus 2.2.6 (stable) + fpc 3.2.2 (stable)
- Lazarus 2.2.7 (fixes) + fpc 3.3.1 (main/trunk)

winni

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