CImage::TransparentBlt
将源设备上下文的位图到此当前设备上下文。
BOOL TransparentBlt(
HDC hDestDC,
int xDest,
int yDest,
int nDestWidth,
int nDestHeight,
UINT crTransparent = CLR_INVALID
) const throw( );
BOOL TransparentBlt(
HDC hDestDC,
const RECT& rectDest,
UINT crTransparent = CLR_INVALID
) const throw( );
BOOL TransparentBlt(
HDC hDestDC,
int xDest,
int yDest,
int nDestWidth,
int nDestHeight,
int xSrc,
int ySrc,
int nSrcWidth,
int nSrcHeight,
UINT crTransparent = CLR_INVALID
) const throw( );
BOOL TransparentBlt(
HDC hDestDC,
const RECT& rectDest,
const RECT& rectSrc,
UINT crTransparent = CLR_INVALID
) const throw( );
参数
hDestDC
对目标设备上下文的句柄。xDest
x坐标,在逻辑单位,目标矩形的左上角。yDest
y坐标,在逻辑单位,目标矩形的左上角。nDestWidth
宽度,在逻辑单位,目标矩形。nDestHeight
高度,在逻辑单位,目标矩形。crTransparent
在将的源位图的颜色透明。 默认情况下,CLR_INVALID,指示当前设置的颜色,应使用图像的透明的颜色。rectDest
为 RECT 结构的引用,标识目标。xSrc
x坐标,在逻辑单位,源矩形的左上角。ySrc
y坐标,在逻辑单位,源矩形的左上角。nSrcWidth
宽度,在逻辑单位,源矩形。nSrcHeight
高度,在逻辑单位,源矩形。rectSrc
为 RECT 结构的引用,标识源。
返回值
TRUE 如果成功,则否则,FALSE。
备注
TransparentBlt 在4位和8位/像素的位图每像素支持。 使用 CImage::AlphaBlend 指定用透明度的每像素32位的位图。
此方法适用于Microsoft Windows 2000、Windows 98和更高版本的系统。 有关详细信息 Windows SDK 参见中的 TransparentBlt 和 与以前的操作系统的CImage限制。
示例
// Performs a transparent blit from the source image to the destination
// image using the images' current transparency settings
BOOL TransparentBlt(CImage* pSrcImage, CImage* pDstImage, int xDest, int yDest,
int nDestWidth, int nDestHeight)
{
HDC hDstDC = NULL;
BOOL bResult;
if(pSrcImage == NULL || pDstImage == NULL)
{
// Invalid parameter
return FALSE;
}
// Obtain a DC to the destination image
hDstDC = pDstImage->GetDC();
// Perform the blit
bResult = pSrcImage->TransparentBlt(hDstDC, xDest, yDest, nDestWidth, nDestHeight);
// Release the destination DC
pDstImage->ReleaseDC();
return bResult;
}
要求
Header: atlimage.h