WriteBitsFB() public method

public WriteBitsFB ( int numberOfBits, double value ) : void
numberOfBits int
value double
return void
Ejemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="output"></param>
        public override void Write(Stream output)
        {
            BitStream bits = new BitStream(output);
            BinaryWriter bw = new BinaryWriter(output);

            bw.Write(this._startWidth);
            bw.Write(this._endWidth);

            bits.WriteBits(2, (Int32)this._startCapStyle);
            bits.WriteBits(2, (Int32)this._joinstyle);
            bits.WriteBits(1, Convert.ToInt32(this._hasFillFlag));
            bits.WriteBits(1, Convert.ToInt32(this._noHScale));
            bits.WriteBits(1, Convert.ToInt32(this._noVScale));
            bits.WriteBits(1, Convert.ToInt32(this._pixelHinting));
            bits.WriteBits(5, 0); // reserved
            bits.WriteBits(1, Convert.ToInt32(this._noClose));
            bits.WriteBits(2, (Int32)this._endCapStyle);
            bits.WriteFlush();

            if (this._joinstyle.Equals(JoinStyle.Miter))
            {
                bits.WriteBitsFB(16, this._miterLimtiFactor);
            }

            if (!this._hasFillFlag)
            {
                this._startColor.Write(output);
                this._endColor.Write(output);
            }
            else
            {
                this._fillStyle.Write(output);
            }
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Writes this object back to a stream.
        /// </summary>
        /// <param name="output">The stream to write to.</param>
        public override void Write(Stream output)
        {
            BitStream bits = new BitStream(output);

            byte[] width = BitConverter.GetBytes(this._width);
            output.Write(width, 0, 2);

            bits.WriteBits(2, (Int32)this._startCapStyle);
            bits.WriteBits(2, (Int32)this._joinstyle);
            bits.WriteBits(1, Convert.ToInt32(this._hasFillFlag));
            bits.WriteBits(1, Convert.ToInt32(this._noHScale));
            bits.WriteBits(1, Convert.ToInt32(this._noVScale));
            bits.WriteBits(1, Convert.ToInt32(this._pixelHinting));
            bits.WriteBits(5, 0); // reserved
            bits.WriteBits(1, Convert.ToInt32(this._noClose));
            bits.WriteBits(2, (Int32)this._endCapStyle);

            if (this._joinstyle.Equals(JoinStyle.Miter))
            {
                bits.WriteFlush();
                bits.WriteBitsFB(16, this._miterLimtiFactor);
            }
            if (!this._hasFillFlag)
            {
                bits.WriteFlush();
                this._color.Write(output);

            }
            else
            {
                bits.WriteFlush();
                this._fillStyle.Write(output);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Writes this object back to a stream
        /// </summary>
        /// <param name="output">The stream to write to.</param>
        public void Write(Stream output)
        {
            BitStream bits = new BitStream(output);

            bits.WriteBitsFB(16, this._alignmentCoordinate);
            bits.WriteBitsFB(16, this._range);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="output"></param>
        public override void Write(Stream output)
        {
            BitStream bits = new BitStream(output);

            bits.WriteBits(2, (Int32)this._spreadMode);
            bits.WriteBits(2, (Int32)this._interpolationMode);
            bits.WriteBits(4, (Int32)this._numGradients);

            bits.WriteFlush();

            for (int i = 0; i < this._numGradients; i++)
            {
                this._gradientRecords[i].Write(output);
            }
            bits.WriteBitsFB(16, this._focalPoint);
        }