Transparency of PNG files

Hi everybody,

I found a previous topic about this problem but no answer…It had been closed more than 120 days ago, so I make a new topic.

I’m testing the Charlie’s script for coloring and tagging an icon for my items (Songs, Jingles…)
I’ve choosen PNG files for my icons. When I use the item’s properties window, and “select” the PNG icon manually, the icon is correctly displayed in the playlist with its transparency. Great!

However, when I load with the Charlie’s script, the PNG files is linked to the item, but with black background instead of transparency…

Where I’m wrong ? Do I have to put the PNG icon one-to-one, using the properties windows (which would be very very boring…) ?
Is it a problem with the script ? with the icon ?

Thanks for you help…


Theo

Can you please post a reference to the script you mention? I presume it must be updated to reflect some changes in the internal handling of images.

“the Charlie” uses this line in his scripts:

CurrentPlaylist.GetItem(i).GetPicture.LoadFromFile(‘C:\mAirList\icons\Icon - Song.ico’);

Yes, it’s that script…replacing the ICO file path by the PNG file path…

I had some problems with PNG transparency, so I found some (better) ICO files instead :slight_smile: I get mine from iconarchive.com - they are all available in various pixel sizes in PNG format, plus a large ICO file. Cad did suggest an image program to set the PNG transparency but I couldn’t get it to work for me, but he appears to be the expert on that sort of thing.

It was IconSushi, which has variably successful results.

Also try any graphics programs you have available, like PaintShopPro or Photoshop.

BFN
CAD

It’s right.

My png files use transparency with grey shadow… it’s, according to photoshop, a PNG24 format. Hence, this format is not correctly supported by mairlist for transparency. The picture displays but all the background is painted.
So, either I export with color background included (what I’ve done to keep the shadow), either I convert it to PNG8 (without shadow to seem natural, or with shadow but a shadow not transparent).

I chose the first one for keeping the shadow transparency… Thanks for your help.

Just a message in order to say it’s not so easy to customize the playlist item…
So many keywords… it’s really hard to obtain the required result.

For example, the FadingRowColor doesn’t work…
The font for the name and the state of the player (in the playlist column) is big, but I don’t find the keyword for them…
I don’t find the keyword for uping the item’s line height…

Quite difficult… And each time I make a modification in the ini file, I must restart mairlist to see the result. Quite long for each modification…

I have to be courageous… :-[

Once you got the point (that is, how the entry names are built of keywords), it is pretty easy.

Reloading the skin during runtime is not possible due to various reasons at the time being.

Pretty easy… I will see :-/
It’s hard to find keywords I need…

I found the difference between adding a picture from “properties” windows, and adding a picture with the Charlie’s script. Storage is quite different.
The script line useful for being able to see the good PNG transparency is

CurrentPlaylist.GetItem(i).GetPicture.SetFilename('File-path.png');

In the XML, with this script, we see the png file path and the transparency is okay in the playlist.
With the script line

CurrentPlaylit.GetItem(i).GetPicture.LoadFromFile('File-path.png');

The picture is stored in the XML. Impossible to see a correct transparency.

So, if you want to see the PNG transparency in the playlist, let use the first script line instead of the second script line :slight_smile:

First of all, thanks for your extensive investigations. I finally found the bug, which will be fixed in v2.2.1.

Here’s a little background:

mAirList uses a powerful graphics library (GraphicEx) which can handle dozens of file types, e.g. BMP, JPG, GIF, etc. Unfortunately, that library has very poor PNG support. It can only display certain sub-types, and transparency as hardly handled correctly at all. This is why I included an additional library - pngdelphi - only for PNG files. When loading an icon, a flag is set to determine whether the special PNG library or the default library should be used for this image. In the current version, when using LoadFromFile, the flag is not set correctly. This is the bug I just fixed.

Also note the difference between SetFilename and LoadFromFile mentioned by Theo above: When using SetFilename (or clicking “Select Icon” in the Properties dialog), only the name of the icon file is stored in the MMD file/tag/etc. When using LoadFromFile (or holding Shift while clicking “Select”), the file data is stored in the MMD.

Torben

Oh, and can you please try the snapshot I have just uploaded?

http://www.mairlist.com/download/mAirList/v2.2/snapshot/

I would add that the advantage of using the SetFilename function, instead of using the LoadFromFile is that :
if you tagg all the song items with the same icon (logical process), and you decide finally to change the picture because you found a more beautiful icon, you just have to replace the file, giving it the same filename as the origin file.

All the song item will link directly to the new image, without having to launch a script for re-tagging all the items…It’s a very fast process : one picture for all the song item. Replacing the file with the same filename will impact all the song items.
Great function !

Thanks Torben for your explanation about the flag. It’s clear now. I will try your snapshot tonight after work :slight_smile:

Theo,
Well done for this - I’ve just used the 1st line to change some icons and it works much better! The problem I had was that icons on certain files were not being changed

The old line of code wouldn’t remove this part of the code, so I had to click “icon reset” then run the code again :frowning:

<Picture> <Filename>Z:\mAirList Files\icons\Icon - Song.ico</Filename> </Picture>

Old Line:
CurrentPlaylist.GetItem(i).GetPicture.LoadFromFile(‘C:\mAirList\icons\Icon - Song.ico’);

New Line:
CurrentPlaylist.GetItem(i).GetPicture.SetFilename(‘C:\mAirList\icons\Icon - Song.ico’);

Looking at it like this, I can see why I had problems now but I did think it may have started when, as I recall, Torben did change the icon format/routines and perhaps the changes made on that snapshot would not be future-compatible ? Anyway, it’s sorted now.

Perhaps it’s possible to “reset” picture for all items with a mairlist script ?
I don’t know all the available functions… Maybe there is a line code like “GetItem(i).ResetPicture()” possible ?

The other advantage of linking the PNG file path instead of selecting it from the “properties” windows is that only one instance of the picture is stored. And not stored in each MMD song’s item file !!!
Hence, you will have more memory-saving MMD files because they don’t store the picture into them : only a reference. Great for saving memory of your hard disks…isn’t it ?

What do you mean by “reset”?

CurrentPlaylist.GetItem(i).GetPicture.Clear;

I was also concerned that the MMD files were getting bloated with data when saving playlist icons/png files. A (local or network) reference to an icon folder is much more efficient and as Theo says, easy to change your icons should you find better ones in the future.

Yes Torben. I was thinking about the “reset” bouton in properties windows. That’s why I use “reset” word for function name.
Your script line is right.

So, if Charlie wants to remove all his icons (loaded with the LoadFromFile function), it’s possible with ease. Just write the

CurrentPlaylist.GetItem(i).GetPicture.Clear;

followed by the

CurrentPlaylist.GetItem(i).GetPicture.SetFilename('File-path.png');

Great ! Happy to help you after you helped me a lot !!

SetFilename overwrites the current image, so why would you need to call Clear first?

Oh ! I thought that the storage in the XML file was different (not the same tagname indeed)…
But if it’s the same tag, yep, clearing the picture before calling SetFilename is useless.

Sorry for the mistake ;D