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