1

这是我的代码。

MediaLibrary myMediaLibrary = new MediaLibrary();
Uri myUri = new Uri(@"Images/Jellyfish.jpg", UriKind.Relative);
System.IO.Stream photoStream = App.GetResourceStream(myUri).Stream;
byte[] buffer = new byte[photoStream.Length];
photoStream.Read(buffer, 0, Convert.ToInt32(photoStream.Length));
myMediaLibrary.SavePicture("Jellyfish.jpg", buffer);

在模拟器上,一切都被保存了。但在设备上显示错误“发生意外错误”。

4

1 回答 1

0

直接保存您的流不起作用?

MediaLibrary myMediaLibrary = new MediaLibrary();
Uri myUri = new Uri(@"Images/Jellyfish.jpg", UriKind.Relative);
System.IO.Stream photoStream = App.GetResourceStream(myUri).Stream;
myMediaLibrary.SavePicture("Jellyfish.jpg", photoStream);

或者,您可以使用WriteableBitmap并将其保存到Stream,然后使用MediaLibray.

wr.SaveJpeg(FileStream, wr.PixelWidth, wr.PixelHeight, 0, 85);
于 2014-06-07T14:44:49.590 回答