public virtual byte[] GetData() { var writer = new SwfWriter(); WriteBody(writer); return(writer.ToByteArray()); }
internal override void ToSwf(SwfWriter w) { if (this.CompressionMode == CompressionType.ZLIB) { w.AppendByte((byte)'C'); } else if (this.CompressionMode == CompressionType.LZMA) { w.AppendByte((byte)'Z'); } else { w.AppendByte((byte)'F'); } w.AppendByte((byte)'W'); w.AppendByte((byte)'S'); w.AppendByte(this.Version); w.AppendUI32(this.FileLength); this.FrameSize.ToSwf(w); ushort frateWhole = (ushort)this.FrameRate; uint frateDec = (((uint)this.FrameRate * 0x100) & 0xFF); w.AppendUI16((uint)((frateWhole << 8) + frateDec)); w.AppendUI16(this.FrameCount); }
public byte[] GetData() { var writer = new SwfWriter(); WriteData(writer); return(writer.ToByteArray()); }
protected override void WriteBody(SwfWriter writer) { if (Body != null) { writer.Write(Body); } }
internal void ToSwf(SwfWriter w) { w.AppendBits(0, 2); w.AppendBit(ButtonHasBlendMode); w.AppendBit(ButtonHasFilterList); w.AppendBit(ButtonStateHitTest); w.AppendBit(ButtonStateDown); w.AppendBit(ButtonStateOver); w.AppendBit(ButtonStateUp); w.AppendUI16(CharacterID); w.AppendUI16(PlaceDepth); PlaceMatrix.ToSwf(w); if (containerTag == TagType.DefineButton2) { ColorTransform.ToSwf(w, true); if (ButtonHasFilterList) { w.AppendByte((byte)FilterList.Count); for (int i = 0; i < FilterList.Count; i++) { FilterList[i].ToSwf(w); } } if (ButtonHasBlendMode) { w.AppendByte((byte)BlendMode); } } }
public void Write(SwfWriter writer) { writer.WriteUIntEncoded((uint)_method.Index); writer.WriteUIntEncoded((uint)MaxStackDepth); writer.WriteUIntEncoded((uint)LocalCount); writer.WriteUIntEncoded((uint)MinScopeDepth); writer.WriteUIntEncoded((uint)MaxScopeDepth); if (_il != null) { using (var codeWriter = new SwfWriter()) { codeWriter.ABC = writer.ABC; _il.Write(codeWriter); var code = codeWriter.ToByteArray(); writer.WriteUIntEncoded((uint)code.Length); writer.Write(code); } } else { writer.WriteUInt8(0); } _exceptions.Write(writer); _traits.Write(writer); }
internal void ToSwf(SwfWriter w) { w.AppendBits(0, 2); // reserved w.AppendBit(IsSyncStop); w.AppendBit(IsSyncNoMultiple); w.AppendBit(HasEnvelope); w.AppendBit(HasLoops); w.AppendBit(HasOutPoint); w.Align(); if (HasInPoint) { w.AppendUI32(InPoint); } if (HasOutPoint) { w.AppendUI32(OutPoint); } if (HasLoops) { w.AppendUI16(LoopCount); } if (HasEnvelope) { w.AppendByte((byte)LoopCount); uint count = (uint)EnvelopeRecords.Length; for (int i = 0; i < EnvelopeRecords.Length; i++) { w.AppendUI32(EnvelopeRecords[i].Pos44); w.AppendUI16(EnvelopeRecords[i].LeftLevel); w.AppendUI16(EnvelopeRecords[i].RightLevel); } } }
public void Write(SwfWriter writer) { writer.ABC = this; var ver = Version; writer.WriteUInt16((ushort)ver.Minor); writer.WriteUInt16((ushort)ver.Major); if (ver.Major == CurrentMajor && ver.Minor == CurrentMinor) { IntPool.Write(writer); UIntPool.Write(writer); DoublePool.Write(writer); StringPool.Write(writer); Namespaces.Write(writer); NamespaceSets.Write(writer); Multinames.Write(writer); Methods.Write(writer); Metadata.Write(writer); int n = Instances.Count; writer.WriteUIntEncoded((uint)n); Instances.Write(writer); Classes.Write(writer); Scripts.Write(writer); MethodBodies.Write(writer); } else { throw new NotImplementedException(); } }
internal override void ToSwf(SwfWriter w) { w.AppendByte((byte)ActionKind.DefineFunction); w.AppendUI16(Length - 3); // don't incude def byte and len w.AppendString(FunctionName); w.AppendUI16((uint)Params.Length); for (int i = 0; i < Params.Length; i++) { w.AppendString(Params[i]); } w.AppendUI16(CodeSize); // temp long startPos = w.Position; for (int i = 0; i < Statements.Count; i++) { Statements[i].ToSwf(w); } // adjust code size long curPos = w.Position; if (codeSize != (curPos - startPos)) { codeSize = (uint)(curPos - startPos); w.Position = startPos - 2; w.AppendUI16(CodeSize); // acutal w.Position = curPos; } }
private static byte[] GetRGB24(Bitmap bmp, bool alpha) { var writer = new SwfWriter(); //NOTE: The RGB data must already be multiplied by the alpha channel value. int w = bmp.Width; int h = bmp.Height; using (var fbmp = new FastBitmap(bmp)) { for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { var c = fbmp[x, y]; if (alpha) { c = MulAlpha(c); writer.WriteARGB(c); } else { writer.WriteUInt8(0); writer.WriteUInt8(c.R); writer.WriteUInt8(c.G); writer.WriteUInt8(c.B); } } } } return(writer.ToByteArray()); }
protected override void WriteBeforeClipActions(SwfWriter writer) { if ((Flags & SwfPlaceFlags.HasFilterList) != 0) { _filters.Write(writer); } }
internal override void ToSwf(SwfWriter w, ref uint fillBits, ref uint lineBits, ShapeType shapeType) { w.AppendBit(true); w.AppendBit(true); uint bits = SwfWriter.MinimumBits(DeltaX, DeltaY); bits = bits < 2 ? 2 : bits; // min 2 bits w.AppendBits(bits - 2, 4); if (DeltaX != 0 && DeltaY != 0) { w.AppendBit(true); w.AppendSignedNBits(DeltaX, bits); w.AppendSignedNBits(DeltaY, bits); } else if (DeltaX == 0) { w.AppendBit(false); w.AppendBit(true); w.AppendSignedNBits(DeltaY, bits); } else { w.AppendBit(false); w.AppendBit(false); w.AppendSignedNBits(DeltaX, bits); } }
internal void ToSwf(SwfWriter w, bool isSwf6Plus) { if ((uint)ClipEvents == 0) { if (isSwf6Plus) { w.AppendUI32(0); } else { w.AppendUI16(0); } } else { w.AppendBits((uint)ClipEvents, 32); uint start = (uint)w.Position; w.AppendUI32(0); // write len after tag written if ((ClipEvents & ClipEvents.KeyPress) > 0) { w.AppendByte(KeyCode); } ActionRecords.ToSwf(w); uint end = (uint)w.Position; w.Position = start; w.AppendUI32(end - start - 4); w.Position = end; } }
public override void Write(SwfWriter writer, SwfTagCode shapeType) { if (DeltaX == 0 && DeltaY == 0) { return; } writer.WriteBit(true); //edge flag writer.WriteBit(true); //strait flag if (DeltaX == 0) //vert { WriteCoord(writer, DeltaY, true); } else if (DeltaY == 0) //horz { WriteCoord(writer, DeltaX, false); } else { int x = DeltaX.ToTwips(); int y = DeltaY.ToTwips(); int bits = _bits; if (!_read) { bits = Math.Max(x.GetMinBits(y), 2); } writer.WriteUB((uint)(bits - 2), 4); writer.WriteBit(true); //gl writer.WriteSB(x, bits); writer.WriteSB(y, bits); } }
internal override void ToSwf(SwfWriter w) { w.AppendByte((byte)ActionKind.GoToLabel); w.AppendUI16(Length - 3); // don't incude def byte and len w.AppendString(Label); }
internal override void ToSwf(SwfWriter w) { uint start = (uint)w.Position; w.AppendTagIDAndLength(this.TagType, 0, true); w.AppendBits(0, 4); switch (PlaybackSoundRate) { case 55000: w.AppendBits(0, 2); break; case 11000: w.AppendBits(1, 2); break; case 22000: w.AppendBits(2, 2); break; case 44000: w.AppendBits(3, 2); break; } w.AppendBit(PlaybackSoundSize == 16u); w.AppendBit(IsStereo); w.AppendBits((uint)StreamSoundCompression, 4); switch (StreamSoundRate) { case 55000: w.AppendBits(0, 2); break; case 11000: w.AppendBits(1, 2); break; case 22000: w.AppendBits(2, 2); break; case 44000: w.AppendBits(3, 2); break; } w.AppendBit(StreamSoundSize == 16u); w.AppendBit(StreamIsStereo); w.Align(); w.AppendUI16(StreamSoundSampleCount); if (StreamSoundCompression == SoundCompressionType.MP3) { w.AppendUI16(LatencySeek); } w.ResetLongTagLength(this.TagType, start); }
internal override void ToSwf(SwfWriter w) { uint start = (uint)w.Position; w.AppendTagIDAndLength(this.TagType, 0, true); w.AppendUI16(ButtonId); w.AppendBits(0, 7); w.AppendBit(TrackAsMenu); w.AppendUI16(ActionOffset); // todo: calc offset for (int i = 0; i < Characters.Count; i++) { Characters[i].ToSwf(w); } w.AppendByte(0); if (ActionOffset > 0) { ButtonCondActions[ButtonCondActions.Count - 1].CondActionSize = 0; for (int i = 0; i < ButtonCondActions.Count; i++) { ButtonCondActions[i].ToSwf(w); } } w.ResetLongTagLength(this.TagType, start, true); }
internal override void ToSwf(SwfWriter w, bool useAlpha) { w.AppendUI16(this.Width); w.AppendBits((uint)this.StartCapStyle, 2); w.AppendBits((uint)this.JoinStyle, 2); w.AppendBit(this.HasFillFlag); w.AppendBit(this.NoHScaleFlag); w.AppendBit(this.NoVScaleFlag); w.AppendBit(this.PixelHintingFlag); w.AppendBits(0, 5); w.AppendBit(this.NoClose); w.AppendBits((uint)this.EndCapStyle, 2); if (this.JoinStyle == JoinStyle.MiterJoin) { w.AppendFixed8_8(this.MiterLimitFactor); } if (this.HasFillFlag) { this.FillStyle.ToSwf(w); } else { w.AppendByte(Color.R); w.AppendByte(Color.G); w.AppendByte(Color.B); if (useAlpha) { w.AppendByte(Color.A); } } }
internal override void ToSwf(SwfWriter w) { w.AppendByte((byte)ActionKind.WaitForFrame2); w.AppendUI16(Length - 3); // don't incude def byte and len w.AppendByte((byte)SkipCount); }
public void Write(SwfWriter writer) { writer.WriteUIntEncoded((uint)_name.Index); if (_metadata == null) { Attributes &= ~AbcTraitAttributes.HasMetadata; } else { Attributes |= AbcTraitAttributes.HasMetadata; } int kind = ((int)_kind & 0x0F) | ((int)Attributes << 4); writer.WriteUInt8((byte)kind); _slot.Write(writer); if (_metadata != null) { int n = _metadata.Count; writer.WriteUIntEncoded((uint)n); for (int i = 0; i < n; ++i) { writer.WriteUIntEncoded((uint)_metadata[i].Index); } } }
internal override void ToSwf(SwfWriter w) { w.AppendByte((byte)ActionKind.StoreRegister); w.AppendUI16(Length - 3); // don't incude this part w.AppendByte((byte)Register); }
public void Write(SwfWriter writer) { writer.WriteUIntEncoded((uint)Name.Index); if (BaseTypeName == null) { writer.WriteUInt8(0); } else { writer.WriteUIntEncoded((uint)BaseTypeName.Index); } writer.WriteUInt8((byte)Flags); if ((Flags & AbcClassFlags.ProtectedNamespace) != 0) { writer.WriteUIntEncoded((uint)ProtectedNamespace.Index); } int n = _interfaces.Count; writer.WriteUIntEncoded((uint)n); for (int i = 0; i < n; ++i) { var iface = _interfaces[i]; writer.WriteUIntEncoded((uint)iface.Index); } writer.WriteUIntEncoded((uint)_initializer.Index); _traits.Write(writer); }
internal override void ToSwf(SwfWriter w) { // write header this.Header.ToSwf(w); for (int i = 0; i < Tags.Count; i++) { //if (i == 0x2de)//w.Position >= 0x3cd20)// //{ // i = i; //} if (Tags[i] is PlaceObject2Tag) { bool is6Plus = this.Header.Version > 5; ((PlaceObject2Tag)Tags[i]).ToSwf(w, is6Plus); } else { Tags[i].ToSwf(w); } } if (Header.IsCompressed) { w.Zip(); } uint len = (uint)w.Position; w.Position = 4; w.AppendUI32(len); w.Position = len; }
public override void WriteTagData(SwfWriter writer) { if (Data != null) { writer.Write(Data); } }
internal override void ToSwf(SwfWriter w) { w.AppendByte((byte)ActionKind.SetTarget); w.AppendUI16(Length - 3); // don't incude def byte and len w.AppendString(TargetName); }
public static void WriteConstIndex(this SwfWriter writer, object value) { var c = value as IAbcConst; if (c != null) { writer.WriteUIntEncoded((uint)c.Index); writer.WriteUInt8((byte)c.Kind); return; } var kind = GetConstantKind(value); switch (kind) { case AbcConstKind.True: case AbcConstKind.False: case AbcConstKind.Null: case AbcConstKind.Undefined: writer.WriteUInt8((byte)kind); writer.WriteUInt8((byte)kind); break; default: throw new NotImplementedException(); } }
internal override void ToSwf(SwfWriter w) { w.AppendByte((byte)ActionKind.Jump); w.AppendUI16(Length - 3); // don't incude def byte and len w.AppendInt16(BranchOffset); }
/// <summary> /// Gets tag data. /// </summary> /// <returns></returns> public virtual byte[] GetData() { var body = new SwfWriter(); WriteTagData(body); return(body.ToByteArray()); }
internal override void ToSwf(SwfWriter w) { w.AppendByte((byte)PrimitiveType); byte b = (BooleanValue == true) ? (byte)0x01 : (byte)0x00; w.AppendByte(b); }
internal override void ToSwf(SwfWriter w) { uint start = (uint)w.Position; w.AppendTagIDAndLength(this.TagType, 0, true); w.AppendUI16(CharacterID); Bounds.ToSwf(w); w.AppendBit(HasText); w.AppendBit(WordWrap); w.AppendBit(Multiline); w.AppendBit(Password); w.AppendBit(ReadOnly); w.AppendBit(HasTextColor); w.AppendBit(HasMaxLength); w.AppendBit(HasFont); w.AppendBit(false);// resreved w.AppendBit(AutoSize); w.AppendBit(HasLayout); w.AppendBit(NoSelect); w.AppendBit(Border); w.AppendBit(false);// resreved w.AppendBit(HTML); w.AppendBit(UseOutlines); if (HasFont) { w.AppendUI16(FontID); w.AppendUI16(FontHeight); } if (HasTextColor) { w.AppendByte((byte)TextColor.R); w.AppendByte((byte)TextColor.G); w.AppendByte((byte)TextColor.B); w.AppendByte((byte)TextColor.A); } if (HasMaxLength) { w.AppendUI16(MaxLength); } if (HasLayout) { w.AppendByte((byte)Align); w.AppendUI16(LeftMargin); w.AppendUI16(RightMargin); w.AppendUI16(Indent); w.AppendUI16((uint)Leading); } w.AppendString(VariableName); if (HasText) { w.AppendString(InitialText); } w.ResetLongTagLength(this.TagType, start, true); }