Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        /// <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));
        }
Beispiel #3
0
        /// <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));
        }
Beispiel #4
0
        /// <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);
            }
        }