?
Solved

CImageList transparency

Posted on 2004-12-01
4
Medium Priority
?
471 Views
Last Modified: 2008-02-01
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.
0
Comment
Question by:jeffreyg
1 Comment
 
LVL 31

Accepted Solution

by:
Zoppo earned 500 total points
ID: 12717109
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question