Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Creating circular background image with transparency

Creating circular background image with transparency

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mac
    wrote on last edited by
    #1

    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);

    F 1 Reply Last reply
    0
    • M Mac

      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);

      F Offline
      F Offline
      Feng Yuan
      wrote on last edited by
      #2

      How can you select a region into a DC ? Region can only be selected as clipping region, meta region, or used in PaintRgn directly.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups