[Solved] Transparent background for custom images

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

[Solved] Transparent background for custom images

Post by bertrod » Wed Jul 26, 2006 8:54 am

Hello,

I created custom images for my teeTree which I put in a imageList. In the imageList, I've set a transparent color (clRed in my case). Unfortunately, the pixels which should be transparent are white.

My teeTree has a gradient background, and I think this can be the reason why it doesn't work.

I resume :
1. creation of images with clRed pixels for the transparent parts
2. adding the images in a imageList
3. Linking the imageList to the treeview
4. Set the imageList transparentColor to clRed (works fine in the list)
5. Set a gradient background to the TeeTree
6. In the program, the transparent pixels are white instead of being transparent.

Maybe you can confirm me it is a problem with TeeTree. And if it is the case, is there a way to solve this problem ?
Last edited by bertrod on Mon Aug 07, 2006 11:08 am, edited 1 time in total.

tom
Advanced
Posts: 211
Joined: Mon Dec 01, 2003 5:00 am
Contact:

Post by tom » Mon Jul 31, 2006 10:24 am

Hi Bertrod,

Could you send me an example source code, so we can look at it and perhaps provide a solution?

Thanks,
tom @ steema.com

bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

Post by bertrod » Wed Aug 02, 2006 7:32 am

Hey tom,

I made some screenshots to explain my problem.

1. My images :
ImageImage
You see the clGreen color used to make the transparency

2. My images in the TImageList. I've set clGreen as transparentColor and you see the green doesn't appear, so I guess it should work :

Image

3. The result in the TeeTree :

Image
So the transparent color didn't work. There is a white square around the images.

What do you think about this problem ?

tom
Advanced
Posts: 211
Joined: Mon Dec 01, 2003 5:00 am
Contact:

Post by tom » Thu Aug 03, 2006 9:07 pm

Hi bertrod,

This is a bug in TImageList with 32bit images on XP.

You can try the following:

1) Try to set the TimageList BkColor property to something else than clNone. In a color which you probably won't have in the bitmap images.

2) Use non TImageList based component.

3) use the fix provided on the internet for a similar issue (not tested by us):

http://www.planet-source-code.com/vb/sc ... 0&lngWId=7
http://www.codeproject.com/cs/miscctrl/ ... gelist.asp

Regards,
Tom

bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

Post by bertrod » Mon Aug 07, 2006 11:08 am

Hello Tom,

Thank you, I could make it work with the 1st solution. I put :

Code: Select all

ImageList1.bkColor := treeview.color
and it works. But of course I guess it will not work if i set a gradient background. Fortunately I'm using a plain color for the moment.

tom
Advanced
Posts: 211
Joined: Mon Dec 01, 2003 5:00 am
Contact:

Post by tom » Mon Aug 07, 2006 9:00 pm

Hi Bertrod,

It even works when using a gradient background...

Regards,
Tom.

bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

Post by bertrod » Tue Aug 08, 2006 7:46 am

Hello,

Yes you're right. I thought it was working because i was setting the transparent color as the treeview.color. But as you said before, I just need to set the bkcolor to any color which is not used on my images to make it working.

Thanks again.

Post Reply