How to setup a TIcon instance to support alpha channel icons (SupportsPartialTransparency)

泪湿孤枕 提交于 2019-12-11 10:39:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!