I have a transparency issue when adding a mouse pointer (Bitmap resource) onto an existing Bitmap image.
How do you set the transparent color of the bitmap image to apply?
Currently the bitmap is all white except a black outline of the mouse pointer, when I use code below with SRCAND, the middle is also transparent. If I fill the mouse pointer middle Grey then it’s ok, If I fill the outside green then how do I make this part transparent so I can have a white mouse pointer?
void CSnapScreen::ApplyMousePointer(CBitmap &m_BmpTarget, int m_width, int m_height, int mouseX, int mouseY)
{
CBitmap m_Bmp1;
if(m_Bmp1.LoadBitmap(IDB_IMG1)==0) // IDB_IMG1 is mouse cursor bitmap
{
AfxMessageBox("Load mouse pointer error");
}
int nTargetWidth = m_width;
int nTargetHeight = m_height;
int nCoordX = mouseX+4;
int nCoordY = mouseY+4;
// bitblt the source DC onto the target DC
if(targetDC.BitBlt(nCoordX, nCoordY, nTargetWidth, nTargetHeight, &sourceDC, 0, 0, SRCAND )==0) //SRCAND
{
AfxMessageBox("Error adding mouse pointer to bitmap!");
}
// re-select the original (default) bitmap so we don't leak resources
sourceDC.SelectObject(pOldSourceBmp);
// re-select the original (default) bitmap so we don't leak resources
targetDC.SelectObject(pOldTargetBmp);
Bookmarks