Capture a form rectangle to bmp...

AlexCode

Well-known member
Joined
Jul 7, 2003
Messages
931
Location
Portugal
Hi!
The subject says it all...

How can I capture part of my form, defined as a rectangle, into a bmp/jpg whatever...

Thank you very much...

Alex :p
 
here it is in C# pretty much the same in vb
C#:
bitmap = form.backgroundimage.clone();
bitmap = bitmap.clone(rectangle,bitmap.pixelformat);
bitmap.save(FileName,ImageFormat);
The Image format is a enum in System.Drawing.Imaging and can be bmp or jpg plus many others, the rectangle can be either a Rectangle or a RectangleF, the form is well a System.Windows.Forms.Form and the bitmap is well a System.Drawing.Bitmap. Good luck!
 
HI...

Thanks for the repply.

In fact, thats almost it... the problem on your idea is that I only get the background image... I need to get everything thats on the specifyed rectangle... as possible controls for example!

I was thinking about making a print screen and calculate the form position and then the rectangle position... finally use something like you told on your post...

How can I do a print screen in .net? :p

Alex :p
 
Back
Top