WPF: WebBrowser TO Bitmap

            var topLeftCorner = webBrowser.PointToScreen(new System.Windows.Point(0, 0)); 
            var topLeftGdiPoint = new System.Drawing.Point((int)topLeftCorner.X, (int)topLeftCorner.Y);
            var size = new System.Drawing.Size((int)webBrowser.ActualWidth, (int)webBrowser.ActualHeight);
            var screenShot = new Drawing.Bitmap((int)webBrowser.ActualWidth, (int)webBrowser.ActualHeight); 
            using (var graphics = Drawing.Graphics.FromImage(screenShot)) { graphics.CopyFromScreen(topLeftGdiPoint, new System.Drawing.Point(), size, Drawing.CopyPixelOperation.SourceCopy); } 
            screenShot.Save(@"D:\screenshot.bmp");

posted on 2011-04-08 09:56  Y#  阅读(408)  评论(0编辑  收藏  举报

导航