Recurity.Swf.Matrix.Write C# (CSharp) Method

Write() public method

public Write ( Stream output ) : void
output Stream
return void
        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();
        }