Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
677 views
in Technique[技术] by (71.8m points)

c++ - Is it possible to create a CImageList with alpha blending transparency?

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));
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...