Topic: Feature request : LoadFromFile PNG

Hello Dmitry,

The title says it all, I'd like to be able to use PNG images as icons for my menus.

At the moment I do :

    MyItem2.Bitmap.Width := 16;
    MyItem2.Bitmap.Height := 16;
    BMwanted:= TBitmap.Create;
    BMwanted.LoadFromFile('.\icons\Search16.bmp');
    MyItem2.BitMap.Canvas.Draw(0,0,BMwanted);

This works fine, but handling transparency with bitmaps is a pain in the *** if you see what I mean smile
It's doable but you have to generate the alpha channel and save in 32 bits bitmap... not fun.


I spotted the TCustomImageList in the classes list but failed to use it.


Do you think it would be a lot of work to implement PNG handling ?


Cheers


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: Feature request : LoadFromFile PNG

Hello.


It's not supported in the current version. Unfortunately I can't to know right now how difficult it is to realize this.

Dmitry.

Re: Feature request : LoadFromFile PNG

Thanks Dmitry,


I'll stick with my 32 bits bitmaps then smile


Cheers


Math

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: Feature request : LoadFromFile PNG

Hello again Dmitry,


I've tried a few things and ended-up with :

MyItem1 := TMenuItem.Create (Pop);
    MyItem1.Caption := 'Mark Asset as Owned';
    MyItem1.BitMap.Width := 16;
    MyItem1.Bitmap.Height := 16;
    POwned := TPngImage.Create;
    POwned.LoadFromFile('.\icons\TEST\owned.png');
    MyItem1.BitMap.Canvas.Draw(0,0,POwned);
    Pop.Items.Add(MyItem1);
  1. Define width and height of the image

  2. Create a TPngImage

  3. Load PNG from file

  4. Assign PNG to Menu Item


This works fine without error and the PNG image is loaded correctly except... it's not transparent.... sad


Any idea to overcome this "detail" and get the image transparent ?

BMP.Assign(PNG);

does not work because it strips the transparency during the assign process

Ideally, we would do :

PNG.AssignTo(BMP);

Theocratically, this would preserve transparency but I'm not 100% sure.


I'll leave you with that smile


Have a nice day


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: Feature request : LoadFromFile PNG

mathmathou
It's possible only with using component TImageList, planned.

Dmitry.