WriteFlush() public method

public WriteFlush ( ) : void
return void
        /// <summary>
        /// 
        /// </summary>
        /// <param name="output"></param>
        public override void Write(Stream output)
        {
            BinaryWriter bw = new BinaryWriter(output);
            BitStream bits = new BitStream(output);

            bw.Write(this._initialSampleLeft);
            bits.WriteBits(6, (Int32)this._initialIndexLeft);
            bits.WriteFlush();

            bw.Write(this._initialSampleRight);
            bits.WriteBits(6, (Int32)this._initialIndexRight);
            bits.WriteFlush();

            output.Write(this._adpcmCodeData, 0, this._adpcmCodeData.Length);
        }
Beispiel #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();
        }
Beispiel #3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="input"></param>
 /// <param name="bits"></param>
 public override void Parse(Stream input, BitStream bits)
 {
     bits.GetBits(6);
     bits.WriteFlush();
 }
Beispiel #4
0
        /// <summary>
        /// Writes this object back to a stream.
        /// </summary>
        /// <param name="output">The stream to write to.</param>
        public virtual void Write(Stream output)
        {
            BitStream bits = new BitStream(output);

            bits.WriteBits(4, (Int32)this._numFillBits);
            bits.WriteBits(4, (Int32)this._numLineBits);
            bits.WriteFlush();

            output.Write(this._shapeRecordBuffer, 0, this._shapeRecordBuffer.Length);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="output"></param>
        public void Write( Stream output )
        {
            BitStream bits = new BitStream( output );

            int maxBits = this.BitCount;

            if ( 0 == maxBits )
            {
                //
                // special case: must be byte-aligned by hand
                //
                bits.WriteBits( 2, 0 ); // has no Terms whatsoever
                bits.WriteBits( 4, 1 ); // 1 Bit per nothing
                bits.WriteBits( 2, 0 ); // nothing
            }
            else
            {
                bits.WriteBits( 1, ( _HasAddTerms ? 1 : 0 ) );
                bits.WriteBits( 1, ( _HasMultTerms ? 1 : 0 ) );
                bits.WriteBits( 4, maxBits );

                if ( _HasMultTerms )
                {
                    bits.WriteBits( maxBits, _RedMultTerm );
                    bits.WriteBits( maxBits, _GreenMultTerm );
                    bits.WriteBits( maxBits, _BlueMultTerm );
                    bits.WriteBits( maxBits, _AlphaMultTerm );
                }
                if ( _HasAddTerms )
                {
                    bits.WriteBits( maxBits, _RedAddTerm );
                    bits.WriteBits( maxBits, _GreenAddTerm );
                    bits.WriteBits( maxBits, _BlueAddTerm );
                    bits.WriteBits( maxBits, _AlphaAddTerm );
                }
            }
            bits.WriteFlush();
        }
Beispiel #6
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();
        }
Beispiel #7
0
        /// <summary>
        /// Writes this object back to a stream
        /// </summary>
        /// <param name="output">The stream to write to.</param>
        public void Write(Stream output)
        {
            if (!this._glyphEntries.Count.Equals(this._glyphCount))
            {
                SwfFormatException e = new SwfFormatException("The value of glyph count and the list size of glyphs muste be equal.");
               Log.Error(this, e.Message);
                throw e;
            }
            BitStream bits = new BitStream(output);

            bits.WriteBits(1, 1); // TextRecordType (always 1)
            bits.WriteBits(3, 0); // StyleFlagsReserved (always 0)
            bits.WriteBits(1, Convert.ToInt32(this._StyleFlagsHasFont));
            bits.WriteBits(1, Convert.ToInt32(this._StyleFlagsHasColor));
            bits.WriteBits(1, Convert.ToInt32(this._StyleFlagsHasYOffset));
            bits.WriteBits(1, Convert.ToInt32(this._StyleFlagsHasXOffset));
            bits.WriteFlush();

            if (this._StyleFlagsHasFont)
            {
                byte[] fontID = BitConverter.GetBytes(this._fontID);
                output.Write(fontID, 0, 2);
            }
            if (this._StyleFlagsHasColor)
            {
                this._textColor.Write(output);
            }
            if (this._StyleFlagsHasXOffset)
            {
                byte[] xOffset = BitConverter.GetBytes(this._xOffset);
                output.Write(xOffset, 0, 2);
            }
            if (this._StyleFlagsHasYOffset)
            {
                byte[] yOffset = BitConverter.GetBytes(this._yOffset);
                output.Write(yOffset, 0, 2);
            }
            if (this._StyleFlagsHasFont)
            {
                byte[] textHeight = BitConverter.GetBytes(this._textHeight);
                output.Write(textHeight, 0, 2);
            }

            output.WriteByte(this._glyphCount);

            for (int i = 0; i < this._glyphCount; i++)
            {
                this._glyphEntries[i].Write(bits);

            }
            bits.WriteFlush();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="output"></param>
        /// <param name="bits"></param>
        public override void Write(Stream output, BitStream bits)
        {
            bits.WriteBits(1, 0); //type flag
            bits.WriteBits(1, Convert.ToUInt32(this._stateNewStyles));
            bits.WriteBits(1, Convert.ToUInt32(this._stateLineStyle));
            bits.WriteBits(1, Convert.ToUInt32(this._stateFillStyle1));
            bits.WriteBits(1, Convert.ToUInt32(this._stateFillStyle0));
            bits.WriteBits(1, Convert.ToUInt32(this._stateMoveTo));

            if (this._stateMoveTo)
            {
                bits.WriteBits(5, (Int32)this._moveBits);
                bits.WriteBits((Int32)this._moveBits, (Int32)this._moveDeltaX);
                bits.WriteBits((Int32)this._moveBits, (Int32)this._moveDeltaY);
            }
            if (this._stateFillStyle0)
            {
                bits.WriteBits((Int32)this._numFillBits, (Int32)this._fillStyle0);
            }
            if (this._stateFillStyle1)
            {
                bits.WriteBits((Int32)this._numFillBits, (Int32)this._fillStyle1);
            }
            if (this._stateLineStyle)
            {
                bits.WriteBits((Int32)this._numLineBits, (Int32)this._lineStyle);
            }
            if (this._stateNewStyles && (this._caller.Equals(TagTypes.DefineShape2) || this._caller.Equals(TagTypes.DefineShape3)))
            {
                bits.WriteFlush();
                this._fillStyles.Write(output);
                bits.WriteFlush();
                this._lineStyles.Write(output);
                bits.WriteFlush();
                bits.WriteBits(4, (Int32)this._newNumFillBits);
                bits.WriteBits(4, (Int32)this._newNumLineBits);
            }
        }
Beispiel #9
0
        /// <summary>
        /// Writes this object back to a stream
        /// </summary>
        /// <param name="output">The stream to write to</param>
        public virtual 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 );
            }
        }
Beispiel #10
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="output"></param>
        internal void Write(Stream output)
        {
            BinaryWriter bw = new BinaryWriter(output);

            BitStream bs = new BitStream(output);

            bs.WriteBits(1, false == this._HasAddTerms ? 0 : 1);
            bs.WriteBits(1, false == this._HasMultTerms ? 0 : 1);

            bs.WriteBits(4, this._Nbits );

            bs.WriteBits(this._Nbits, this._RedMultTerm);
            bs.WriteBits(this._Nbits, this._GreenMultTerm);
            bs.WriteBits(this._Nbits, this._BlueMultTerm);

            bs.WriteBits(this._Nbits, this._RedAddTerm);
            bs.WriteBits(this._Nbits, this._GreenAddTerm);
            bs.WriteBits(this._Nbits, this._BlueAddTerm);
            bs.WriteFlush();
        }
Beispiel #11
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);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="output"></param>
        /// <param name="version"></param>
        /// <param name="lastAction"></param>
        public void Write( Stream output, byte version, bool lastAction )
        {
            BinaryWriter bw = new BinaryWriter( output );

            if ( !lastAction )
            {
                _OffsetToNextCondAction = (ushort)this.Length;
            }
            else
            {
                _OffsetToNextCondAction = 0;
            }
            bw.Write( _OffsetToNextCondAction );

            BitStream bits = new BitStream( output );
            bits.WriteBits( 1, (_CondIdleToOverDown?1:0));
            bits.WriteBits( 1, (_CondOutDownToIdle?1:0));
            bits.WriteBits( 1, (_CondOutDownToOverDown?1:0));
            bits.WriteBits( 1, (_CondOverDownToOutDown?1:0));
            bits.WriteBits( 1, (_CondOverDownToOverUp?1:0));
            bits.WriteBits( 1, (_CondOverUpToOverDown?1:0));
            bits.WriteBits( 1, (_CondOverUpToIdle?1:0));
            bits.WriteBits( 1, (_CondIdleToOverUp?1:0));
            bits.WriteBits( 7, _CondKeyPress );
            bits.WriteBits( 1, ( _CondOverDownToIdle ? 1 : 0 ) );
            bits.WriteFlush();

            for ( int i = 0; i < _Code.Count; i++ )
            {
                _Code[ i ].Write( output );
            }
        }
Beispiel #13
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();
        }
Beispiel #14
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="output"></param>
        public void Write( Stream output )
        {
            BitStream bits = new BitStream( output );

            bits.WriteBits( 1, ( ClipEventKeyUp ? 1 : 0 ) );
            bits.WriteBits( 1, ( ClipEventKeyDown ? 1 : 0 ) );
            bits.WriteBits( 1, ( ClipEventMouseUp ? 1 : 0 ) );
            bits.WriteBits( 1, ( ClipEventMouseDown ? 1 : 0 ) );
            bits.WriteBits( 1, ( ClipEventMouseMove ? 1 : 0 ) );
            bits.WriteBits( 1, ( ClipEventUnload ? 1 : 0 ) );
            bits.WriteBits( 1, ( ClipEventEnterFrame ? 1 : 0 ) );
            bits.WriteBits( 1, ( ClipEventLoad ? 1 : 0 ) );
            if ( this.Version >= 6 )
            {
                // Swf6 and following
                bits.WriteBits( 1, ( ClipEventDragOver ? 1 : 0 ) );
                bits.WriteBits( 1, ( ClipEventRollOut ? 1 : 0 ) );
                bits.WriteBits( 1, ( ClipEventRollOver ? 1 : 0 ) );
                bits.WriteBits( 1, ( ClipEventReleaseOutside ? 1 : 0 ) );
                bits.WriteBits( 1, ( ClipEventRelease ? 1 : 0 ) );
                bits.WriteBits( 1, ( ClipEventPress ? 1 : 0 ) );
                bits.WriteBits( 1, ( ClipEventInitialize ? 1 : 0 ) );
                bits.WriteBits( 1, ( ClipEventData ? 1 : 0 ) );
                bits.WriteBits( 5, 0 ); // reserved
                // Swf6, used in Swf7
                if ( this.Version >= 7 )
                    bits.WriteBits( 1, ( ClipEventConstruct ? 1 : 0 ) );
                else
                    bits.WriteBits( 1, 0 );

                bits.WriteBits( 1, ( ClipEventKeyPress ? 1 : 0 ) );
                bits.WriteBits( 1, ( ClipEventDragOut ? 1 : 0 ) );
            }

            bits.WriteBits( 8, 0 ); // reserved

            bits.WriteFlush();
        }
Beispiel #15
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);
            }
        }
Beispiel #16
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="output"></param>
        /// <param name="version"></param>
        public virtual void Write( Stream output, byte version )
        {
            BitStream bits = new BitStream( output );
            // reserved
            bits.WriteBits( 2, 0 );
            bits.WriteBits( 1, ( _ButtonHasBlendMode ? 1 : 0 ) );
            bits.WriteBits( 1, ( _ButtonHasFilterList ? 1 : 0 ) );
            bits.WriteBits( 1, ( _ButtonStateHitTest ? 1 : 0 ) );
            bits.WriteBits( 1, ( _ButtonStateDown ? 1 : 0 ) );
            bits.WriteBits( 1, ( _ButtonStateOver ? 1 : 0 ) );
            bits.WriteBits( 1, ( _ButtonStateUp ? 1 : 0 ) );
            bits.WriteFlush();

            BinaryWriter bw = new BinaryWriter( output );
            bw.Write( _CharacterID );
            bw.Write( _PlaceDepth );
            _PlaceMatrix.Write( output );
        }
Beispiel #17
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);
        }