aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWilliam Venner <[email protected]>2021-02-27 12:17:43 +0000
committerWilliam Venner <[email protected]>2021-02-27 12:17:43 +0000
commitff3d02281c2776633f88f48934179591911382d8 (patch)
tree4dff499ee6364e7046e68f675a22ec4359f33574 /src
parentUpdate version in readme (diff)
downloadsteamworks-rs-ff3d02281c2776633f88f48934179591911382d8.tar.xz
steamworks-rs-ff3d02281c2776633f88f48934179591911382d8.zip
Add friends::large_avatar (binding to ISteamFriends->GetLargeFriendAvatar)
Diffstat (limited to 'src')
-rw-r--r--src/friends.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/friends.rs b/src/friends.rs
index ddc9a7a..5ac49f8 100644
--- a/src/friends.rs
+++ b/src/friends.rs
@@ -278,6 +278,29 @@ impl <Manager> Friend<Manager> {
Some(dest)
}
}
+
+ /// Returns a large (184x184) avatar for the user in RGBA format
+ pub fn large_avatar(&self) -> Option<Vec<u8>> {
+ unsafe {
+ let utils = sys::SteamAPI_SteamUtils_v010();
+ let img = sys::SteamAPI_ISteamFriends_GetLargeFriendAvatar(self.friends, self.id.0);
+ if img == 0 {
+ return None;
+ }
+ let mut width = 0;
+ let mut height = 0;
+ if !sys::SteamAPI_ISteamUtils_GetImageSize(utils, img, &mut width, &mut height) {
+ return None;
+ }
+ assert_eq!(width, 184);
+ assert_eq!(height, 184);
+ let mut dest = vec![0; 184 * 184 * 4];
+ if !sys::SteamAPI_ISteamUtils_GetImageRGBA(utils, img, dest.as_mut_ptr(), 184 * 184 * 4) {
+ return None;
+ }
+ Some(dest)
+ }
+ }
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]