我想从基于Web的Silverlight 5应用程序中截取屏幕截图并将其保存在磁盘上,我有哪些选择?我搜索了很多,但没有发现任何有用的东西。
答案 0 :(得分:1)
This似乎捕获并将其保存到磁盘
<强>捕获强>
// 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();
}
}