CImagelist and CListCtrl problem.
-
I'm trying to load a bitmap into a imagelist, and to get a transparent background. The imagelist is used in a CListCtrl. When I load the bitmap directly I get transparent images, but wrong colors. m_ilReport.Create(IDB_TOOLBAR_GRID256, 16, 1, RGB(255,0,255)); If I load it into a CBitmap first the colors look ok, the problem is that the mask color is replaced with black. SetBkColor seems to have no affect. I've tried with regular colors too. m_ilReport.Create(16, 16, ILC_COLOR8, 16, 1); CBitmap bmp; bmp.LoadBitmap(IDB_TOOLBAR_GRID256); m_ilReport.Add(&bmp, RGB(255, 0, 255)); m_ilReport.SetBkColor(CLR_NONE); ctl.SetImageList(&m_ilReport); What have I done wrong?
-
I'm trying to load a bitmap into a imagelist, and to get a transparent background. The imagelist is used in a CListCtrl. When I load the bitmap directly I get transparent images, but wrong colors. m_ilReport.Create(IDB_TOOLBAR_GRID256, 16, 1, RGB(255,0,255)); If I load it into a CBitmap first the colors look ok, the problem is that the mask color is replaced with black. SetBkColor seems to have no affect. I've tried with regular colors too. m_ilReport.Create(16, 16, ILC_COLOR8, 16, 1); CBitmap bmp; bmp.LoadBitmap(IDB_TOOLBAR_GRID256); m_ilReport.Add(&bmp, RGB(255, 0, 255)); m_ilReport.SetBkColor(CLR_NONE); ctl.SetImageList(&m_ilReport); What have I done wrong?
You are setting the transparency colour to be the bright pink that has RGB(255,0,255). It's what I do in my code, as it's not a colour I use normally in the actual bitmap. Snip of code that works for me:
m_ImageList.Create(IDB_ALARMBANNER ,16,32,RGB(255,0,255)); m_nImageIndex[IMAGE_ALARMBANNER] = nImageIndex++; //array used to reference the image AddBitmapToList(m_ImageList,IDB_ALARMCLIENT,IMAGE_ALARMCLIENT,nImageIndex++); void CMainDialog::AddBitmapToList(CImageList& ImageList, UINT nId, UINT nImageId, UINT nImageIndex) { CBitmap bm; bm.LoadBitmap(nId); ImageList.Add(&bm, RGB(255,0,255)); //set transparency colour m_nImageIndex[nImageId] = nImageIndex; }
Debbie -
You are setting the transparency colour to be the bright pink that has RGB(255,0,255). It's what I do in my code, as it's not a colour I use normally in the actual bitmap. Snip of code that works for me:
m_ImageList.Create(IDB_ALARMBANNER ,16,32,RGB(255,0,255)); m_nImageIndex[IMAGE_ALARMBANNER] = nImageIndex++; //array used to reference the image AddBitmapToList(m_ImageList,IDB_ALARMCLIENT,IMAGE_ALARMCLIENT,nImageIndex++); void CMainDialog::AddBitmapToList(CImageList& ImageList, UINT nId, UINT nImageId, UINT nImageIndex) { CBitmap bm; bm.LoadBitmap(nId); ImageList.Add(&bm, RGB(255,0,255)); //set transparency colour m_nImageIndex[nImageId] = nImageIndex; }
Debbiethanks. But that doesnt help me. I want to know why it doesnt work. Why do the colors look fuckedup if I use the same overloaded version of create as you do? (The one where u specify the mask color) Why do the mask become black when I first load the bmp into a CBitmap and then load the CBitmap into the imagelist?