简体   繁体   English

如何在不将图像保存到Windows Phone 8中的库的情况下共享图像?

[英]How can i Share an image without saving it to Gallery in Windows Phone 8?

I'm using ShareMediaTask to share an image.I'm able to do this after saving an image to my Phone gallery but i want it directly before saving it to gallery. 我正在使用ShareMediaTask共享图像。将图像保存到我的手机图库后可以执行此操作,但是我想直接将其保存到图库中。 How can i do this ? 我怎样才能做到这一点 ? I have done this but i dont want that photo chooser task open before sharing, i want directly it share. 我已经做到了,但是我不希望在共享之前打开该照片选择器任务,我希望它直接共享。

    private void mnuShare_Click(object sender, EventArgs e)
    {

         using (MemoryStream stream = new MemoryStream())
        {
            WriteableBitmap bitmap = new WriteableBitmap(LayoutRoot, null);
            bitmap.SaveJpeg(stream, bitmap.PixelWidth, bitmap.PixelHeight, 0, 100);
            stream.Seek(0, SeekOrigin.Begin);

            using (MediaLibrary mediaLibrary = new MediaLibrary())
                mediaLibrary.SavePicture("Picture.jpg", stream);

        }
       MessageBox.Show("Picture Saved...");
        var chooser = new Microsoft.Phone.Tasks.PhotoChooserTask();
        chooser.Completed += chooser_Completed;
       chooser.Show();
      _fileName = e.ToString();

    }
    void ShowShareMediaTask(string path)
    {
        ShareMediaTask shareMediaTask = new ShareMediaTask();
        shareMediaTask.FilePath = path;
        shareMediaTask.Show();
    }
    void chooser_Completed(object sender, PhotoResult e)
    {
        _fileName = e.OriginalFileName.ToString();
        if (e.TaskResult == TaskResult.OK)
        {
            ShareMediaTask shareMediaTask = new ShareMediaTask();

            shareMediaTask.FilePath = _fileName;
            shareMediaTask.Show();

        }

I can use ShareMediaTask only with photos from the gallery. 我只能对图库中的照片使用ShareMediaTask There is no way around it. 没有其他办法了。

However, in Windows Phone 8.1 you can share any file from isolated storage, take a look at http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh871371.aspx 但是,在Windows Phone 8.1中,您可以共享隔离存储中的任何文件,请访问http://msdn.microsoft.com/zh-cn/library/windows/apps/xaml/hh871371.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM