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

CountNeededBitsFB() public method

public CountNeededBitsFB ( double source ) : int
source double
return int
        public int CountNeededBitsFB(double source)
        {
            Int32 i = FBtoInt32(source);
            int result = this.CountNeededBits(i);
            return result;
        }

Usage Example

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

            if ( _HasScale )
            {
                int scaleBitsX = bits.CountNeededBitsFB( _xScaleF );
                int scaleBitsY = bits.CountNeededBitsFB( _yScaleF );
                int scaleBits = scaleBitsX > scaleBitsY ? scaleBitsX : scaleBitsY;

                bits.WriteBits( 1, 1 ); // HasScale
                bits.WriteBits( 5, scaleBits );
                bits.WriteBitsFB( scaleBits, _xScaleF );
                bits.WriteBitsFB( scaleBits, _yScaleF );

            }
            else
            {
                bits.WriteBits( 1, 0 ); // Has no Scale
            }

            if ( _HasRotate )
            {
                int rotateBits0 = bits.CountNeededBitsFB( _rotateSkew0F );
                int rotateBits1 = bits.CountNeededBitsFB( _rotateSkew1F );
                int rotateBits = rotateBits0 > rotateBits1 ? rotateBits0 : rotateBits1;

                bits.WriteBits( 1, 1 ); // HasRotate
                bits.WriteBits( 5, rotateBits );
                bits.WriteBitsFB( rotateBits, _rotateSkew0F );
                bits.WriteBitsFB( rotateBits, _rotateSkew1F );
            }
            else
            {
                bits.WriteBits( 1, 0 ); // has no Rotate
            }

            int translateBits = bits.CountMaximumBits( _translateX, _translateY );

            if (this._SwfVersion > 8)
            {
                bits.WriteBits(5, this._numTranslateBits);
                bits.WriteBits(this._numTranslateBits, _translateX);
                bits.WriteBits(this._numTranslateBits, _translateY);
            }
            else
            {
                bits.WriteBits(5, translateBits);
                bits.WriteBits(translateBits, _translateX);
                bits.WriteBits(translateBits, _translateY);
            }

            bits.WriteFlush();
        }
All Usage Examples Of Recurity.Swf.BitStream::CountNeededBitsFB