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);
}