/// <summary>Retrieves a user's avatar from the cache.</summary> public static Texture2D LoadUserAvatar(int userId, UserAvatarSize size) { string avatarFilePath = CacheClient.GenerateUserAvatarFilePath(userId, size); Texture2D avatarTexture = IOUtilities.ReadImageFile(avatarFilePath); return(avatarTexture); }
/// <summary>Stores a user's avatar in the cache.</summary> public static bool SaveUserAvatar(int userId, UserAvatarSize size, Texture2D avatarTexture) { Debug.Assert(avatarTexture != null); string avatarFilePath = CacheClient.GenerateUserAvatarFilePath(userId, size); return(IOUtilities.WritePNGFile(avatarFilePath, avatarTexture)); }
/// <summary>Stores a user's avatar in the cache.</summary> public static bool SaveUserAvatar(int userId, UserAvatarSize size, Texture2D avatarTexture) { Debug.Assert(avatarTexture != null); string avatarFilePath = CacheClient.GenerateUserAvatarFilePath(userId, size); byte[] imageData = avatarTexture.EncodeToPNG(); return(LocalDataStorage.WriteFile(avatarFilePath, imageData)); }
/// <summary>Retrieves a user's avatar from the cache.</summary> public static Texture2D LoadUserAvatar(int userId, UserAvatarSize size) { string avatarFilePath = CacheClient.GenerateUserAvatarFilePath(userId, size); byte[] imageData; if (LocalDataStorage.ReadFile(avatarFilePath, out imageData) && imageData != null) { return(IOUtilities.ParseImageData(imageData)); } else { return(null); } }