CImageList transparency

Posted on 2004-12-01
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,, ILD_NORMAL);

So how do I do this?


Question by:jeffreyg
    1 Comment
    LVL 30

    Accepted Solution

    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,


    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
    The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now