/// <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); }
/// <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(); }
/// <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(); }
/// <summary> /// /// </summary> /// <param name="output"></param> /// <param name="bits"></param> public override void Write(Stream output, BitStream bits ) { bits.WriteBits(1, 1); // type flag = 1 bits.WriteBits(1, 1); // straight flag = 1 bits.WriteBits(4, (UInt32)this._numbits); bits.WriteBits(1, (true == this._generalLineFlag ? 1 : 0)); if (!this._generalLineFlag) { bits.WriteBits(1, (true == this._vertLineFlag ? 1 : 0)); if (!this._vertLineFlag) { bits.WriteBits((Int32)this._numbits + 2, this._deltaX); } else { bits.WriteBits((Int32)this._numbits + 2, this._deltaY); } } else { bits.WriteBits((Int32)this._numbits + 2, this._deltaX); bits.WriteBits((Int32)this._numbits + 2, this._deltaY); } }
/// <summary> /// /// </summary> /// <param name="output"></param> internal void Write(Stream output) { BitStream bits = new BitStream(output); bits.WriteBits(11, this._synchWord); bits.WriteBits(2, this._MPEGVersion); bits.WriteBits(2, this._layer); bits.WriteBits(1, true == this._protectionBit ? 1 : 0); bits.WriteBits(4, this._bitrate); bits.WriteBits(2, this._samplingRate); bits.WriteBits(1, true == this._paddingBit ? 1 : 0); bits.WriteBits(1,0); bits.WriteBits(2, this._channelMode); bits.WriteBits(2, this._modeExtension); bits.WriteBits(1, true == this._copyright ? 1 : 0); bits.WriteBits(1, true == this._original ? 1 : 0); bits.WriteBits(2, this._emphasis); output.Write(this._sampleData, 0, this._sampleData.Length); }
/// <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(); }
/// <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); bits.WriteBits(1, 0); //reserved bits.WriteBits(5, this._Red); bits.WriteBits(5, this._Green); bits.WriteBits(5, this._Blue); }
/// <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); } }
/// <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(); }
/// <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); } }
/// <summary> /// Writes this object back to a stream. /// </summary> /// <param name="output">The stream to write to.</param> public void Write(Stream output) { this._fillStyles.Write(output); this._lineStyles.Write(output); BitStream bits = new BitStream(output); bits.WriteBits(4, (Int32)this._numFillBits); bits.WriteBits(4, (Int32)this._numLineBits); long startPosition = output.Position; output.Write(this._shapeRecordBuffer, 0, this._shapeRecordBuffer.Length); }
/// <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> /// 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 ); } }
/// <summary> /// /// </summary> /// <param name="input"></param> /// <param name="bits"></param> public override void Write(Stream input, BitStream bits) { bits.WriteBits(1, 1); // type flag bits.WriteBits(1, 0); // straight flag bits.WriteBits(4, (Int32)this._numbits); bits.WriteBits((Int32)this._numbits + 2, (Int32)this._controlDeltaX); bits.WriteBits((Int32)this._numbits + 2, (Int32)this._controlDeltaY); bits.WriteBits((Int32)this._numbits + 2, (Int32)this._anchorDeltaX); bits.WriteBits((Int32)this._numbits + 2, (Int32)this._anchorDeltaY); }
/// <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(); }
/// <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(); }
/// <summary> /// /// </summary> /// <param name="output"></param> /// <param name="bits"></param> public override void Write(Stream output, BitStream bits) { bits.WriteBits(6, 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 ); } }
/// <summary> /// /// </summary> /// <param name="output"></param> public void Write( Stream output ) { this._fillStyles.Write( output ); this._lineStyles.Write( output ); BitStream bits = new BitStream( output ); bits.WriteBits( 4, ( Int32 )this._numFillBits ); bits.WriteBits( 4, ( Int32 )this._numLineBits ); }
/// <summary> /// /// </summary> /// <param name="bits"></param> public void Write(BitStream bits) { bits.WriteBits(this._glyphBits, this._glyphIndex); bits.WriteBits(this._advancedBits, this._glyphAdvance); }
/// <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 ); }
/// <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> /// Writes this object back to a stream /// </summary> /// <param name="output">The stream to write to.</param> public void Write(Stream output) { if (this._zoneData.Count != (Int32)this._numZoneData) { SwfFormatException e = new SwfFormatException("The count of List<ZoneData> and the byte value of zone data differs. "); Log.Error(this, e.Message); throw e; } output.WriteByte(this._numZoneData); for (int i = 0; i < this._zoneData.Count; i++) { this._zoneData[i].Write(output); } BitStream bits = new BitStream(output); bits.WriteBits(6, 0); //reserved bits.WriteBits(1, Convert.ToInt32(this._zoneMaskY)); bits.WriteBits(1, Convert.ToInt32(this._zoneMaskX)); }
/// <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); }