背景:有两个图片,一个是目标背景图片, 一个是带有自身背景色彩的彩色图片先将这彩色图片绘制到目标背景图片中, 这一步通过BITBLT就可实现。 但实现后的效果是: 目标图片上,绘制上去的彩色图片带有其本身的背景。问题就来了, 我们想将彩色图片本身的背景去掉,应该如何解决?解决方法:使用API函数:TransparentBlt 此函数将原DC中的图片绘制到目标DC中,并同时设置原图形在目标图形上的透明色。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 );如本例中,将透明色设置为彩色图形自带背景色时, 则使用此函数后,所得最终图形上彩色图形的自身背景色就消除了。CDC* pDC=GetDC();