public static DdsFile Read(Stream inputStream) { DdsFile result = new DdsFile(); BinaryReader reader = new BinaryReader(inputStream, Encoding.Default, true); reader.Assert(MagicNumber); result.Header = DdsFileHeader.Read(inputStream); if (result.Header.IsDx10()) { result.HeaderDx10 = DdsFileHeaderDx10.Read(inputStream); } MemoryStream dataStream = new MemoryStream(); inputStream.CopyTo(dataStream); result.Data = dataStream.ToArray(); return(result); }
public static DdsFileHeader Read(Stream inputStream) { DdsFileHeader result = new DdsFileHeader(); BinaryReader reader = new BinaryReader(inputStream, Encoding.Default, true); result.Size = reader.ReadInt32(); result.Flags = (DdsFileHeaderFlags) reader.ReadInt32(); result.Height = reader.ReadInt32(); result.Width = reader.ReadInt32(); result.PitchOrLinearSize = reader.ReadInt32(); result.Depth = reader.ReadInt32(); result.MipMapCount = reader.ReadInt32(); // int Reserved1[11]; reader.Skip(44); result.PixelFormat = DdsPixelFormat.ReadDdsPixelFormat(inputStream); result.Caps = (DdsSurfaceFlags) reader.ReadInt32(); result.Caps2 = (DdsCubemap) reader.ReadInt32(); result.Caps3 = reader.ReadInt32(); result.Caps4 = reader.ReadInt32(); // int Reserved2; reader.Skip(4); return result; }
public static DdsFileHeader Read(Stream inputStream) { DdsFileHeader result = new DdsFileHeader(); BinaryReader reader = new BinaryReader(inputStream, Encoding.Default, true); result.Size = reader.ReadInt32(); result.Flags = (DdsFileHeaderFlags)reader.ReadInt32(); result.Height = reader.ReadInt32(); result.Width = reader.ReadInt32(); result.PitchOrLinearSize = reader.ReadInt32(); result.Depth = reader.ReadInt32(); result.MipMapCount = reader.ReadInt32(); // int Reserved1[11]; reader.Skip(44); result.PixelFormat = DdsPixelFormat.ReadDdsPixelFormat(inputStream); result.Caps = (DdsSurfaceFlags)reader.ReadInt32(); result.Caps2 = (DdsCubemap)reader.ReadInt32(); result.Caps3 = reader.ReadInt32(); result.Caps4 = reader.ReadInt32(); // int Reserved2; reader.Skip(4); return(result); }