Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将IrandoMacAccessStreamWithContentType转换为BitMapImage UWP?_C#_Uwp - Fatal编程技术网

C# 如何将IrandoMacAccessStreamWithContentType转换为BitMapImage UWP?

C# 如何将IrandoMacAccessStreamWithContentType转换为BitMapImage UWP?,c#,uwp,C#,Uwp,我尝试使用下面的代码从UWP获取联系人的图像。我的问题是:我不知道如何从irandomaccesstreamwithcontenttype获取位图 我怎样才能得到它呢?当你说“位图图像”时,我想你的意思是在UWP中使用的。如果是这样,您可以通过调用并提供流来定义 方法需要一个as参数,接口只继承表单。因此,您可以通过以下方式轻松获得: var contactStore = await ContactManager.RequestStoreAsync(); Contact Mycontact =

我尝试使用下面的代码从UWP获取联系人的图像。我的问题是:我不知道如何从irandomaccesstreamwithcontenttype获取位图

我怎样才能得到它呢?

当你说“位图图像”时,我想你的意思是在UWP中使用的。如果是这样,您可以通过调用并提供流来定义

方法需要一个as参数,接口只继承表单。因此,您可以通过以下方式轻松获得:

var contactStore = await ContactManager.RequestStoreAsync();

Contact Mycontact = await contactStore.GetContactAsync(contact.Id);

if (Mycontact.Thumbnail != null)
 {
  using (IRandomAccessStreamWithContentType stream = await Mycontact.Thumbnail.OpenReadAsync())
 {
  // todo: get bitmapimage
 }
}
请参考答案。可能的副本
if (Mycontact.Thumbnail != null)
{
    using (IRandomAccessStreamWithContentType stream = await Mycontact.Thumbnail.OpenReadAsync())
    {
        var bitmapimage = new BitmapImage();
        await bitmapimage.SetSourceAsync(stream);
        //TODO with bitmapimage
    }
}