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