TagTool.Common.DdsHeader.ReadDdsD3D10Header C# (CSharp) Method

ReadDdsD3D10Header() private method

private ReadDdsD3D10Header ( BinaryReader reader ) : void
reader System.IO.BinaryReader
return void
        private void ReadDdsD3D10Header(BinaryReader reader)
        {
            D3D10Format = (DxgiFormat)reader.ReadUInt32();
            D3D10Dimension = (D3D10Dimension)reader.ReadUInt32();
            D3D10MiscFlags = (D3D10MiscFlags)reader.ReadUInt32();
            D3D10ArraySize = reader.ReadUInt32();
            D3D10AlphaMode = (D3D10AlphaMode)reader.ReadUInt32();
        }

Usage Example

Beispiel #1
0
        /// <summary>
        /// Reads a DDS header from a stream. On return, the stream will be positioned at the beginning of the texture data.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        /// <returns>The header that was read.</returns>
        /// <exception cref="System.InvalidOperationException">Thrown if the DDS header is invalid.</exception>
        public static DdsHeader Read(Stream stream)
        {
            var reader = new BinaryReader(stream);

            if (stream.Length - stream.Position < 128)
            {
                throw new InvalidOperationException("Invalid DDS file: header is too small");
            }
            var result = new DdsHeader();

            // Read and verify magic
            if (reader.ReadUInt32() != DdsFourCc.FromString("DDS "))
            {
                throw new InvalidOperationException("Invalid DDS file: invalid header magic");
            }

            // Read the DDS header
            result.ReadDdsHeader(reader);

            // If the format FourCC is 'DX10', read the extended header
            if (result.FourCc == DdsFourCc.FromString("DX10"))
            {
                result.ReadDdsD3D10Header(reader);
            }

            return(result);
        }
All Usage Examples Of TagTool.Common.DdsHeader::ReadDdsD3D10Header