i have a web-browser control, through this i am able to navigate diffrent sites. how to take the bitmap of the site 开发者_运维百科we visit.
Thanks GrabIt
- Get the Rectangle occupied by the browser control
- Create a DC for the screen: screen=GetDC(NULL)
- Create a compatible DC: memDC=CreateCompatibleDC(screen)
- Create a compatible bitmap: bmp=CreateCompatibleBitmap(screen, rect);
- select the compatible bitmap into the compatible DC SelectObject(memDC, bmp)
- BitBlt from the screenDC to the compatible DC
The bitmap you created should now contain an image of that area of the screen.
Something like this will work -
Bitmap bitmap = new Bitmap(webBrowser1.Width, webBrowser1.Height);
Graphics g = Graphics.FromImage(bitmap);
g.CopyFromScreen(webBrowser1.PointToScreen(webBrowser1.Location), new Point(), webBrowser1.Size);
bitmap.Save(@"c:\\browser.jpg", ImageFormat.Jpeg);
bitmap.Dispose();
精彩评论