MFC 位图某些颜色透明

来源:百度知道 编辑:UC知道 时间:2024/06/28 10:43:41
我想在MFC对话框位图上的某些颜色变透明该怎么做,例如一张图片有蓝色和绿色。。。我想让绿色变透明该怎么做。
那位能帮下谢谢。。。。如果有详细资料请传到cookie562@sina.com上

给你个函数吧,用法:
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP1);
HRGN rgn;
rgn = BitmapToRegion((HBITMAP)bmp, RGB(127, 127, 127));
SetWindowRgn(rgn, TRUE);
bmp.DeleteObject();

以下是函数
原型:
static HRGN BitmapToRegion(HBITMAP hBmp, COLORREF cTransparentColor, COLORREF cTolerance = RGB(0,0,0));
定义:
// BitmapToRegion : create a region from the "non-transparent" pixels of a bitmap
// hBmp : source bitmap
// cTransparentColor : color base for the "transparent" pixels (default is black)
// cTolerance : color tolerance for the "transparent" pixels.
// a pixel is assumed to be transparent if the value of each of its 3 components (blue, green and red) is
// greater or equal to the corresponding value in cTransparentColor and is lower or equal to the
// corresponding value in cTransparentColor + cTolerance.
HRGN CYourDlg::BitmapToRegion(HBITMAP hBmp, COLORREF cTransp