Saving a DC

Bucky

Well-known member
Joined
Dec 23, 2001
Messages
791
Location
East Coast
User Rank
*Expert*
I have a handle to a window thats been drawn on by various
Windows APIs. I can create a Graphics object and paint to it fine.

How can I save the contents of the Graphics object (or directly
from the hDC, if that makes a difference) to a file?
 
I think youll need to create an appropriately sized Bitmap object and use the Graphics objects DrawImage method to draw the image to the Bitmap. Then use the Bitmaps Save method to write it out. It can write to various formats using the ImageFormat param (I think).

-Nerseus
 
The problem there is that DrawImage only takes classes inherited
from Image (such as Bitmap) as a parameter; you cant pass a
Graphics object to DrawImage. Herein lies the problem.

I tried using BitBlt from the DC to the DC of a Bitmaps Graphics
object, but without luck.
 
Data on a DC isnt strictly saved anywhere, its often just drawn straight on to screen memory when needed. If bltting from the DC didnt work I dont know what to suggest.
 
Back
Top