在Windows Phone 8中如何共享图片而不将其保存到图库?
本文关键字:保存 Phone Windows 何共享 共享 | 更新日期: 2023-09-27 18:19:22
我正在使用ShareMediaTask共享图像。我能够做到这一点后,保存图像到我的手机画廊,但我想要它保存到画廊之前直接。我该怎么做呢?我已经这样做了,但是我不想在分享之前打开照片选择器任务,我想直接分享。
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();
}
我只能对图库中的照片使用ShareMediaTask
。没有别的办法。
然而,在Windows Phone 8.1中,你可以从隔离的存储共享任何文件,看看http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh871371.aspx