How to: Retrieve a local user’s picture

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

At design time, you must determine which picture is appropriate for your use. If you are displaying the picture in a game, or an app that relates to gaming, you should use the Gamer Picture (UserDisplayInfo::GetGamerPictureAsync). If you are displaying the picture in an app that doesn’t relate to gaming, you should use the Application Picture (UserDisplayInfo::GetApplicationPictureAsync).

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

To retrieve a local user’s picture:

  1. Identify which User object in the static Users collection is associated with the user whose picture is to be displayed.
  2. Use the User::DisplayInfo property to retrieve the UserDisplayInfo object for the User.
  3. Call the appropriate GetNNNPictureAsync method, passing an IBuffer with Length of zero.
  4. The call fails with an E_BOUNDS error, but with the returned GetPictureResult::RequiredBufferSize value set to the required buffer size for the requested picture.
  5. Allocate a new IBuffer instance with the specified buffer size, and call the appropriate GetNNNPictureAsync method again, passing the newly-allocated buffer.
  6. When the asynchronous operation completes, the IBuffer contains the requested picture, as a .PNG formatted image.