我正在尝试将应用程序主页中名为 image1 的图像控件中的图像保存到手机的媒体库这是我的代码,但在 WriteableBitmap wr = image1; 它给了我一个错误。
public void SaveImageTo(string fileName = "Gage.jpg")
{
fileName += ".jpg";
var myStore = IsolatedStorageFile.GetUserStoreForApplication();
if (myStore.FileExists(fileName))
{
myStore.DeleteFile(fileName);
}
IsolatedStorageFileStream myFileStream = myStore.CreateFile(fileName);
WriteableBitmap wr = image1; // give the image source
wr.SaveJpeg(myFileStream, wr.PixelWidth, wr.PixelHeight, 0, 85);
myFileStream.Close();
// Create a new stream from isolated storage, and save the JPEG file to the media library on Windows Phone.
myFileStream = myStore.OpenFile(fileName, FileMode.Open, FileAccess.Read);
MediaLibrary library = new MediaLibrary();
//byte[] buffer = ToByteArray(qrImage);
library.SavePicture(fileName, myFileStream); }