WebView.CapturePreviewToStreamAsync(IRandomAccessStream) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
public:
virtual IAsyncAction ^ CapturePreviewToStreamAsync(IRandomAccessStream ^ stream) = CapturePreviewToStreamAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncAction CapturePreviewToStreamAsync(IRandomAccessStream const& stream);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncAction CapturePreviewToStreamAsync(IRandomAccessStream stream);
function capturePreviewToStreamAsync(stream)
Public Function CapturePreviewToStreamAsync (stream As IRandomAccessStream) As IAsyncAction
参数
- stream
- IRandomAccessStream
要向其写入映像的流。
返回
等待捕获操作的异步操作。
- 属性
示例
此示例演示如何使用此方法创建当前内容的缩略图。 有关完整示例,请参阅 WebView 控件示例。
private async void bookmarkBtn_Click(object sender, RoutedEventArgs e)
{
InMemoryRandomAccessStream ms = new InMemoryRandomAccessStream();
await webView8.CapturePreviewToStreamAsync(ms);
// Create a small thumbnail.
int longlength = 180, width = 0, height = 0;
double srcwidth = webView8.ActualWidth, srcheight = webView8.ActualHeight;
double factor = srcwidth / srcheight;
if (factor < 1)
{
height = longlength;
width = (int)(longlength * factor);
}
else
{
width = longlength;
height = (int)(longlength / factor);
}
BitmapSource small = await resize(width, height, ms);
BookmarkItem item = new BookmarkItem();
item.Title = webView8.DocumentTitle;
item.PageUrl = webView8.Source;
item.Preview = small;
bookmarks.Add(item);
}