导入以下命名空间:

using System.Windows.Media.Imaging;
using System.IO;

using Microsoft.Xna.Framework.Media;

全部代码如下:

1publicvoidCaptureScreen(objectsender,EventArgse)
2{
3WriteableBitmapbmp=newWriteableBitmap(480,800);
4bmp.Render(App.Current.RootVisual,null);
5bmp.Invalidate();
6
7MemoryStreamstream=newMemoryStream();
8bmp.SaveJpeg(stream,bmp.PixelWidth,bmp.PixelHeight,0,80);
9stream.Seek(0,SeekOrigin.Begin);
10
11MediaLibrarylibrary=newMediaLibrary();
12stringfileName="ScreenShot_"+DateTime.Now.ToString("yyyy-mm-dd_hh:mm:ss");
13library.SavePicture(fileName,stream);
14stream.Close();
15
16
17Dispatcher.BeginInvoke(()=>
18{
19PictureCollectionpicCollection=library.Pictures;
20foreach(PictureiteminpicCollection)
21{
22if(item!=null)
23{
24BitmapImagebitmap=newBitmapImage();
25bitmap.SetSource(item.GetImage());
26ScreenShot.Source=bitmap;
27PicName.Text="图片名称:"+item.Name;
28}
29
30}
31});
32
33
34

35 }

调用该方法后得到的效果如下:

Windows Phone 7 截取当前屏幕保存图像的代码

相关文章:

  • 2021-12-02
  • 2021-11-24
  • 2021-12-10
  • 2021-12-20
  • 2021-09-06
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
猜你喜欢
  • 2021-06-06
  • 2021-06-23
  • 2021-11-18
  • 2021-06-22
  • 2022-12-23
相关资源
相似解决方案