ShareMediaTask 与隔离存储图像的使用 [英] Usage of ShareMediaTask along with Isolated storage image

查看:23
本文介绍了ShareMediaTask 与隔离存储图像的使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将 ShareMediaTask 与保存在独立存储上的图像一起使用.我尝试通过应用下面给定的代码来实现相同的功能.但是当我运行代码时,当前页面闪烁并返回到同一页面.

Is it possible to use ShareMediaTask along with the image save on the isolated storage. I tried to implement the same by applying the below given code. But when i run the code the current page flashes and comes back to the same page.

  var shareMediaTask = new ShareMediaTask { FilePath = "isostore:" + LocalImagePath };
  shareMediaTask.Show();

推荐答案

抱歉,目前 ShareMediaTask 仅支持已保存图片"文件夹的相机胶卷"文件夹中媒体库中的项目.这样做是出于安全原因.例如,如果您使用 ShareMediaTask 并与另一个应用程序共享,则该应用程序永远不应访问您应用程序的 IsoStore.因此,ShareMediaTask 目前不支持 IsoStore 文件路径.

Sorry, currently ShareMediaTask only supports items in the Media Library either in the Camera Roll folder of the Saved Pictures folder. That's done due to security reasons. If for example you use ShareMediaTask and share with another app, that app should never have access to your app's IsoStore. For that reason, ShareMediaTask doesn't currently support IsoStore file paths.

这是一个端到端的代码示例,说明如何将图像保存到 MediaLibrary Saved Pictures 中并使用 ShareMediaTask @ http://www.reflectionit.nl/Blog/PermaLink620a4c87-a4af-4007-b4bc-81d851b11658.aspx

Here's an end-to-end code sample of how to save an image into the MediaLibrary Saved Pictures and use the ShareMediaTask @ http://www.reflectionit.nl/Blog/PermaLink620a4c87-a4af-4007-b4bc-81d851b11658.aspx

private void ButtonShare_Click(object sender, RoutedEventArgs e) {
    var bmp = new WriteableBitmap(this.ContentPanel, null);
    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();
        var picture = lib.SavePicture(string.Format("test.jpg"), ms);

        var task = new ShareMediaTask();

        task.FilePath = picture.GetPath();

        task.Show();
    }
}

您还可以将图片保存到相机胶卷文件夹中,并通过 MediaLibrary.SavePictureToCameraRoll() 扩展方法使用 ShareMediaTask.

You can also save pictures into the Camera Roll folder and use the ShareMediaTask using the MediaLibrary.SavePictureToCameraRoll() extension method.

这篇关于ShareMediaTask 与隔离存储图像的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆