private static DdsFile GetDdsFile(Stream stream) { using (var reader = new BinaryReader(stream)) { return(DdsFile.Deserialize(reader)); } }
public static DdsFile Deserialize(BinaryReader reader) { var file = new DdsFile(); file.dwMagic = reader.ReadString(4); if (file.dwMagic != magicNumber) { throw new IOException($"Expected header file identifier ({magicNumber}) does not match the deserialized identifier ({file.dwMagic})"); } file.header = DdsHeader.Deserialize(reader); file.data = reader.ReadRemainingBytes(); return(file); }