开发者

How to get the Bitmap

开发者 https://www.devze.com 2022-12-09 16:04 出处:网络
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.

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


  1. Get the Rectangle occupied by the browser control
  2. Create a DC for the screen: screen=GetDC(NULL)
  3. Create a compatible DC: memDC=CreateCompatibleDC(screen)
  4. Create a compatible bitmap: bmp=CreateCompatibleBitmap(screen, rect);
  5. select the compatible bitmap into the compatible DC SelectObject(memDC, bmp)
  6. 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();
0

精彩评论

暂无评论...
验证码 换一张
取 消