GTARaja
GTARaja

Reputation: 47

VB.NET Screen Capture

Hello all i am using the below code to capture the screenshot of the black panel of my window form in visual basic 2005.

My problem is that I want the red border image to come in between and to be full.

enter image description here

My code :

    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.Format32bppRgb)  
    graph = Graphics.FromImage(screenshot)  
    graph.CopyFromScreen(618, 191, 850, 455, bounds.Size, CopyPixelOperation.SourceCopy)  
    screenshot.Save("d:\\dcap.bmp", Imaging.ImageFormat.Bmp)  `

enter image description here

Upvotes: 1

Views: 25685

Answers (1)

user3664693
user3664693

Reputation: 84

Your code works well just set the bounds to zero

 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.Format32bppRgb)
    graph = Graphics.FromImage(screenshot)
    graph.CopyFromScreen(0, 0, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
    screenshot.Save("d:\\dcap.jpg", Imaging.ImageFormat.Bmp)

Upvotes: 4

Related Questions