Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

I have a handle to a window that's 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?

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

  • *Experts*
Posted

I think you'll need to create an appropriately sized Bitmap object and use the Graphics object's DrawImage method to draw the image to the Bitmap. Then use the Bitmap's Save method to write it out. It can write to various formats using the ImageFormat param (I think).

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • *Experts*
Posted

The problem there is that DrawImage only takes classes inherited

from Image (such as Bitmap) as a parameter; you can't pass a

Graphics object to DrawImage. Herein lies the problem.

 

I tried using BitBlt from the DC to the DC of a Bitmap's Graphics

object, but without luck.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...