Пример #1
0
        public static Texture LoadFromStream(BinaryReader inputReader, string name)
        {
            TextureStorage storage = new TextureStorage();

            if (!storage.Parse(inputReader))
            {
                return(null);
            }

            return(new Texture(name, storage.Pixels, storage.Width, storage.Height));
        }
Пример #2
0
        public static Texture LoadFromFile(string filePath)
        {
            TextureStorage storage = new TextureStorage(filePath);

            using (FileStream inputStream = new FileStream(storage.LibraryPath, FileMode.Open, FileAccess.Read))
            {
                using (BinaryReader inputReader = new BinaryReader(inputStream, storage.Encoding))
                {
                    if (!storage.Parse(inputReader))
                    {
                        return(null);
                    }
                }
            }

            string name = Path.GetFileNameWithoutExtension(filePath);

            return(new Texture(name, storage.Pixels, storage.Width, storage.Height));
        }