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. Save Bitmap from Device Context to File

Save Bitmap from Device Context to File

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphicshelp
2 Posts 2 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.
  • O Offline
    O Offline
    Okeno Palmer
    wrote on last edited by
    #1

    Greets all, I have an app that loads a monochrome bitmap and displays it in a Static Control where I later allow the user to resize the bitmap by dragging the edges of a rectangular selection box around the bitmap. Now what I want to do is to save this newly sized bitmap to file. I have tried and so far when I write the bitmap to file and later view it all I am seeing is a blank image (i.e. all white). I think the problem lies in my call to the GetDIBits() function. in the MSDN docs, it says that I have to make sure the bitmap is not currently selected into a device context. So my question is, how do I unselect the Bitmap from a Device Context?? .:. Keno .:.

    J 1 Reply Last reply
    0
    • O Okeno Palmer

      Greets all, I have an app that loads a monochrome bitmap and displays it in a Static Control where I later allow the user to resize the bitmap by dragging the edges of a rectangular selection box around the bitmap. Now what I want to do is to save this newly sized bitmap to file. I have tried and so far when I write the bitmap to file and later view it all I am seeing is a blank image (i.e. all white). I think the problem lies in my call to the GetDIBits() function. in the MSDN docs, it says that I have to make sure the bitmap is not currently selected into a device context. So my question is, how do I unselect the Bitmap from a Device Context?? .:. Keno .:.

      J Offline
      J Offline
      Johann Gerell
      wrote on last edited by
      #2

      Re-select the default one.

      old bitmap = dc.SelectObject(new bitmap)
      dc.DoSomeStuff()
      dc.SelectObject(old bitmap)

      -- Dad, how strange it is that the pig can speak.
      *thoughtful pause* It must have lost its "oink".
      (my 3-year old daughter Moa, while watching Babe) Human beings, who are almost unique in having the ability
      to learn from the experience of others, are also remarkable
      for their apparent disinclination to do so. (Douglas Adams)

      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