CountMaximumBits() public method

public CountMaximumBits ( ) : int
return int
Example #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();
        }
Example #2
0
        /// <summary>
        /// TODO : Documentation
        /// </summary>
        /// <param name="output"></param>
        public void Write( Stream output )
        {
            BitStream bits = new BitStream( output );

            int bitsNeeded = bits.CountMaximumBits(_x_min, _x_max, _y_min, _y_max);

            bits.WriteBits(5, (ulong)bitsNeeded);
            // reassign, so we don't work with stale data
            _bits_per_entry = (uint)bitsNeeded;

            bits.WriteBits(bitsNeeded, _x_min);
            bits.WriteBits(bitsNeeded, _x_max);
            bits.WriteBits(bitsNeeded, _y_min);
            bits.WriteBits(bitsNeeded, _y_max);
            bits.WriteFlush();
        }
Example #3
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
            }

            bits.WriteBits(1, 0); // has no Rotate

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

            bits.WriteFlush();
        }
Example #4
0
 /// <summary>
 ///         /// TODO : Documentation
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     BitStream bits = new BitStream();
     StringBuilder sb = new StringBuilder();
     sb.Append( "RECT " );
     sb.AppendFormat( "{0:d}Bits/entry, ", bits.CountMaximumBits( _x_min, _x_max, _y_min, _y_max ) );
     sb.AppendFormat( "Xmin {0:d} / Xmax {1:d} / Ymin {2:d} / Ymax {3:d}",
         _x_min, _x_max, _y_min, _y_max );
     return sb.ToString();
 }