CSharpImageLibrary.Headers.PNG_Header.Load C# (CSharp) Method

Load() protected method

Loads PNG header from stream.
protected Load ( Stream stream ) : long
stream Stream Fully formatted header stream. Position not relevant, but not reset.
return long
        protected override long Load(Stream stream)
        {
            base.Load(stream);
            byte[] temp = stream.ReadBytes(HeaderSize);

            if (!CheckIdentifier(temp))
                throw new FormatException("Stream is not a PNG Image");

            PNGChunk header = new PNGChunk(temp);
            Width = MyBitConverter.ToInt32(header.ChunkData, 0, MyBitConverter.Endianness.BigEndian);
            Height = MyBitConverter.ToInt32(header.ChunkData, 4, MyBitConverter.Endianness.BigEndian);
            BitDepth = header.ChunkData[8];
            colourType = (ColourType)header.ChunkData[9];
            CompressionMethod = (CompressionMethods)header.ChunkData[10];
            FilterMethod = (FilterMethods)header.ChunkData[11];
            InterlaceMethod = (InterlaceMethdods)header.ChunkData[12];

            return -1;  // Since we don't know the length of the entire header, no point returning any value.
        }