Search code examples
c#xamlwindows-10-universalucwa

How to display the skype user photo from HTTP Response using UCWA API?


I am working on Universal Windows Applications, in my current project I used Unified Communications Web API (UCWA) to display the skype user status it's working fine but when I am trying to display the skype user photo at that time I got stuck.

I followed below link to display the photo https://msdn.microsoft.com/en-us/skype/ucwa/getmyphoto

I got response code of 200 OK for my GET request but I don't know how to display the image from my response.

Please tell me how to resolve it.

-Pradeep


Solution

  • I got Result, After getting HTTP Response then I am converting those response content to stream type by using this below line.

    var presenceJsonStr = await httpResponseMessage.Content.ReadAsStreamAsync();
    

    This is the code to display the image

     var photo = await AuthenticationHelper.Photo();
    // Create a .NET memory stream.
                    var memStream = new MemoryStream();
    
                    // Convert the stream to the memory stream, because a memory stream supports seeking.
                    await photo.CopyToAsync(memStream);
    
                    // Set the start position.
                    memStream.Position = 0;
    
                    // Create a new bitmap image.
                    var bitmap = new BitmapImage();
    
                    // Set the bitmap source to the stream, which is converted to a IRandomAccessStream.
                    bitmap.SetSource(memStream.AsRandomAccessStream());
    
                    // Set the image control source to the bitmap.
                    imagePreivew.ImageSource = bitmap;