简体   繁体   English

接收图像-UWP

[英]Receiving Image-UWP

I m using VS 2017, and I need to receive Image form other app. 我正在使用VS 2017,我需要从其他应用程序接收图像。 So its basically App-App Communication. 因此,它基本上是App-App通讯。 I m new in UWP and windows mobile developing, so I research a lot, and I manage to get DataPackage with shared content. 我是UWP和Windows Mobile开发的新手,所以我做了很多研究,并且设法获得了具有共享内容的DataPackage。

When you try to examine this: 当您尝试检查以下内容时:

if (this.shareOperation.Data.Contains(StandardDataFormats.Bitmap))
{
    this.sharedBitmapStreamRef = await this.shareOperation.Data.GetBitmapAsync();

    //catch (Exception ex)
    //{
    //    NotifyUserBackgroundThread("Failed GetBitmapAsync - " + ex.Message, NotifyType.ErrorMessage);
    //}
}

Problem is that app doesn't see my file as Bitmap. 问题是应用程序没有将我的文件视为位图。 When I try to get type of recived file it gives me System.__COMObject. 当我尝试获取接收文件的类型时,它给了我System .__ COMObject。 I manage get file as storageitem, but I cannot read IRandomAccessStreamReference. 我将获取文件管理为storageitem,但无法读取IRandomAccessStreamReference。 As StorageItem I get, path, name etc. 作为StorageItem,我得到了路径,名称等。

The same thing is happening on ShareTarget example app, its also doesn't see image as BitMap(formatId). 在ShareTarget示例应用程序上发生了同样的事情,它也没有将图像视为BitMap(formatId)。 Any suggestions? 有什么建议么?

Refer this sample https://code.msdn.microsoft.com/How-to-share-data-between-6ef0a355 on msdn. 请在msdn上参考此示例https://code.msdn.microsoft.com/How-to-share-data-between-6ef0a355

Target app: 目标应用:

if (operation.Data.Contains(StandardDataFormats.Bitmap))
{
    shareType.Text = "Bitmap";
    shareTitle.Text = operation.Data.Properties.Title;
    imgShareImage.Visibility = Visibility.Visible;
    tbShareData.Visibility = Visibility.Collapsed;
    RandomAccessStreamReference imageStreamRef = await operation.Data.GetBitmapAsync();
    IRandomAccessStreamWithContentType streamWithContentType = await imageStreamRef.OpenReadAsync();
    BitmapImage bitmapImage = new BitmapImage();
    bitmapImage.SetSource(streamWithContentType);
    imgShareImage.Source = bitmapImage;
}

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

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