love_lyn99
Member
- Joined
- Sep 2, 2022
- Messages
- 16
- Programming Experience
- Beginner
Hi, im having difficulty in getting the accurate location of the image i want to capture, how do i correct this? ive tried to manually put the X and Y number but the result was the same. (Please see Attached Image, The First Image is the whole form and the second image was the result after pressing "Capture" button). am i missing something?. i have attached the code i use for you to see.
-----------------------
VB:
Public Class Form1
Dim memoryImage As Bitmap
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox1.SendToBack()
End Sub
Private Sub CaptureScreen()
Dim s As Size = RectangleShape1.Size
memoryImage = New Bitmap(s.Width, s.Height)
Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
memoryGraphics.CopyFromScreen(RectangleShape1.Location.X, RectangleShape1.Location.Y, 0, 0, s)
memoryImage.Save("D:\Library\Pictures\Screenshot.png")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
CaptureScreen()
End Sub
End Class
-----------------------