如何在VC中显示透明背景位图
来源:互联网 发布:用u盘安装linux 编辑:程序博客网 时间:2024/05/17 01:37
简单的调用系统API。
Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows 98 and later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Use Msimg32.lib.
void CTransparentBltTestDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
CDialog::OnPaint();
COLORREF crMask = RGB(0x00,0x00,0xff); // Mask color of bitmap
BITMAP bm;
m_bmp.GetBitmap(&bm);
int nWidth = bm.bmWidth;
int nHeight = bm.bmHeight;
CDC ImageDC;
ImageDC.CreateCompatibleDC(&dc);
CBitmap *pOldImageBMP = ImageDC.SelectObject(&m_bmp);
::TransparentBlt(dc.m_hDC,50,40,nWidth,nHeight,ImageDC.m_hDC,0,0,nWidth,nHeight,crMask);
ImageDC.SelectObject(pOldImageBMP);
}
}
TransparentBlt
The TransparentBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.
BOOL TransparentBlt(
HDC hdcDest, // handle to destination DC
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
int nWidthDest, // width of destination rectangle
int hHeightDest, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXOriginSrc, // x-coord of source upper-left corner
int nYOriginSrc, // y-coord of source upper-left corner
int nWidthSrc, // width of source rectangle
int nHeightSrc, // height of source rectangle
UINT crTransparent // color to make transparent
);
Parameters
- hdcDest
- [in] Handle to the destination device context.
- nXOriginDest
- [in] Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
- nYOriginDest
- [in] Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
- nWidthDest
- [in] Specifies the width, in logical units, of the destination rectangle.
- hHeightDest
- [in] Handle to the height, in logical units, of the destination rectangle.
- hdcSrc
- [in] Handle to the source device context.
- nXOriginSrc
- [in] Specifies the x-coordinate, in logical units, of the source rectangle.
- nYOriginSrc
- [in] Specifies the y-coordinate, in logical units, of the source rectangle.
- nWidthSrc
- [in] Specifies the width, in logical units, of the source rectangle.
- nHeightSrc
- [in] Specifies the height, in logical units, of the source rectangle.
- crTransparent
- [in] The RGB color in the source bitmap to treat as transparent.
Return Values
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE.
Windows NT/2000/XP: To get extended error information, call GetLastError.
- 如何在VC中显示透明背景位图
- VC 位图背景透明显示
- 如何在C++ Builder中显示透明位图
- vc 透明显示位图
- 在VC中显示位图
- vc实现透明位图,透明背景
- vc实现透明位图,透明背景
- VC中如何在对话框上显示位图
- 如何在ListBox中选择背景位图
- VC中如何显示一张位图
- 使CBitmap位图对象背景透明显示
- VC对话框如何添加WM_ERASEBKGND消息(OnEraseBkgnd函数)及对话框使用位图背景并透明
- VC对话框如何添加WM_ERASEBKGND消息(OnEraseBkgnd函数)及对话框使用位图背景并透明
- VC对话框如何添加WM_ERASEBKGND消息(OnEraseBkgnd函数)及对话框使用位图背景并透明
- VC对话框如何添加WM_ERASEBKGND消息(OnEraseBkgnd函数)及对话框使用位图背景并透明
- VC中显示位图
- VC实现在ListBox中选择背景位图
- 用VC实现在TreeView中使用背景位图
- 正确处理Windows电源事件
- 3.c++-/MD、/MDd 和 /MT、/MTd
- 我要一个新的开始!
- 域名邮箱如何配置
- 解决ofbiz在myeclipse中调试运行时报错:Can't find bundle for base name cache
- 如何在VC中显示透明背景位图
- 入门开源ERP最全面的ADempiere 资料和compiere 资料全集
- 独品纹身器材
- 十年展望
- 如何在对话框单位与象素单位间进行转换
- 单调队列进阶
- 编译指示指令(#pragma)
- 常用数据结构及其应用总结
- 百度知道太牛了,和尚只在我梦里~