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. HDC to BitBlt (Visual C)

HDC to BitBlt (Visual C)

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
4 Posts 4 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
    marqua
    wrote on last edited by
    #1

    How can I get the HDC from CBitmap or HBITMAP in Visual C??? I need to use BitBlt: BOOL BitBlt( HDC hdcDest, // handle to destination DC int nXDest, // x-coord of destination upper-left corner int nYDest, // y-coord of destination upper-left corner int nWidth, // width of destination rectangle int nHeight, // height of destination rectangle HDC hdcSrc, // handle to source DC int nXSrc, // x-coordinate of source upper-left corner int nYSrc, // y-coordinate of source upper-left corner DWORD dwRop // raster operation code ); but I don't know how to get the HDC from a CBitmap or a HBITMAP from BMP files. Tkz MarQua

    A M 2 Replies Last reply
    0
    • M marqua

      How can I get the HDC from CBitmap or HBITMAP in Visual C??? I need to use BitBlt: BOOL BitBlt( HDC hdcDest, // handle to destination DC int nXDest, // x-coord of destination upper-left corner int nYDest, // y-coord of destination upper-left corner int nWidth, // width of destination rectangle int nHeight, // height of destination rectangle HDC hdcSrc, // handle to source DC int nXSrc, // x-coordinate of source upper-left corner int nYSrc, // y-coordinate of source upper-left corner DWORD dwRop // raster operation code ); but I don't know how to get the HDC from a CBitmap or a HBITMAP from BMP files. Tkz MarQua

      A Offline
      A Offline
      Antony M Kancidrowski
      wrote on last edited by
      #2

      HDC does not come from the CBitmap or HBITMAP. If you want to get the HDC for a window do something like below:

      CDC* pDC = GetDC();
      HDC hdc = pDC->GetSafeHDC();

      :
      // Do something here
      :

      ReleaseDC(pDC);

      Ant. I'm hard, yet soft.
      I'm coloured, yet clear.
      I'm fruity and sweet.
      I'm jelly, what am I? Muse on it further, I shall return!
      - David Williams (Little Britain)

      1 Reply Last reply
      0
      • M marqua

        How can I get the HDC from CBitmap or HBITMAP in Visual C??? I need to use BitBlt: BOOL BitBlt( HDC hdcDest, // handle to destination DC int nXDest, // x-coord of destination upper-left corner int nYDest, // y-coord of destination upper-left corner int nWidth, // width of destination rectangle int nHeight, // height of destination rectangle HDC hdcSrc, // handle to source DC int nXSrc, // x-coordinate of source upper-left corner int nYSrc, // y-coordinate of source upper-left corner DWORD dwRop // raster operation code ); but I don't know how to get the HDC from a CBitmap or a HBITMAP from BMP files. Tkz MarQua

        M Offline
        M Offline
        mahade1
        wrote on last edited by
        #3

        I think this should do the trick.... CDC dcMem; CPaintDC dc(this); //create a compatible dc dcMem.CreateCompatibleDC(&dc); // Select the bitmap into the in-memory DC dcMem.SelectObject(CBitmap::FromHandle(m_hBitmap)); dcMem.DeleteDC(); Then in Bitblt u can use dcMem.m_hDC

        R 1 Reply Last reply
        0
        • M mahade1

          I think this should do the trick.... CDC dcMem; CPaintDC dc(this); //create a compatible dc dcMem.CreateCompatibleDC(&dc); // Select the bitmap into the in-memory DC dcMem.SelectObject(CBitmap::FromHandle(m_hBitmap)); dcMem.DeleteDC(); Then in Bitblt u can use dcMem.m_hDC

          R Offline
          R Offline
          Ryan Binns
          wrote on last edited by
          #4

          mahade1 wrote: Then in Bitblt u can use dcMem.m_hDC Only before the dcMem.DeleteDC() line...

          Ryan

          "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

          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