6

I would like to knwo if it is possible to create a CImageList with alpha blending transparency.

Sample code that creates a CImageList with ugly transparency (no alpha blending)

CGdiPlusBitmapResource m_pBitmap;
m_pBitmap.Load(IDB_RIBBON_FILESMALL,_T("PNG"),AfxGetResourceHandle());

HBITMAP hBitmap;
m_pBitmap.m_pBitmap->GetHBITMAP(RGB(0,0,0),&hBitmap );

CImageList *pList=new CImageList;
CBitmap bm;
bm.Attach(hBitmap);
pList->Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 4);
pList->Add(&bm, RGB(255,0,255));
sorin
  • 161,544
  • 178
  • 535
  • 806

1 Answers1

5

Don't use the ILC_MASK flag (from MSDN):

Using 32 Bit Anti-Aliased Icons

Windows XP imagelists, which are collections of images used with certain controls such as list-view controls, support the use of 32-bit anti-aliased icons and bitmaps. Color values use 24 bits, and 8 bits are used as an alpha channel on the icons. To create an imagelist that can handle a 32-bits-per-pixel (bpp) image, call the ImageList_Create function passing in an ILC_COLOR32 flag.

Gutblender
  • 1,340
  • 1
  • 12
  • 25
MSN
  • 53,214
  • 7
  • 75
  • 105
  • 3
    +1. Not real clear from the post but the options are not compatible. Either mask or use a 32bpp with alpha, not both. – Hans Passant Apr 14 '10 at 21:18