灰色和抖色位图函数

灰色位图函数

MFC 提供了两个函数为位图提供已禁用控件的外观。

Comparison of gray and original icon versions.

名称 描述
AfxDrawGrayBitmap 绘制灰色版本的位图。
AfxGetGrayBitmap 复制灰色版本的位图。

抖色位图函数

MFC 还提供了两个函数以将位图背景替换为抖色样式。

Comparison of dithered and original icon versions.

名称 描述
AfxDrawDitheredBitmap 绘制抖色背景位图。
AfxGetDitheredBitmap 复制抖色背景位图。

AfxDrawGrayBitmap

绘制灰色版本的位图。

void AFXAPI AfxDrawGrayBitmap(
    CDC* pDC,
    int x,
    int y,
    const CBitmap& rSrc,
    COLORREF crBackground);

参数

pDC
指向目标值 DC 的指针。

x
目标 x 坐标。

y
目标 y 坐标。

rSrc
源位图。

crBackground
新背景色(通常为灰色,如 COLOR_MENU)。

备注

使用 AfxDrawGrayBitmap 绘制的位图将具有禁用控件的外观。

Comparison of gray and original icon versions.

示例

void CDCView::DrawGrayBitmap(CDC* pDC)
{
   CBitmap bm;
   bm.LoadBitmap(IDB_BITMAP1);
   AfxDrawGrayBitmap(pDC, 10, 50, bm, GetSysColor(COLOR_MENU));
}

要求

标头:afxwin.h

AfxGetGrayBitmap

复制灰色版本的位图。

void AFXAPI AfxGetGrayBitmap(
    const CBitmap& rSrc,
    CBitmap* pDest,
    COLORREF crBackground);

参数

rSrc
源位图。

pDest
目标位图。

crBackground
新背景色(通常为灰色,如 COLOR_MENU)。

备注

使用 AfxGetGrayBitmap 复制的位图将具有禁用控件的外观。

Comparison of gray and original icon versions.

示例

CBitmap bm;
bm.LoadBitmap(IDB_BITMAP1);
CBitmap bmGray;
AfxGetGrayBitmap(bm, &bmGray, GetSysColor(COLOR_MENU));

要求

标头:afxwin.h

AfxDrawDitheredBitmap

绘制位图,并将其背景替换为递色(棋盘格)图案。

void AFXAPI AfxDrawDitheredBitmap(
    CDC* pDC,
    int x,
    int y,
    const CBitmap& rSrc,
    COLORREF cr1  ,
    COLORREF cr2);

参数

pDC
指向目标值 DC 的指针。

x
目标 x 坐标。

y
目标 y 坐标。

rSrc
源位图。

cr1
两种递色中的一种,通常为白色。

cr2
另一种递色,通常为浅灰色 (COLOR_MENU)。

备注

将源位图绘制到目标 DC,并使用两种颜色(cr1 和 cr2)的棋盘格图案替换位图的背景。 根据定义,源位图的背景指的是指位图的白色像素以及与位图左上角的像素颜色匹配的所有像素。

Comparison of dithered and original icon versions.

示例

void CDCView::DrawDitheredBitmap(CDC* pDC)
{
   CBitmap bm;
   bm.LoadBitmap(IDB_BITMAP1);
   AfxDrawDitheredBitmap(pDC, 10, 50, bm, RGB(255, 255, 255),
      GetSysColor(COLOR_BTNFACE));
}

要求

标头:afxwin.h

AfxGetDitheredBitmap

复制位图,并将其背景替换为递色(棋盘格)图案。

void AFXAPI AfxGetDitheredBitmap(
    const CBitmap& rSrc,
    CBitmap* pDest,
    COLORREF cr1  ,
    COLORREF cr2);

参数

rSrc
源位图。

pDest
目标位图。

cr1
两种递色中的一种,通常为白色。

cr2
另一种递色,通常为浅灰色 (COLOR_MENU)。

备注

将源位图复制到目标位图,并使用两种颜色(cr1 和 cr2)的棋盘格图案替换源位图的背景。 根据定义,源位图的背景指的是指位图的白色像素以及与位图左上角的像素颜色匹配的所有像素。

Comparison of dithered and original icon versions.

示例

CBitmap bm;
bm.LoadBitmap(IDB_BITMAP1);
CBitmap bmDith;
AfxGetDitheredBitmap(bm, &bmDith, RGB(255, 255, 255),
   GetSysColor(COLOR_BTNFACE));

要求

标头:afxwin.h

另请参阅

宏和全局函数