How to: Retrieve a remote user’s picture

Your code uses a different process to retrieve the user pictures for remote user than it uses to retrive those for local user.

At design time, you must determine two things: which picture is appropriate for your use, and the size of the picture you will request.

Note This procedure is only used for user on a remote console. To retrieve the picture for a user on the local console, see How to: Retrieve a local user’s picture.

To retrieve a remote user’s picture:

  1. Identify the XUID of one or more remote users.
    auto userList = ref new Vector<String^>();
    userList->Append(xboxUserId);  
    
  2. Retrieve the user’s profile and gamer picture URIs. The user profile contains multiple gamer picture URIs in its properties. As explained above, your code should use the appropriate URI (XboxUserProfile.GameDisplayPictureResizeUri for the gamer picture) and append the width and height of the requested image, in the format&format=png&w={width}&h={height}. The returned image data from this URI is in PNG format.
    The following example retrieves the URI for a 64x64 pixel version of a user’s gamer picture.
    auto pAsyncOp = requester->ProfileService->GetUserProfilesAsync(userList->GetView());
    String^ gameDisplayPicResizeUri;
    create_task( pAsyncOp )
     .then( [this] (task<XboxUserProfile^> resultTask)
    {
      try
     {
        IVectorView<XboxUserProfile^>^ results = resultTask.get();
              
        for (XboxUserProfile^ profile : results)
        {
            if( profile->GameDisplayPictureResizeUri != nullptr )
            {
               // Retrieve small image size URI by appending size query strings.
               gameDisplayPicResizeUri = String::Concat( profile->GameDisplayPictureResizeUri->AbsoluteUri, L"&format=png&w=64&h=64" );
            }
        }
     catch (Platform::Exception^ ex)
     {
        // Handle error
     }
    });