Windows phone 7 使用ShareMediaTask和独立存储映像
是否可以在隔离存储上使用ShareMediaTask和映像存储。我试图通过应用下面给出的代码来实现同样的功能。但是当我运行代码时,当前页面会闪烁并返回到同一页面Windows phone 7 使用ShareMediaTask和独立存储映像,windows-phone-7,windows-phone-7.1,windows-phone-8,Windows Phone 7,Windows Phone 7.1,Windows Phone 8,是否可以在隔离存储上使用ShareMediaTask和映像存储。我试图通过应用下面给出的代码来实现同样的功能。但是当我运行代码时,当前页面会闪烁并返回到同一页面 var shareMediaTask = new ShareMediaTask { FilePath = "isostore:" + LocalImagePath }; shareMediaTask.Show(); 很抱歉,当前ShareMediaTask仅支持媒体库中的项目,即“已保存图片”文件夹中的“相机卷”文件夹中的项目
var shareMediaTask = new ShareMediaTask { FilePath = "isostore:" + LocalImagePath };
shareMediaTask.Show();
很抱歉,当前ShareMediaTask仅支持媒体库中的项目,即“已保存图片”文件夹中的“相机卷”文件夹中的项目。这是出于安全原因。例如,如果您使用ShareMediaTask并与另一个应用程序共享,则该应用程序不应访问您应用程序的IsoStore。因此,ShareMediaTask当前不支持IsoStore文件路径 以下是如何将图像保存到MediaLibrary保存的图片中并使用ShareMediaTask@
您还可以将图片保存到Camera Roll文件夹中,并使用MediaLibrary.SavePictureToCameraRoll()扩展方法使用ShareMediaTask 很抱歉,当前ShareMediaTask仅支持媒体库中的项目,即“已保存图片”文件夹中的“相机卷”文件夹中的项目。这是出于安全原因。例如,如果您使用ShareMediaTask并与另一个应用程序共享,则该应用程序不应访问您应用程序的IsoStore。因此,ShareMediaTask当前不支持IsoStore文件路径 以下是如何将图像保存到MediaLibrary保存的图片中并使用ShareMediaTask@ 您还可以将图片保存到Camera Roll文件夹中,并使用MediaLibrary.SavePictureToCameraRoll()扩展方法使用ShareMediaTask
我已经完成了以下代码:
BitmapImage bi = new BitmapImage(new Uri(string.Format("Data/{0}/{1}", Category, img), UriKind.Relative)));
bi.CreateOptions = BitmapCreateOptions.BackgroundCreation;
bi.ImageOpened += (s1, e1) =>
{
var bmp = new WriteableBitmap(bi);
var width = (int)bmp.PixelWidth;
var height = (int)bmp.PixelHeight;
using (var ms = new MemoryStream(width * height * 4))
{
bmp.SaveJpeg(ms, width, height, 0, 100);
ms.Seek(0, SeekOrigin.Begin);
var lib = new MediaLibrary();
Picture picture = null;
try
{
picture = lib.SavePicture(string.Format("test.jpg"), ms);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
var task = new ShareMediaTask();
task.FilePath = picture.GetPath();
task.Show();
}
};
我已经完成了以下代码:
BitmapImage bi = new BitmapImage(new Uri(string.Format("Data/{0}/{1}", Category, img), UriKind.Relative)));
bi.CreateOptions = BitmapCreateOptions.BackgroundCreation;
bi.ImageOpened += (s1, e1) =>
{
var bmp = new WriteableBitmap(bi);
var width = (int)bmp.PixelWidth;
var height = (int)bmp.PixelHeight;
using (var ms = new MemoryStream(width * height * 4))
{
bmp.SaveJpeg(ms, width, height, 0, 100);
ms.Seek(0, SeekOrigin.Begin);
var lib = new MediaLibrary();
Picture picture = null;
try
{
picture = lib.SavePicture(string.Format("test.jpg"), ms);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
var task = new ShareMediaTask();
task.FilePath = picture.GetPath();
task.Show();
}
};
GetPath()
是Microsoft.Xna.Framework.Media.PhoneExtensions
中的一个扩展方法(以防其他人怀疑)。GetPath()
是Microsoft.Xna.Framework.Media.PhoneExtensions
中的一个扩展方法(以防其他人怀疑)。