Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TImageList sometimes does not respect transparency of icons


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 6 - Last Post: Apr 1, 2016 2:43 AM Last Post By: Trevor Cooper
Trevor Cooper

Posts: 45
Registered: 10/7/10
TImageList sometimes does not respect transparency of icons  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 28, 2016 6:16 AM
Hi,

I have an icon that clearly seems to have its transparent colour correctly set, as shown by e.g. inserting into Word and positioning it over text. But when I load it into a TImageList and thence to a TToolBar, the transparent part of the icon is rendered in white. I don't have this problem with any other icons, just this one. Any ideas what would be causing this?

Thanks for any advice.

Trevor Cooper
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: TImageList sometimes does not respect transparency of icons  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2016 2:18 AM   in response to: Trevor Cooper in response to: Trevor Cooper
Trevor Cooper wrote:

Hi,

I have an icon that clearly seems to have its transparent colour
correctly set, as shown by e.g. inserting into Word and positioning
it over text. But when I load it into a TImageList and thence to a
TToolBar, the transparent part of the icon is rendered in white. I
don't have this problem with any other icons, just this one. Any
ideas what would be causing this?

Is the icon the only image in your imagelist? All images in an
imagelist share the same color for transparency, if this icon uses a
different color it will not be interpreted correctly by default. You
also can get into problems if you load images/icons with different
color depth into the same imagelist.

--
Peter Below
TeamB
Matthew Jones

Posts: 337
Registered: 1/25/98
Re: TImageList sometimes does not respect transparency of icons  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2016 2:32 AM   in response to: Peter Below in response to: Peter Below
Peter Below wrote:

All images in an
imagelist share the same color for transparency,

The key being that it doesn't, at least in versions I'm familiar with,
support alpha transparency. There are third-party components that
derive from the ImageList which do support alpha transparency (Dev
Express does IIRC).
Trevor Cooper

Posts: 45
Registered: 10/7/10
Re: TImageList sometimes does not respect transparency of icons  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2016 7:13 AM   in response to: Matthew Jones in response to: Matthew Jones
Thanks for the suggestion Matthew.

Actually, I'm trying to edit transparency into this icon using IcoFX. It doesn't appear to make any difference in Delphi how I set IcoFX's 'apply filter to alpha channel' option. I don't know whether that option is relevant, but it seems to be the only one referencing the term 'alpha' in the help file.

I may give up on this and adapt another icon that does behave properly in Delphi.

TC
Trevor Cooper

Posts: 45
Registered: 10/7/10
Re: TImageList sometimes does not respect transparency of icons  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2016 7:08 AM   in response to: Peter Below in response to: Peter Below
Thanks for your advice Peter.

If I add the icon to a pre-existing image list, how do I tell which colour the others are sharing for transparency? The image list reports its never-editable transparent colour as 'default', and that looks white-ish, but how can I be sure?

Then, if I add the icon to a new image list, I have the same problem, so I guess there must be something else odd about the icon itself.

Regards

Trevor Cooper
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: TImageList sometimes does not respect transparency of icons  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 30, 2016 6:29 AM   in response to: Trevor Cooper in response to: Trevor Cooper
Trevor Cooper wrote:

Thanks for your advice Peter.

If I add the icon to a pre-existing image list, how do I tell which
colour the others are sharing for transparency? The image list
reports its never-editable transparent colour as 'default', and that
looks white-ish, but how can I be sure?

The imagelist picks the color of the bottom left (or top left, don't
rememeber) pixel of the bitmap as the transparent color and builds the
image mask used for rendering with transparency based on that. I
misremembered, by the way: the images added can have a different color
here, but this only works reliably if all images use the same color
depth (and palette, if they have one), and it does not work with 32 bit
icon transparency based on alpha channel.

I had this problem myself while adding images from different sources to
an imagelist and ended up by filling the transparent areas in IcoFX
with a color not otherwise used (purple usually), saving the image as a
bitmap with a suitable fixed color depth (32 bits usually), and then
adding that to the imagelist. Directly adding icons (ICO files) has not
worked well for me in the past.


--
Peter Below
TeamB

Trevor Cooper

Posts: 45
Registered: 10/7/10
Re: TImageList sometimes does not respect transparency of icons  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2016 2:43 AM   in response to: Peter Below in response to: Peter Below
Thanks for your advice Peter. I will bear it in mind for the next time.

Cheers

TC
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02