Recurity.Swf.BitStream.GetBitsSigned C# (CSharp) Method

GetBitsSigned() public method

public GetBitsSigned ( UInt32 numberOfBits ) : Int32
numberOfBits System.UInt32
return System.Int32
        public Int32 GetBitsSigned(UInt32 numberOfBits)
        {
            if (0 == numberOfBits)
                return 0;

            UInt32 usig = this.GetBits(numberOfBits);
            UInt32 mask = unchecked((UInt32)(long)(~0) << (int)numberOfBits);
            Int32 ret;

            if (0 != ((long)usig >> (int)(numberOfBits - 1)))
            {
                ret = unchecked((Int32)((long)usig | (long)mask));
            }
            else
            {
                ret = (Int32)usig;
            }

            return ret;
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        public void Parse(Stream input)
        {
            BitStream bits = new BitStream(input);

            if (_HasScale = (1 == bits.GetBits(1)))
            {
                _numScaleBits = (byte)bits.GetBits(5);
                bits.GetBitsFB(_numScaleBits, out _xScaleF);
                bits.GetBitsFB(_numScaleBits, out _yScaleF);
            }

            _numTranslateBits = (byte)bits.GetBits(5);
            _translateX = bits.GetBitsSigned(_numTranslateBits);
            _translateY = bits.GetBitsSigned(_numTranslateBits);
        }
All Usage Examples Of Recurity.Swf.BitStream::GetBitsSigned