mfcimagelist

CImageList is changing colours when I load it from the application resources


I am colour blind so I could be barking up the wrong tree here.

This is a BMP file that I am using for a CImageList:

BITMAP image

It looks colourful to me, albeit small. This is what it looks like in VS 2019 Editor:

BITMAP image in VS 2019 Editor

To me, they look the same. This is how I am creating my CImageList object:

m_imgList.Create(IDB_BMP_DIGITAL_MEDIA_LIST, 16, 10, 0x0000FF00);

This then gets passed into the CListCtrl to be used. Now, when I run my application:

BITMAP in Dialog

The colouring is no longer the same? The BMP file is 24 bit.

How do I stop this?


Solution

  • This is how to do it:

    // Create the full-color image list
    m_imgList.Create(16, 16, ILC_MASK | ILC_COLOR24, 0, 0);
    
    // Load the full-color bitmap
    CBitmap bmp;
    bmp.LoadBitmap(IDB_BMP_DIGITAL_MEDIA_LIST);
    
    // Add the bitmap into the image list
    m_imgList.Add(&bmp, 0x0000FF00);
    

    Results:

    Results