0

无论如何要获取 WP8 中 WebBrowser 控件元素中显示的当前内容的屏幕截图?文档说 WebBrowser 控件元素与手机上的 Internet Explorer 使用的相同,并且 IE 具有“选项卡”视图,您可以在其中查看上次访问的页面和包含这些页面内容的小图片。

4

2 回答 2

0

尝试这个

  UIElement scrollContent = (UIElement)this.LayoutRoot;
            bmpCurrentScreenImage.Render(LayoutRoot, new MatrixTransform());
            bmpCurrentScreenImage.Invalidate();


            SaveToMediaLibrary(bmpCurrentScreenImage, fileName, 100);


public void SaveToMediaLibrary(WriteableBitmap bitmap, string name, int quality)
        {
            using (var stream = new MemoryStream())
            {
                // Save the picture to the Windows Phone media library.
                bitmap.SaveJpeg(stream, bitmap.PixelWidth, bitmap.PixelHeight, 0, quality);
                stream.Seek(0, SeekOrigin.Begin);
                     IsolatedStorageFileStream fileStream = _storageFile.CreateFile("folderName" + fileName);
            BitmapImage bitmap = new BitmapImage();
            bitmap.SetSource(imageStream);

            WriteableBitmap wb = new WriteableBitmap(bitmap);
            wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, orientation, quality);
            fileStream.Close();
               // new MediaLibrary().SavePicture(name, stream);
            }
        }

这会将浏览器内容保存到独立存储中的图像文件中

于 2014-06-04T08:00:38.427 回答
0

我没有找到这个问题的解决方案(webBrowser 的屏幕截图)。

但是,您有一个临时解决方案可以在历史页面中显示用户调用的页面以供示例......

调用网页时,保存页面的SourceCode。并且,在您的历史记录中,将源代码添加到锁定的 WebBrowser 元素中......

用户可以看到这个历史网页...

但是,这种方法有两个问题(因为它只是“临时方法”):

首先是如果当您在 webbrowser 中显示源代码时,重新加载,元素(并使用数据连接)与图像,没有使用数据连接......

其次,如果您及时保存页面 web 的源代码 X,您还保存了网页的 video/images/css/js 上的路径。

而且,可能在Y 时间,网页内容已修改,无法重新加载图像...源代码已过时...

于 2013-06-07T08:19:41.377 回答