Web ベースの Silverlight 5 アプリケーションのスクリーン ショットを取得してディスクに保存したいのですが、どのような方法がありますか? 私はたくさん検索しましたが、有用なものは何も見つかりませんでした。
1118 次
1 に答える
1
これは、キャプチャしてディスクに保存するようです
捕獲
// create a WriteableBitmap
WriteableBitmap bitmap = new WriteableBitmap(
(int)this.LayoutRoot.ActualWidth,
(int)this.LayoutRoot.ActualHeight);
// render the visual element to the WriteableBitmap
bitmap.Render(this.LayoutRoot, this.transform);
// request an redraw of the bitmap
bitmap.Invalidate();
保存
private void ThumbnailClicked(object sender, MouseButtonEventArgs e)
{
// pause the capture timer
this.timer.Stop();
try
{
// locate the WriteableBitmap source for the clicked image
WriteableBitmap bitmap = ((Image)sender).Source as WriteableBitmap;
if (null == bitmap)
{
MessageBox.Show("Nothing to save");
return;
}
// prompt for a location to save it
if (this.dialog.ShowDialog() == true)
{
// the "using" block ensures the stream is cleaned up when we are finished
using (Stream stream = this.dialog.OpenFile())
{
// encode the stream
JPGUtil.EncodeJpg(bitmap, stream);
}
}
}
finally
{
// restart the capture timer
this.timer.Start();
}
}
于 2013-03-29T09:32:04.823 に答える