0
回答
极新手关于在WP8.1中截取手机屏幕截图并保存到手机相册的问题
【腾讯云】学生服务器套餐10元/月 >>>   
void saveButton_click(object sender, EventArgs args)
        {
             //截取屏幕图像
ScaleTransform trans = new ScaleTransform();
            trans.ScaleX = 1;
            trans.ScaleY = 1;
            System.Windows.Media.Imaging.WriteableBitmap we = new System.Windows.Media.Imaging.WriteableBitmap(this, trans);
            //建立文件名称
            string filename = "Image-" + DateTime.Now.ToFileTime() + ".jpeg";
            Stream stream = new MemoryStream();
            we.SaveJpeg(stream, we.PixelWidth, we.PixelHeight, 0, 100);
            //保存到相册
            MediaLibrary library = new MediaLibrary();
            //运行到该处出错
            Picture pic = library.SavePictureToCameraRoll(filename, stream);
            stream.Close();

}


这是我自己弄的代码……但是运行时总是出错,跪求大神指正。软件是在模拟器上运行,没有在实机上部署过。以下是异常详细信息:

用户代码未处理 System.InvalidOperationException   HResult=-2146233079   Message=An unexpected error has occurred.   Source=Microsoft.Xna.Framework   StackTrace:        at Microsoft.Xna.Framework.Media.MediaLibrary.SavePictureToCameraRoll(String name, Stream source)        at ink.MainPage.supersaveclick(Object sender, EventArgs args)        at Microsoft.Phone.Shell.ApplicationBarItemContainer.FireEventHandler(EventHandler handler, Object sender, EventArgs args)        at Microsoft.Phone.Shell.ApplicationBarMenuItemContainer.ClickEvent()        at Microsoft.Phone.Shell.ApplicationBar.OnCommand(UInt32 idCommand, Boolean isButton)        at Microsoft.Phone.Shell.Interop.NativeCallbackInteropWrapper.OnCommand(UInt32 idCommand, Boolean isButton)   InnerException: 





举报
009988jk
发帖于4年前 0回/108阅
顶部