本文介绍了将图像保存到媒体库 WP7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法将图像保存到 Windows 手机媒体库中!这是我的代码片段:
I cant save images into windows phone media library ! Here is my code snippet :
public void SaveImageTo(string fileName)
{
fileName += ".jpg";
var myStore = IsolatedStorageFile.GetUserStoreForApplication();
if (myStore.FileExists(fileName))
{
myStore.DeleteFile(fileName);
}
IsolatedStorageFileStream myFileStream = myStore.CreateFile(fileName);
// 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();
library.SavePicture(fileName, myFileStream);
}
请给点建议!提前致谢!
Please give some suggestion !Thanks in advance !
推荐答案
试试这个 ....
public void SaveImageTo(string fileName = "ShareByQR.jpg")
{
fileName += ".jpg";
var myStore = IsolatedStorageFile.GetUserStoreForApplication();
if (myStore.FileExists(fileName))
{
myStore.DeleteFile(fileName);
}
IsolatedStorageFileStream myFileStream = myStore.CreateFile(fileName);
WritableBitmap wr = imageControl; // 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);
}
希望它有效!
这篇关于将图像保存到媒体库 WP7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!