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 to save DC's content as bitmap!

How to save DC's content as bitmap!

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphicshelptutorial
3 Posts 3 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.
  • W Offline
    W Offline
    white jungle
    wrote on last edited by
    #1

    at first, because my poor english,I wish you can understand me! If I draw some lines or pictures in a DC,How can I get the bitmap data and save it as a bitmap? thank you for your help! Don't look at me in that way!

    W R 2 Replies Last reply
    0
    • W white jungle

      at first, because my poor english,I wish you can understand me! If I draw some lines or pictures in a DC,How can I get the bitmap data and save it as a bitmap? thank you for your help! Don't look at me in that way!

      W Offline
      W Offline
      wangyiming
      wrote on last edited by
      #2

      CBitmap m_pGenBitmap = new CBitmap(); CClientDC dc(NULL); int nWidth = 128; int nHeight = 128; HDC hDCScreen = dc.GetSafeHdc(); HBITMAP hbm = ::CreateCompatibleBitmap(hDCScreen,nWidth,nHeight); if (hbm != NULL) { HDC hDCGlyphs = ::CreateCompatibleDC(hDCScreen); HBITMAP hbmOld = (HBITMAP)::SelectObject(hDCGlyphs, hbm); CDC *pDC2 = CDC::FromHandle(hDCGlyphs); CRect r(0,0,nWidth,nWidth); // your owner draw pDC2->FillRect(&r,&CBrush(RGB(0xff,0xff,0xff))); m_pFillUnit->Draw(pDC2,&r,0); // end SelectObject(hDCGlyphs, hbmOld); m_pGenBitmap->m_hObject = hbm; ::DeleteDC(hDCGlyphs); } return m_pGenBitmap;

      1 Reply Last reply
      0
      • W white jungle

        at first, because my poor english,I wish you can understand me! If I draw some lines or pictures in a DC,How can I get the bitmap data and save it as a bitmap? thank you for your help! Don't look at me in that way!

        R Offline
        R Offline
        Rickard Andersson20
        wrote on last edited by
        #3

        Check out Mike Dunns FAQ, I think it was something about that there... or see in the Bitmaps & Palettes section here on CP or Search this forum, because you're not the first who asking! :) ------------------------------------ Rickard Andersson, Suza Computing ICQ#: 50302279 I'm from the winter country SWEDEN! ------------------------------------

        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