Yunan.WPF.ImageAnim.GifAnimation.ParseGraphicBlock C# (CSharp) Method

ParseGraphicBlock() private method

private ParseGraphicBlock ( byte gifData, int offset ) : int
gifData byte
offset int
return int
        private int ParseGraphicBlock(byte[] gifData, int offset)
        {
            _currentParseGifFrame.left = BitConverter.ToUInt16(gifData, offset + 1);
            _currentParseGifFrame.top = BitConverter.ToUInt16(gifData, offset + 3);
            _currentParseGifFrame.width = BitConverter.ToUInt16(gifData, offset + 5);
            _currentParseGifFrame.height = BitConverter.ToUInt16(gifData, offset + 7);
            if (_currentParseGifFrame.width > _logicalWidth)
            {
                _logicalWidth = _currentParseGifFrame.width;
            }
            if (_currentParseGifFrame.height > _logicalHeight)
            {
                _logicalHeight = _currentParseGifFrame.height;
            }
            byte packedField = gifData[offset + 9];
            bool hasLocalColorTable = (int)(packedField & 0x80) > 0 ? true : false;

            int currentIndex = offset + 9;
            if (hasLocalColorTable)
            {
                int colorTableLength = packedField & 0x07;
                colorTableLength = (int)Math.Pow(2, colorTableLength + 1) * 3;
                currentIndex = currentIndex + colorTableLength;
            }
            currentIndex++; // Skip 0x00

            currentIndex++; // Skip LZW Minimum Code Size;

            while (gifData[currentIndex] != 0x00)
            {
                int length = gifData[currentIndex];
                currentIndex = currentIndex + gifData[currentIndex];
                currentIndex++; // Skip initial size byte
            }
            currentIndex = currentIndex + 1;
            return currentIndex;
        }