CImageList transparency

I have a list of images and it is displayed like so:

----------------------------------
| White space                     |
|-------------------------------|
|                                       |
|  The image is here           |
|                                       |
|                                       |
|-------------------------------|
| White space                     |
----------------------------------

Now, if I select the image I want my background bitmap to change colour, but I still have the white space displayed with the thumbnail image and it looks rubbish.

I want the white space to be the same colour as the background so transparency would be best but how do I do this?

Do I have to set some flags when createing the image list and also on the Draw code. At the moment my code looks like:

// Create the list
Parent->m_ImageListThumb->Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1 );

// draw the image
Parent->m_ImageListThumb->Draw(&dc, pCurrentImage->whereInTheCImageList, CPoint(Rect.left+4,Rect.top+4), ILD_NORMAL);

So how do I do this?

regards,

Gordon.
jeffreygAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZoppoCommented:
Hi jeffreyg,


this should do it:

1. Create the Imagelist with ILC_MASK flag, i.e.
Parent->m_ImageListThumb->Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24 | ILC_MASK, 0, 1 );

2. When adding images to the list you need to specify the mask-color (i.e. RGB( 255, 255, 255 ) if you want the white parts of your image to be transparent)
Another possibility is to create a mask image manually (i.e. needed if you don't want each white pixel to be transparent) .

3. Use ILD_TRANSPARENT in call to CImageList::Draw() instead of ILD_NORMAL


Hope that helps,

ZOPPO
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.