Recent

Author Topic: How to add PNG to ImageList?  (Read 6576 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2625
    • UVviewsoft
How to add PNG to ImageList?
« on: March 11, 2016, 07:20:08 pm »
I'm looking how to add PNG files (e.g. 20x20) to TImagelist.
I cannot find method to add PNG data.

Can you help?

balazsszekely

  • Guest
Re: How to add PNG to ImageList?
« Reply #1 on: March 12, 2016, 08:10:57 am »
@Alextp
I have no problem adding png files(20x20) to TImageList(Lazarus 1.7/FPC 3.0.0/Win 7). What is your OS, I can test if it works or not.

AlexTP

  • Hero Member
  • *****
  • Posts: 2625
    • UVviewsoft
Re: How to add PNG to ImageList?
« Reply #2 on: March 12, 2016, 08:55:59 am »
My mistake:
I can load png;  I need not TBitmap but other class

wp

  • Hero Member
  • *****
  • Posts: 13226
Re: How to add PNG to ImageList?
« Reply #3 on: March 12, 2016, 11:25:55 am »
You mean to add at runtime since there is no TCustomImageList.AddPng method? This is approximately what the image list editor is doing, it should work for all image types that Laz can read:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   srcBmp: TBitmap;
  4.   picture: TPicture;
  5. begin
  6.   Picture := TPicture.Create;
  7.   try
  8.     Picture.LoadFromFile(Filename);
  9.     SrcBmp := TBitmap.Create;
  10.     SrcBmp.Assign(Picture.Graphic);
  11.     ImageList1.Add(SrcBmp, nil);
  12.   finally
  13.     Picture.Free;
  14.   end;
  15. end;  

AlexTP

  • Hero Member
  • *****
  • Posts: 2625
    • UVviewsoft
Re: How to add PNG to ImageList?
« Reply #4 on: March 12, 2016, 11:42:21 am »
Yes I mean runtime; I solved using
ImageList.Add(<here is object of TPortableNetworkGraphic> )

 

TinyPortal © 2005-2018