|
-
Nov 15th, 2010, 04:40 PM
#1
Thread Starter
Addicted Member
Coordination Screenshot
The following code takes a picture automatically when you click the button
Code:
Public Class Form1
Private Sub ConstructFromResourceSaveAsGif(ByVal e As PaintEventArgs)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bounds As Rectangle
Dim screenshot As System.Drawing.Bitmap
Dim graph As Graphics
bounds = Screen.PrimaryScreen.Bounds
screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy) PictureBox1.Image = screenshot
End Sub
End Class
The next part is responsible for Coordination image (where to where this photograph) So I want to take the Coordination from Form2, how I can do this?
Code:
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
-
Nov 15th, 2010, 08:52 PM
#2
Re: Coordination Screenshot
I think you mean "coordinates" rather than "coordination". If so then you need to use the Bounds property of Form2 rather than of Screen.PrimaryScreen.
-
Nov 16th, 2010, 07:16 AM
#3
Thread Starter
Addicted Member
Re: Coordination Screenshot
yes,like hare in the video:
http://www.youtube.com/watch?v=SLJiSG5aQ3g
(5:20 - 5:50 mins)
u can give me example?
-
Nov 16th, 2010, 02:00 PM
#4
Thread Starter
Addicted Member
Re: Coordination Screenshot
-
Nov 16th, 2010, 05:58 PM
#5
Re: Coordination Screenshot
I already told you what you need to do: use the Bounds property of the form. What exactly is the problem?
-
Nov 16th, 2010, 09:29 PM
#6
Thread Starter
Addicted Member
Re: Coordination Screenshot
want to do it in Form2, you can give me an example code?
-
Nov 16th, 2010, 09:45 PM
#7
Re: Coordination Screenshot
You've already got example code. You posted it yourself. You just need to change it as I have already suggested.
use the Bounds property of Form2 rather than of Screen.PrimaryScreen
-
Nov 17th, 2010, 07:15 AM
#8
Thread Starter
Addicted Member
Re: Coordination Screenshot
I do not understand, what is the code?
Code:
graph.CopyFromScreen(form2.X, form2.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
?
-
Nov 17th, 2010, 07:17 AM
#9
Hyperactive Member
Re: Coordination Screenshot
Did you write that code yourself? If so you should understand what jm means.
Here he means something like this I think but I didnt read your case.
Code:
Dim bounds As Rectangle = Form2.Bounds
Dim screenshot As System.Drawing.Bitmap = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
Dim Graph As Graphics= Graphics.FromImage(screenshot)
Graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
PictureBox1.Image = screenshot
Last edited by Skatebone; Nov 17th, 2010 at 07:23 AM.
Life runs on code
-
Nov 17th, 2010, 08:57 AM
#10
Thread Starter
Addicted Member
Re: Coordination Screenshot
 Originally Posted by Skatebone
Did you write that code yourself? If so you should understand what jm means.
Here he means something like this I think but I didnt read your case.
Code:
Dim bounds As Rectangle = Form2.Bounds
Dim screenshot As System.Drawing.Bitmap = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
Dim Graph As Graphics= Graphics.FromImage(screenshot)
Graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
PictureBox1.Image = screenshot
Thanks but that's not accurate, it takes all the screen and not just the part I want (I want mark it with Form2 course)
-
Nov 18th, 2010, 05:28 PM
#11
Thread Starter
Addicted Member
Re: Coordination Screenshot
-
Nov 18th, 2010, 05:42 PM
#12
Re: Coordination Screenshot
You need to use the Bounds of the form you want. That code is using the default instance of Form2 to get the Bounds. Is it the default instance that you displayed in the first place? If you don;t know what a default instance is, follow the Blog link in my signature and read my post on the subject.
-
Nov 19th, 2010, 12:33 PM
#13
Thread Starter
Addicted Member
Re: Coordination Screenshot
I do not see, you can give me a link?
-
Nov 19th, 2010, 05:49 PM
#14
Re: Coordination Screenshot
I already have.
the Blog link in my signature
-
Nov 22nd, 2010, 06:41 AM
#15
Thread Starter
Addicted Member
Re: Coordination Screenshot
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|