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. How do save a screen to a bitmap

How do save a screen to a bitmap

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsquestion
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.
  • B Offline
    B Offline
    bkphat
    wrote on last edited by
    #1

    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

    R U T 3 Replies Last reply
    0
    • B bkphat

      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

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      See CMetaFileDC[^]. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      1 Reply Last reply
      0
      • B bkphat

        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

        U Offline
        U Offline
        ucc801
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • B bkphat

          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

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          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

          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