问题
Using Borland C++ Builder 2009 I notice that when replacing images in a TImagelist, the alpha channel data gets corrupted somehow.
TIcon *Icon = new TIcon() ;
for (int x = 0 ; x < OS_Specific_count ; x++)
{
OS_xx_ImageList->GetIcon(x, Icon) ;
Use_ImageList->ReplaceIcon(x, Icon) ;
}
delete Icon ;
The problem is also described (+screenhots) in another Q ( TImageList - True color + alpha channel vs. 8-bit (256 colors) ) but I'm now trying to narrow things down with more specific questions.
While browsing TIcon in the help file I noticed a read-only property: SupportsPartialTransparency
.
It appears to be false
in my case, and I wonder if this is not the key to solving this problem ? Icon->Transparent = true
does not set SupportsPartialTransparency
to true !
I wonder what I can do to make sure the TIcon instance correctly 'gets' and 'replaces' the alpha channel information ?
The ImageLists are created at design time and have default properties (nothing changed) and contain 16x16 icons imported via the IDE. The imported icons contain alpha channel information.
回答1:
I just use TPngImageList, it is compatible with TImageList. Plus the design-time editor is more flexible: You will need to convert .ico to .png. .
It is free and widely available, for example here: https://github.com/TurboPack. No headache with transparency since :) BTW, keeping icons as PNGs is more suitable, you can use them on other development tools and platforms.
来源:https://stackoverflow.com/questions/35144723/how-to-setup-a-ticon-instance-to-support-alpha-channel-icons-supportspartialtra