首页 > 代码库 > Windows Phone截取当前屏幕保存图像的代码
Windows Phone截取当前屏幕保存图像的代码
导入以下命名空间:
using System.Windows.Media.Imaging;using System.IO;using Microsoft.Xna.Framework.Media;
全部代码如下:
public void CaptureScreen(object sender, EventArgs e){ WriteableBitmap bmp = new WriteableBitmap(480, 800); bmp.Render(App.Current.RootVisual, null); bmp.Invalidate(); MemoryStream stream = new MemoryStream(); bmp.SaveJpeg(stream, bmp.PixelWidth, bmp.PixelHeight, 0, 80); stream.Seek(0, SeekOrigin.Begin); MediaLibrary library = new MediaLibrary(); string fileName = "ScreenShot_" + DateTime.Now.ToString("yyyy-mm-dd_hh:mm:ss"); library.SavePicture(fileName, stream); stream.Close(); Dispatcher.BeginInvoke(() => { PictureCollection picCollection = library.Pictures; foreach (Picture item in picCollection) { if (item != null) { BitmapImage bitmap = new BitmapImage(); bitmap.SetSource(item.GetImage()); } } });}
转自:http://terryblog.blog.51cto.com/1764499/551752/
Windows Phone截取当前屏幕保存图像的代码
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。