Creating circular background image with transparency
-
Hi, I am trying to display a circular image as a background with the transparency. The programs work if I use a mask image with the following operations //draw BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Image, 0, 0, SRCINVERT); BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Mask, 0, 0, SRCAND); BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Image, 0, 0, SRCINVERT); where m_Image is the DC of the window and m_Mask is the mask dc. I try to do the same thing using Region but it don't works. Can anyone helps? Thanks The code is like //create th region HBRUSH hBrush = CreateSolidBrush(RGB(0,0,0)); HBRUSH hOldBrush; hRegion = CreateEllipticRgn(xPos, yPos, xPos + Width - 1, yPos + Height - 1); hOldBrush = (HBRUSH)SelectObject(hDC, hBrush); if(FillRgn(hDC, hRegion, hBrush)) DeleteObject(hBrush); m_bUseRegion = true; SelectObject(hDC, hOldBrush); DeleteObject(hBrush); // create the mask dc m_Mask = CreateCompatibleDC(hDC); SelectObject(m_Mask, hRegion); DeleteObject(hRegion); //draw BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Image, 0, 0, SRCINVERT); BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Mask, 0, 0, SRCAND); BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Image, 0, 0, SRCINVERT);
-
Hi, I am trying to display a circular image as a background with the transparency. The programs work if I use a mask image with the following operations //draw BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Image, 0, 0, SRCINVERT); BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Mask, 0, 0, SRCAND); BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Image, 0, 0, SRCINVERT); where m_Image is the DC of the window and m_Mask is the mask dc. I try to do the same thing using Region but it don't works. Can anyone helps? Thanks The code is like //create th region HBRUSH hBrush = CreateSolidBrush(RGB(0,0,0)); HBRUSH hOldBrush; hRegion = CreateEllipticRgn(xPos, yPos, xPos + Width - 1, yPos + Height - 1); hOldBrush = (HBRUSH)SelectObject(hDC, hBrush); if(FillRgn(hDC, hRegion, hBrush)) DeleteObject(hBrush); m_bUseRegion = true; SelectObject(hDC, hOldBrush); DeleteObject(hBrush); // create the mask dc m_Mask = CreateCompatibleDC(hDC); SelectObject(m_Mask, hRegion); DeleteObject(hRegion); //draw BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Image, 0, 0, SRCINVERT); BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Mask, 0, 0, SRCAND); BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Image, 0, 0, SRCINVERT);