Groups | Blog | Home
all groups > dotnet sdk > june 2006 >

dotnet sdk : Graphics -> Bitmap


David Thielen
6/25/2006 9:34:02 PM
Hi;

If I have a Graphics object and want to get a Bitmap object that is what is
drawn in the Graphics object - how do I do that?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
v-phuang NO[at]SPAM online.microsoft.com (
6/26/2006 12:00:00 AM
Hi

I think we need to create a graphics from the Bitmap, so the following
drawing will be on the Bitmap.
Create from an Image Object
http://msdn2.microsoft.com/en-us/library/5y289054.aspx

If you means an existing graphics, I think you have to P/Invoke the BitBlt
GDI function.
Here is a link for your reference.

Screen Capturing a Form in .NET - Using GDI and GDI+
http://www.c-sharpcorner.com/Graphics/ScreenCaptFormMG.asp


Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
David Thielen
6/26/2006 8:59:02 AM
That's what I was afraid of - thanks. (I dislike P-Invoke because we're all
supposed to be 100% managed code.)

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



[quoted text, click to view]
David Thielen
6/26/2006 10:41:02 AM
It's from a J# (not .NET) Graphics2D object. The only way to get the bitmap
is it will give me a .NET Graphics object.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



[quoted text, click to view]
Ben Voigt
6/26/2006 12:34:15 PM
[quoted text, click to view]

Don't know why you'd need P/Invoke here. Do you know where the Graphics
object came from? If it's from an exposed window onscreen, use the
CopyFromScreen method to get it into a Bitmap. If it's from another Image
(Bitmap/Icon/Metafile, etc) you can use that Image directly or use
DrawImage. If the Graphics object is to an obscured window (another window
overlaps it) or a DirectX surface, then BitBlt isn't going to get you the
data either, because it isn't in any GDI buffer.

[quoted text, click to view]

AddThis Social Bookmark Button