以网页的截屏编程 [英] Taking screenshot of a webpage programmatically
本文介绍了以网页的截屏编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何采取一个网页的sceenshot编程给出的URL作为输入?
How do take a sceenshot of a webpage programmatically given the URL as input?
这是我到现在:
// The size of the browser window when we want to take the screenshot (and the size of the resulting bitmap)
Bitmap bitmap = new Bitmap(1024, 768);
Rectangle bitmapRect = new Rectangle(0, 0, 1024, 768);
// This is a method of the WebBrowser control, and the most important part
webBrowser1.DrawToBitmap(bitmap, bitmapRect);
// Generate a thumbnail of the screenshot (optional)
System.Drawing.Image origImage = bitmap;
System.Drawing.Image origThumbnail = new Bitmap(120, 90, origImage.PixelFormat);
Graphics oGraphic = Graphics.FromImage(origThumbnail);
oGraphic.CompositingQuality = CompositingQuality.HighQuality;
oGraphic.SmoothingMode = SmoothingMode.HighQuality;
oGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
Rectangle oRectangle = new Rectangle(0, 0, 120, 90);
oGraphic.DrawImage(origImage, oRectangle);
// Save the file in PNG format
origThumbnail.Save(@"d:\Screenshot.png", ImageFormat.Png);
origImage.Dispose();
不过,这是行不通的。它只是给了我一个白色的空白图片。我缺少的是在这里吗?
But this is not working. It is only giving me a white blank picture. What am I missing here?
有没有其他办法,我能得到一个网页的截图编程?
Is there any other way I could get the screenshot of a web page programmatically?
推荐答案
我搜查,搜查,搜查,并发现它的的网页thumbnailer的 的(一个的在code项目一文)。
I searched and searched and searched and found it Webpage thumbnailer (a The Code Project article).
这篇关于以网页的截屏编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文