Capture area of Form
Capture area of Form
Capture area of Form
Capture area of Form
Capture area of Form
Capture area of Form Capture area of Form Capture area of Form Capture area of Form Capture area of Form Capture area of Form Capture area of Form
Capture area of Form Capture area of Form
Capture area of Form
Graphics and Multimedia Topics include: GDI+, drawing 2D/3D, printing and Managed DirectX and the XNA Framework

Enjoy an ad free experience by logging in. Not a member yet? Register.
Go Back  Xtreme .NET Talk > > > Capture area of Form


Reply
 
Thread Tools Display Modes
  #1  
Old 09-06-2015, 01:44 PM
Amerigo Amerigo is offline
Newcomer
 
Join Date: Jul 2012
Posts: 7
Amerigo is on a distinguished road
Default Capture area of Form



the following code is getting an image of the correct size, but it's not in the correct position. It is using the position of the screen rather than the control on the application. How do I correct this?
Code:
        Dim img As New Bitmap(Panel1.Right - Panel1.Left, Panel1.Bottom - Panel1.Top)
        Dim gr As Graphics = Graphics.FromImage(img)
        gr.CopyFromScreen(New Point(Panel1.Left, Panel1.Top), Point.Empty, img.Size)
        'save image + launch in default viewer
        img.Save("test.png", Drawing.Imaging.ImageFormat.Png)
        Process.Start("test.png")
Reply With Quote
  #2  
Old 09-06-2015, 06:39 PM
PlausiblyDamp's Avatar
PlausiblyDampCapture area of Form PlausiblyDamp is offline
Ultimate Contributor

Preferred language:
C#, VB
 
Join Date: Sep 2002
Location: Lancashire, UK
Posts: 6,487
PlausiblyDamp is on a distinguished road
Default Re: Capture area of Form

The bit of code
Code:
gr.CopyFromScreen(...)
is using screen coordinates (as the name implies), you would need to figure out the actual screen coordinates of the panel.

Depending on the version of .Net you are using https://msdn.microsoft.com/en-us/lib...ttoscreen.aspx might be worth a look.
__________________
Posting Guidelines FAQ Post Formatting

Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein
Reply With Quote
Reply

Bookmarks

Tags
correct, image, panel1.top, dim, position, graphics, panel1.bottom, bitmappanel1.right, panel1.left, graphics.fromimageimg, point.empty, viewer, img.savetest.png, process.starttest.png, default, launch, pointpanel1.left, img.size, save, gr.copyfromscreennew, size, form, code, capture, application

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Capture application process Form inside an MDI. AlexCode Windows Forms 2 02-20-2005 02:03 PM
Capture a form rectangle to bmp... AlexCode Graphics and Multimedia 3 07-17-2004 07:13 AM
Using GDI+, how would I copy a specific area of a form and put into a picturebox? Knight Chat X Graphics and Multimedia 0 03-31-2004 02:19 AM
MDI Form BackColor (Client Area) Mikecrosoft Graphics and Multimedia 2 12-06-2003 04:50 AM
updating client area shankar Graphics and Multimedia 2 12-16-2002 03:44 AM

Advertisement:







Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Capture area of Form
Capture area of Form
Capture area of Form Capture area of Form
Capture area of Form
Capture area of Form
Capture area of Form Capture area of Form Capture area of Form Capture area of Form Capture area of Form Capture area of Form Capture area of Form
Capture area of Form
Capture area of Form
 
Capture area of Form
Capture area of Form