How do save a screen to a bitmap
-
I have created an SDI app and have drawn certain things on to the main window (lines, rectangels etc..). I would now like ot take that data, scale it down, and save it in a bitmap file. Is there a convenient way to simply take whatever the Redraw function does and make it draw the same thing on to a bitmap? -bk
-
I have created an SDI app and have drawn certain things on to the main window (lines, rectangels etc..). I would now like ot take that data, scale it down, and save it in a bitmap file. Is there a convenient way to simply take whatever the Redraw function does and make it draw the same thing on to a bitmap? -bk
See
CMetaFileDC
[^]. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com -
I have created an SDI app and have drawn certain things on to the main window (lines, rectangels etc..). I would now like ot take that data, scale it down, and save it in a bitmap file. Is there a convenient way to simply take whatever the Redraw function does and make it draw the same thing on to a bitmap? -bk
You need to create a memory bitmap at first and then drawing it on this memory bitmap,when finished,please convert CBitmap to bitmap file,I think the following sample codes to be useful to you (You cann't build it,it is only a sample): BOOL CMyCanvasCore::DoDrawImage(CImage* pImage, CDC* pDC) { BOOL bSuccess = FALSE; CDC dcMem; CBitmap bmp; CDC dcScreen; dcScreen.Attach(::GetDC(0)); if (pDC == NULL) { pDC = &dcScreen; } dcMem.CreateCompatibleDC(pDC); CRect rcVirtual(GetVirtualOrigin(), GetVirtualSize()); CSize szBitmap(rcVirtual.Width(), rcVirtual.Height()); PrepareDrawDC(pDC, FALSE); pDC->LPtoDP(&szBitmap); BOOL bBmpCreated = bmp.CreateCompatibleBitmap(pDC, szBitmap.cx, szBitmap.cy); if (bBmpCreated) { dcMem.SelectObject(&bmp); const CPoint ptOldLogOrg = GetLogOrigin(); CRect rcMargins; GetMargins(rcMargins); CSize szMargins(rcMargins.left, rcMargins.top); FODPtoLP(&szMargins); CPoint ptTopLeft(GetVirtualOrigin()); ptTopLeft.x += szMargins.cx; ptTopLeft.y += szMargins.cy; SetLogOrigin(ptTopLeft.x, ptTopLeft.y); PrepareDrawDC(&dcMem, FALSE); // Draw background. DoDrawBackGround(&dcMem,rcVirtual); GetCurrentModel()->OnDrawShapeNormal(&dcMem); SetLogOrigin(ptOldLogOrg.x, ptOldLogOrg.y); // pImage->MakeNewBitmap(&dcMem, &bmp); bSuccess = TRUE; } dcScreen.Detach(); return bSuccess; } Jack --------------------------------------------------------------------------------- XD++ MFC/C++ Flow/Diagram Library -- http://www.ucancode.net
-
I have created an SDI app and have drawn certain things on to the main window (lines, rectangels etc..). I would now like ot take that data, scale it down, and save it in a bitmap file. Is there a convenient way to simply take whatever the Redraw function does and make it draw the same thing on to a bitmap? -bk
http://www.codeproject.com/cpp/painter_program.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta