Verhelst
Verhelst

Reputation: 1503

Capture image of webbrowser control

I want to capture the image of my webbrowser, or actually just a part of it.

I already achieved it, but it just takes a screenshot of it instead of capturing the bitmap itself.

So when i use this technique and you drag another window above it, the window is also captured. (this is what I don't want.)

My code:

' 1. Get the WebBrowsers bitmap.

    Dim bmp As New Bitmap(WebBrowser1.Width, WebBrowser1.Height)
    Dim BMPEndResult As Bitmap
    Dim graph As Graphics = Graphics.FromImage(bmp)
    Dim p As Point = Me.PointToScreen(WebBrowser1.Location)
    graph.CopyFromScreen(p.X, p.Y, 0, 0, bmp.Size)
    picDest.Image = bmp

So I need to get the image of the webbrowser:

 - without the scrollbars if possible
 - Even if the window is minimized or in the task bar
 - Full webbrowser
 - and also if possible just a part of it, where I can specify the top, left, width and height

Upvotes: 0

Views: 4714

Answers (1)

Sam Axe
Sam Axe

Reputation: 33738

WebBrowser.DrawToBitmap(bitmap, rectangle)

Upvotes: 1

Related Questions